コード例 #1
0
ファイル: shapes.c プロジェクト: agyoungs/306GPS
/*******************************************************************************
* Purpose: Moves the car in a triangle for however many triangle segments
*           designated by the numTriangles parameter.
* Passed: int numTriangles - number of triangles to do.
* Locals: unsigned int turn - the amount of an arc to turn between segements.
*         unsigned int delay - the amount of delay between segments.
*         unsigned int tri_leg - the amount of time doing a segment.
* Returned: No values returned.
* Author: Will Flores [email protected]
*******************************************************************************/
void triangle (int numTriangles) {
    unsigned int turn = 150; // orig = 200 
    unsigned int delay = 100;
    unsigned int tri_leg = 300;

    for(; numTriangles > NO_MORE_SHAPES; --numTriangles) {
        // first leg
        set_lWheelCount(tri_leg);
        set_rWheelCount(tri_leg);
        start_wheelTimers();
        move_forward();
        while(timerB0_started || timerA0_started);
        timerDelay(delay); // a second delay
        while (timerA1_started);

        // turn some
        set_rWheelCount(turn);
        start_rightWheel();
        right_motor_forward();
        while(timerB0_started || timerA0_started);
        timerDelay(delay); // a second delay
        while (timerA1_started);


        // next leg
        set_lWheelCount(tri_leg);
        set_rWheelCount(tri_leg);
        start_wheelTimers();
        move_forward();
        while(timerB0_started || timerA0_started);
        timerDelay(delay); // a second delay
        while (timerA1_started);

        // turn somemore
        set_rWheelCount(turn);
        start_rightWheel();
        right_motor_forward();
        while(timerB0_started || timerA0_started);
        timerDelay(delay); // a second delay
        while (timerA1_started);

        // home stretch
        set_lWheelCount(tri_leg);
        set_rWheelCount(tri_leg);
        start_wheelTimers();
        move_forward();
        while(timerB0_started || timerA0_started);
        timerDelay(delay); // a second delay
        while (timerA1_started);

        // turn a bit and done
        set_rWheelCount(turn);
        start_rightWheel();
        right_motor_forward();
        while(timerB0_started || timerA0_started);
        timerDelay(2*delay); // a 2 second delay
        while (timerA1_started);
    }
    return;	
}
コード例 #2
0
ファイル: race.c プロジェクト: siberianbrother/robotics-2016
int main(void) {


    initialise_cells();

    tremaux();

    convert_unknown_to_walls();

    create_matrix();

    path_init();
    printf("Will do dikstra from %d\n", find_current_cell());
    dijkstra(find_current_cell(), 0);

    int z;

    for (z = 0; z < 16; z ++)
    {
        printf("%d ", short_path[z]);
    }

    follow_shortest(1);

    swap_direction('s');
    move_forward();
    swap_direction('n');

    int i;

    for (i = 0; i < 3; i++)
    {
        high(26);
        pause(500);
        low(26);
        pause(500);
    }

    move_forward();
    path_init();
    dijkstra(0, 15);
    follow_shortest(0);

    for (i = 0; i < 3; i++)
    {
        high(26);
        pause(500);
        low(26);
        pause(500);
    }

    return 0;
}
コード例 #3
0
ファイル: Legs.cpp プロジェクト: duducosmos/legs
void Legs::move_according_state(){
    /*
    Given the current state, update the moviment.
    */
    switch (get_current_state()) {
        case FORWARD:
        move_forward();
        break;
        case BACKWARD:
        move_backward();
        break;
        case LEFT:
        turn_left();
        break;
        case RIGHT:
        turn_right();
        break;
        case BYELEFT:
        bye_bye_left();
        break;
        case BYERIGHT:
        bye_bye_right();
        break;
        case STOP:
        zero_pos();
        break;
        default:
        zero_pos();
        break;
    }

}
コード例 #4
0
ファイル: Camera3D.cpp プロジェクト: Ceffa/Ryno-Engine
	void Camera3D::move_relative_to_view(F32 speed, glm::vec2 coords){
		
		F32 total_speed = sqrt(coords.x * coords.x + coords.y * coords.y);
		move_forward(speed * -coords.y / total_speed);
		move_right(speed * coords.x / total_speed);

	}
コード例 #5
0
ファイル: merge_vector.hpp プロジェクト: LocutusOfBorg/poedit
void merge_level4(range<Iter1_t> dest, std::vector<range<Iter2_t> > &v_input,
                  std::vector<range<Iter1_t> > &v_output, Compare comp)
{
    typedef range<Iter1_t> range1_t;
    typedef util::value_iter<Iter1_t> type1;
    typedef util::value_iter<Iter2_t> type2;
    static_assert (std::is_same< type1, type2 >::value,
                    "Incompatible iterators\n");

    v_output.clear();
    if (v_input.size() == 0) return;
    if (v_input.size() == 1)
    {
        v_output.emplace_back(move_forward(dest, v_input[0]));
        return;
    };

    uint32_t nrange = v_input.size();
    uint32_t pos_ini = 0;
    while (pos_ini < v_input.size())
    {
        uint32_t nmerge = (nrange + 3) >> 2;
        uint32_t nelem = (nrange + nmerge - 1) / nmerge;
        range1_t rz = full_merge4(dest, &v_input[pos_ini], nelem, comp);
        v_output.emplace_back(rz);
        dest.first = rz.last;
        pos_ini += nelem;
        nrange -= nelem;
    };
    return;
};
コード例 #6
0
ファイル: main.c プロジェクト: pidaeus/libpi
int main() {
  closure = pi_default_closure();
  pi_gpio_setup(closure);

  pi_gpio_pin_t gpioe = PIN_ENABLE;
  pi_gpio_pin_t gpioa1 = PIN_COIL_A1;
  pi_gpio_pin_t gpioa2 = PIN_COIL_A2;
  pi_gpio_pin_t gpiob1 = PIN_COIL_B1;
  pi_gpio_pin_t gpiob2 = PIN_COIL_B2;

  pin_enable = pi_gpio_claim_output(closure, gpioe, PI_GPIO_HIGH);
  pin_coil_a1 = pi_gpio_claim_output(closure, gpioa1, PI_GPIO_LOW);
  pin_coil_a2 = pi_gpio_claim_output(closure, gpioa2, PI_GPIO_LOW);
  pin_coil_b1 = pi_gpio_claim_output(closure, gpiob1, PI_GPIO_LOW);
  pin_coil_b2 = pi_gpio_claim_output(closure, gpiob2, PI_GPIO_LOW);

  move_forward(5, 356);
  move_backward(30, 45);

  pi_gpio_write(pin_enable, PI_GPIO_LOW);
  pi_gpio_release(pin_enable);
  pi_gpio_release(pin_coil_a1);
  pi_gpio_release(pin_coil_a2);
  pi_gpio_release(pin_coil_b1);
  pi_gpio_release(pin_coil_b2);

  pi_gpio_teardown(closure);

  return 0;
}
コード例 #7
0
/*** get keypad input ****/
void get_keypad_input() {  
  char keypad_key;
  keypad_enable();
  while(training) {
    keypad_key=getkey();          // get value from keypad
    wait_keyup();
    lcd_init();
    set_lcd_addr(0x00);
    if(keypad_key==1) {           // 1 = forward
      move_forward();               
    }else if(keypad_key==4) {     // 4 = left
      move_left();
    }else if(keypad_key==7) {     // 7 = right
      move_right();
    }else if(keypad_key==0) {     // 0 = reverse
      move_reverse();
    }else if(keypad_key==6) {     // 7 = pause
      move_pause();
    }else if(keypad_key==9) {     // break out of training mode
      training=0;
      move_stop();
      display_movement(&stop_training);
      break;
    }else{
      display_movement(&error);
    }
    ms_delay(50);
  }
}
コード例 #8
0
void train()
{
  
  if (matrix_last_time + 100 < millis())
  {
    
    matrix_last_time = millis();
    move_forward(false); 
     // cars
     if(random(400) < 10)
     {
     amount = max(0,min(current_volume/20,10)-2);
     if (running_vol_avg < 100)
    for (int i = 0; i  < random(amount);i++)
    {
     int value = random(7);
     picture[num_panels * 16 -1][value] = green;
   //  picture[num_panels * 16 -2][value] = green;
    }
    if (current_volume > 10 && train_num == 0)
    {
      train_num = random(4,7);
      train_pos = random(0,7);
    }
    if (train_num > 0)
    {
      train_num--;
      picture[num_panels * 16 -1][train_pos] = red;
    }
     }
 
    
  }
}
コード例 #9
0
ファイル: fiend.cpp プロジェクト: s4ayub/TowerDefenseGame
fiend::fiend(QGraphicsItem *parent)
{
    // set graphics
    poly2 << QPointF(0,0)
         << QPointF(30,0)
         << QPointF(30,30)
         << QPointF(0,30);

    (this)->setPolygon(poly2);
    (this)->setPen(QPen(Qt::darkRed));
    (this)->setBrush(QBrush(Qt::darkRed));

    //HEALTH BAR!!!
    health = 100;
    STEP_SIZE = 6;

    // set points
   points << QPointF(97,82) << QPointF(770,82); // move down-right then right
    point_index = 0;
    destination = points[0];
    rotateToPoint(destination);


    // connect timer to move_forward
   QTimer * timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(move_forward()));
    timer->start(150);
}
コード例 #10
0
ファイル: gntentry.c プロジェクト: mclarkelauer/HoneyIM
static gboolean
transpose_chars(GntBindable *bind, GList *null)
{
	GntEntry *entry = GNT_ENTRY(bind);
	char *current, *prev;
	char hold[8];  /* that's right */

	if (entry->cursor <= entry->start)
		return FALSE;

	if (!*entry->cursor)
		entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor);

	current = entry->cursor;
	prev = g_utf8_find_prev_char(entry->start, entry->cursor);
	move_forward(bind, null);

	/* Let's do this dance! */
	memcpy(hold, prev, current - prev);
	memmove(prev, current, entry->cursor - current);
	memcpy(prev + (entry->cursor - current), hold, current - prev);

	update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
	entry_redraw(GNT_WIDGET(entry));
	entry_text_changed(entry);
	return TRUE;
}
コード例 #11
0
ファイル: race.c プロジェクト: siberianbrother/robotics-2016
/*
 * Move robot forward, update current position and perform adjustments if the cell has been visited before
 */
void move()
{

    move_forward();
    update_position();

    int i = find_current_cell();
    int k = find_prev_cell();

    if (cells[i].visited == 0) {
        check_walls();
        determ_type(i);
        checked_walls = 1;
        drive_through = 0;
    }

    else {
        checked_walls = 1;
        check_wall_weights();
        printf("Attempting adjustment...\n");
        drive_through = 1;
        perform_angle_adjustment(k, i);
        perform_one_wall_adjustment(i);

    }

    update_visited();
}
コード例 #12
0
ファイル: Lab5.c プロジェクト: cucucachu/CPE416
int main() {
	all_init();	
	while(1) {
		move_forward(SIDE_LENGTH);
		turn_right();
	}
}
コード例 #13
0
/*** Playback Robot ***/
void playback_robot(){
  while(playback) {
    int i=0;
    display_movement(&start_playback);
    /* pull from array */
    for(i=0; i<=array_length; i++) {
      int direction=array1[i];
      
      if(direction == 1) {
        move_forward();
      }else if(direction == 2) {
        move_left();
      }else if(direction == 3) {
        move_right();
      }else if(direction == 4) {
        move_reverse();
      }else if(direction == 5) {
        move_pause();
      }else if((direction == 0) || (direction == 9)) {
        playback=0;
        display_movement(&stop_playback);
        break;
      } else {
        playback=0;
        break;
      }
      if(SW5_down()){         //switch5 stop playback mode
        playback=0;
        display_movement(&stop_playback);
      }
    }
  }
}
コード例 #14
0
ファイル: Robot.cpp プロジェクト: Keiger/Karel
void Robot::move_back()
{
    int temp = getDirection();
    turn();
    turn();
    move_forward();
    direction = temp;
}
コード例 #15
0
ファイル: race.c プロジェクト: siberianbrother/robotics-2016
/*
 * Perform Tremaux algorithm until all 3 goal cells are visited
 *
 * Determine behavior of the robot in a cell according to its type
 * (path/dead end/junction)
 *
 * if path - go to the only possible direction
 * if dead end - rotate 180
 * if coming from a visited path - go to neighbour with least marks on a junction
 * if coming from a new path
 *  if junction is new - randomly choose direction
 *  if not - rotate 180
 */
void tremaux()
{

    move_forward();
    check_walls();
    determ_type(0);
    update_visited();

    int k, m, l;
    k = find_cell(goal1_x, goal1_y); //get goal cells
    m = find_cell(goal2_x, goal2_y);
    l = find_cell(goal3_x, goal3_y);

    while (cells[k].visited == 0 || cells[l].visited == 0 || cells[m].visited == 0) {

        int i = find_current_cell();

        if (cells[i].type == 'p')
        {
            choose_direction_p();
        }

        if (cells[i].type == 'd')
        {
            rotate_180();
            update_visited();

        }

        if (cells[i].type == 'j')
        {

            int p = find_prev_cell();

            if (cells[p].visited == 1)
            {
                if (cells[i].visited == 1)
                {
                    choose_direct_rand_j();
                }

                else
                {
                    rotate_180();
                }
            }

            else
            {
                with_least_marks();
            }
        }

        move();
    }
}
コード例 #16
0
ファイル: main.c プロジェクト: cleichner/bubbly
int main(void) {
    enc_init();
    motor_init();

    encoder_debug_init();

    right_turns = 0;
    left_turns = 0;
    right_direction = REVERSE;
    left_direction = REVERSE;

    encoder_debug_init();

    //Enable all interrupts
    sei();

    DDRC &= ~(_BV(DDC5));
    while (!(has_wall(RIGHT) && has_wall(RIGHT))) {
        move_forward(1);
    }
    turn_right(1);
    move_forward(1);

    while (1) {
        if (has_wall(RIGHT)) {
            PORTC |= _BV(PORTC3);
        } else {
            PORTC &= ~(_BV(PORTC3));
        }
        if (has_wall(LEFT)) {
            PORTC |= _BV(PORTC2);
        } else {
            PORTC &= ~(_BV(PORTC2));
        }
        /*
        while ((PINC & _BV(PINC5)));
        move_forward(1);
        move_forward(1);
        turn_right(1);
        move_forward(1);
        */
    }
}
コード例 #17
0
ファイル: smart_object.cpp プロジェクト: confuzedskull/G2
void smart_object::attract(complex_object target)//object moves toward object B
{
    if(near_front(target))
        move_forward();
    if(near_back(target))
        move_back();
    if(near_left(target))
        move_left();
    if(near_right(target))
        move_right();
}
コード例 #18
0
ファイル: process.c プロジェクト: yachaka/Wolf3D
void			process(t_env *e)
{
	if (e->input->a == 1)
		move_left(e);
	else if (e->input->d == 1)
		move_right(e);
	if (e->input->w == 1)
		move_forward(e);
	else if (e->input->s == 1)
		move_backward(e);
}
コード例 #19
0
ファイル: smart_object.cpp プロジェクト: confuzedskull/G2
void smart_object::repel(complex_object target)//object moves away from object B
{
    if(near_front(target))
        move_back();
    if(near_back(target))
        move_forward();
    if(near_left(target))
        move_right();
    if(near_right(target))
        move_left();
}
コード例 #20
0
ファイル: merge_vector.hpp プロジェクト: LocutusOfBorg/poedit
range<Iter2_t> merge_vector4(range<Iter1_t> range_input,
                             range<Iter2_t> range_output,
                             std::vector<range<Iter1_t> > &v_input,
                             std::vector<range<Iter2_t> > &v_output,
                             Compare comp)
{
    typedef range<Iter2_t> range2_t;
    typedef util::value_iter<Iter1_t> type1;
    typedef util::value_iter<Iter2_t> type2;
    static_assert (std::is_same< type1, type2 >::value,
                    "Incompatible iterators\n");

    v_output.clear();
    if (v_input.size() == 0)
    {
        return range2_t(range_output.first, range_output.first);
    };
    if (v_input.size() == 1)
    {
        return move_forward(range_output, v_input[0]);
    };
    bool sw = false;
    uint32_t nrange = v_input.size();

    while (nrange > 1)
    {
        if (sw)
        {
            merge_level4(range_input, v_output, v_input, comp);
            sw = false;
            nrange = v_input.size();
        }
        else
        {
            merge_level4(range_output, v_input, v_output, comp);
            sw = true;
            nrange = v_output.size();
        };
    };
    return (sw) ? v_output[0] : move_forward(range_output, v_input[0]);
};
コード例 #21
0
ファイル: main.cpp プロジェクト: treeffle/sdbot
void perform_action(gamestate_t *gs, int action)
{
	switch(action)
	{
		case 0: noop(gs); qbLog("Noop"); break;
		case 1: turn_left(gs); qbLog("turn left"); break;
		case 2: turn_right(gs); qbLog("turn right"); break;
		case 3: move_forward(gs); qbLog("move forward"); break;
		case 4: move_backward(gs); qbLog("move backward"); break;
		case 5: jump(gs); qbLog("jump"); break;
		case 6: shoot(gs); qbLog("shoot"); break;
	}
}
コード例 #22
0
ファイル: help.c プロジェクト: GarothLongint/mc
static void
help_next_link (gboolean move_down)
{
    const char *new_item;

    new_item = select_next_link (selected_item);
    if (new_item != NULL)
    {
        selected_item = new_item;
        if ((int) (selected_item - last_shown) >= 0)
        {
            if (move_down)
                move_forward (1);
            else
                selected_item = NULL;
        }
    }
    else if (move_down)
        move_forward (1);
    else
        selected_item = NULL;
}
コード例 #23
0
ファイル: events.c プロジェクト: pdaumont/my_lab
int			loop_event(t_app *app)
{
	if (app->player.move_forward == 1)
		move_forward(app);
	if (app->player.move_backward == 1)
		move_backward(app);
	if (app->player.turn_left == 1)
		turn_left(app);
	if (app->player.turn_right == 1)
		turn_right(app);
	refresh(app);
	return (0);
}
コード例 #24
0
void loop()
{
    if (Serial.available() > 0)
    {
        int command = Serial.read();
        Serial.print(command, DEC);
        Serial.print(" ");
        switch (command)
        {
            case 1:
            move_stop();
            delay(500);
            move_forward();
            break;
            case 2:
            move_stop();
            delay(500);
            turn_left();
            break;
            case 3:
            move_stop();
            delay(500);
            turn_right();
            break;
            case 4:
            move_stop();
            delay(500);
            move_backward();
            break;
            case 5:
            move_stop();
            break;
            case 6:
            front_led_control(true);
            break;
            case 7:
            front_led_control(false);
            break;
            case 8:
            rear_led_control(true);
            break;
            case 9:
            rear_led_control(false);
            break;
            default:
            move_stop();
            front_led_control(false);
            rear_led_control(false);
        }
    }
}
コード例 #25
0
int main(void)
{	intialisation();
	// receiving data from master robot
	
			// receiving data from master robot
			UCSR0B=0xD8;		// initializing receiving
			while (flag1==0);	// calling interrupt till flag1==0
			UCSR0B=0x00;		//stop receiving
			//after storing the resolved path slave will move forward and follow the resolved path
			while(tag==0)
			while(tag==0)
			{
				move_forward();				
			}		
}
コード例 #26
0
void picture_move()
{
  if (changed)
  {
    draw_picture();
    //Serial.println("dr");
  }
  if(current_beat)
  {
    move_forward(true);


  }

}
コード例 #27
0
ファイル: enemy.cpp プロジェクト: ushalin/TowerDefence
enemy::enemy(QGraphicsItem *parent){
    // set graphics
    setPixmap(QPixmap(":/images/pika.png"));

    // set points
    points << QPointF(200,200) << QPointF(400,200); // move down-right then right
    point_index = 0;
    destination = points[0];
    rotateToPoint(destination);

    // connect timer to move_forward
    QTimer * timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(move_forward()));
    timer->start(150);
}
コード例 #28
0
ファイル: events.c プロジェクト: amasson42/projects
int		key_press(int keycode, t_env *e)
{
	if (keycode == KEY_ALPHA_Q)
		move_leftward(e->map, 1);
	else if (keycode == KEY_ALPHA_W)
		move_forward(e->map, 1);
	else if (keycode == KEY_ALPHA_E)
		move_rightward(e->map, 1);
	else if (keycode == KEY_ALPHA_A)
		turn_left(e->map, 1);
	else if (keycode == KEY_ALPHA_S)
		move_backward(e->map, 1);
	else if (keycode == KEY_ALPHA_D)
		turn_right(e->map, 1);
	return (0);
}
コード例 #29
0
void matrix()
{
  if (matrix_last_time + 15 < millis())
  {
  
    matrix_last_time = millis();
    move_forward(false); 
  for (int i = 0; i  < random(4);i++)
  {
   int value = random(8);
 picture[num_panels * 16 -0][value] = random(4);;
 picture[num_panels * 16 -1][value] = random(4);
  }
 
   
  }
}
コード例 #30
0
ファイル: enemy.cpp プロジェクト: d-dawn/TiborChess
Enemy::Enemy(QList<QPointF> pointsToFollow,QGraphicsItem *parent)
{

 QPixmap blueenemy(":/images/red.png");
 QPixmap newPixmap = blueenemy.scaled(QSize(30,30),  Qt::KeepAspectRatio);
 setPixmap(QPixmap(newPixmap));
 points = pointsToFollow;
 point_index = 0;
 dest = points[0];
 rotateToPoint(dest);
 Health = 100;


 timer = new QTimer(this);
 connect(timer,SIGNAL(timeout()),this,SLOT(move_forward()));
         timer->start(200);
}