当前位置: 首页>>代码示例>>C++>>正文


C++ set_speed函数代码示例

本文整理汇总了C++中set_speed函数的典型用法代码示例。如果您正苦于以下问题:C++ set_speed函数的具体用法?C++ set_speed怎么用?C++ set_speed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_speed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: trash_water_treatment

order_result_t trash_water_treatment(void){
  ROME_LOG(&rome_paddock,INFO,"Trashing water in treatment area");
  order_result_t or;
  set_speed(RS_FAST);

  _wait_meca_ready();
  ROME_SENDWAIT_MECA_CMD(&rome_meca,ROME_ENUM_MECA_COMMAND_PREPARE_TRASH_TREATMENT);
  _wait_meca_ground_clear();

  //store nb balls for scoring purpose
  uint8_t balls_loaded = robot_state.cylinder_nb_bad;

  //push away the cubes in front of treatment area
  //the angle is changed to avoid pushing cubes towards recyling area
  float angle = arfast(TEAM_SIDE_VALUE(ROBOT_SIDE_BACK, ROBOT_SIDE_BALLEATER), TABLE_SIDE_MAIN);

  or = goto_pathfinding_node(PATHFINDING_GRAPH_NODE_MIDDLE_BOT, angle);
  if (or != ORDER_SUCCESS)
    return or;

  //go in position to trash the bad water
  or = goto_xya(KX(-250),250+130, arfast(ROBOT_SIDE_TURBINE,TABLE_SIDE_DOWN));
  if (or != ORDER_SUCCESS)
    return or;
  _wait_meca_ready();
  ROME_SENDWAIT_MECA_CMD(&rome_meca,ROME_ENUM_MECA_COMMAND_TRASH_TREATMENT);
  _wait_meca_ground_clear();
  update_score(10*balls_loaded);

  or = goto_xya(KX(-250), 400, arfast(ROBOT_SIDE_TURBINE, TABLE_SIDE_DOWN));

  set_speed(RS_NORMAL);
  return or;
}
开发者ID:robotter,项目名称:eurobot,代码行数:34,代码来源:strat_galipeur.inc.c

示例2: set_speed

/*void follow_wall()
{
    set_speed(0);
    while (true)
    {
        take_picture();
        bool seen_wall = false;
        for (int i = -100; i < 100; i++) { for (int j = -50; j <= 50; j++) {
            int pixel = get_pixel(IMAGE_SIZE_X / 2 + i, IMAGE_SIZE_Y / 2 + j, COLOR_WHITE);
            if (pixel >= WHITE_THRESHOLD) {
                seen_wall = true;
                goto found_wall;
            }
        }}
        found_wall:

        if (seen_wall) {
            set_speed(20);//20
            turn(75);//-80
        } else {
            set_speed(30);//30
            turn(-75);//80
        }
    }
    halt();
}
*/
void follow_wall(){
	set_speed(50);
	turn(0);
	while(true){
		frontVal = read_analog(FRONT_PIN);
		leftVal = read_analog(LEFT_PIN);
		rightVal = read_analog(RIGHT_PIN);
		while(leftVal < (rightVal+40) && leftVal > (rightVal-40)){
			set_speed(50);
		}
		while(leftVal > (rightVal+40)){
			set_speed(40);			
			turn(10);
			Sleep(0, 500);
		}
		while(leftVal < (rightVal+40)){
			set_speed(40);			
			turn(-10);
			Sleep(0, 500);
		}
		if(frontVal > 550){
			if(rightVal < 300){
				turn(1 * SHARP_TURN);
				Sleep(0, TURN_WAIT);
			}
			if(leftVal < 300){
				turn(-1 * SHARP_TURN);
				Sleep(0, TURN_WAIT);
			}
		}
	}
}
开发者ID:lovemich,项目名称:AVC_Team-Epsilon,代码行数:59,代码来源:mazefollow.cpp

示例3: get_attribute

void Material::move(Map *map)
{
    if (!m_ref_done) {
        int dx;
        if (m_from_chest) {
            dx = get_attribute("chest_speed");
        }
        else {
            dx = get_attribute("move_speed");
        }
        if (get_reference() == Right) {
            set_speed(dx, -get_attribute("rise_speed"));
        }
        else {
            set_speed(-dx, -get_attribute("rise_speed"));
        }
        set_accelration(0, get_attribute("weight"));
        m_ref_done = true;
    }

    Body::move(map);
    if (get_moving()) {
        animate_move();
    }
    else {
        m_frame = get_attribute("move_still");
    }

    if (get_fall()) {
        m_reachable = true;
    }
}
开发者ID:surdeg,项目名称:dragonscurse,代码行数:32,代码来源:material.cpp

示例4: set_lock_direction

bool Player::set_hit(Object *object)
{
    bool result = false;

    if (!m_invisible) {
        // TODO: Check if player hp is above zero instead
        result = Actor::set_hit(object);
        if (result) {

            set_lock_direction(true);

            // Move backwards and upwards
            if (m_dir == Right) {
                set_speed(-get_attribute("move_speed"),
                          -get_attribute("jump_speed"));
            }
            else {
                set_speed(get_attribute("move_speed"),
                          -get_attribute("jump_speed"));
            }

            // Make player invisible for a certain time
            set_invisible(true);
        }
    }

    return result;
}
开发者ID:johnwilson69,项目名称:dragonscurse,代码行数:28,代码来源:player.cpp

示例5: set_lock_direction

bool Monster::set_hit(Object *object)
{
    bool result = false;

    if (!m_invinsible && m_hit == HitNone) {
        result = Actor::set_hit(object);

        if (result) {

            set_lock_direction(true);

            // Move backwards and upwards
            if (get_reference() == Right) {
                set_speed(-get_attribute("move_speed"), 0);
            }
            else {
                set_speed(get_attribute("move_speed"), 0);
            }

            // Reduce hp
            // TODO: Get attackers attack power
            m_curr_hp--;
            if (m_curr_hp <= 0) {
                set_perish();
            }
        }
    }

    return result;
}
开发者ID:johnwilson69,项目名称:dragonscurse,代码行数:30,代码来源:monster.cpp

示例6: set_lock_direction

bool Monster::set_hit(Object *object, Status *status)
{
    bool result = false;

    if (!m_invinsible) {
        result = Actor::set_hit(object);
        if (result) {

            set_lock_direction(true);

            // Move backwards
            if (get_reference() == Right) {
                set_speed(-get_attribute("move_speed"), 0);
            }
            else {
                set_speed(get_attribute("move_speed"), 0);
            }

            // Reduce hp
            m_curr_hp -= status->get_ap();
            if (m_curr_hp <= 0) {
                set_perish();
            }
        }
    }

    return result;
}
开发者ID:surdeg,项目名称:dragonscurse,代码行数:28,代码来源:monster.cpp

示例7: i2c_set_bus_speed

/*
 * i2c_set_bus_speed - Set the i2c speed
 * @speed:	required i2c speed
 *
 * Set the i2c speed.
 */
void i2c_set_bus_speed(int speed)
{
	if (speed >= I2C_MAX_SPEED)
		set_speed(IC_SPEED_MODE_MAX);
	else if (speed >= I2C_FAST_SPEED)
		set_speed(IC_SPEED_MODE_FAST);
	else
		set_speed(IC_SPEED_MODE_STANDARD);
}
开发者ID:247a,项目名称:lenovo_b6000-8000_kernel_source,代码行数:15,代码来源:spr_i2c.c

示例8: set_speed

void TpFanDriver::ping_watchdog_and_depulse(const Level *level)
{
	if (depulse_ > std::chrono::milliseconds(0)) {
		FanDriver::set_speed("level disengaged");
		std::this_thread::sleep_for(depulse_);
		set_speed(level);
	}
	else if (last_watchdog_ping_ + watchdog_ + sleeptime >= std::chrono::system_clock::now())
		set_speed(level);
}
开发者ID:jpofalla,项目名称:thinkfan,代码行数:10,代码来源:drivers.cpp

示例9: demo_play_click

static int demo_play_click(int b, int d)
{
    if (d)
    {
        if (b == SDL_BUTTON_WHEELUP)   set_speed(+1);
        if (b == SDL_BUTTON_WHEELDOWN) set_speed(-1);
    }

    return 1;
}
开发者ID:NeverHack,项目名称:neverball,代码行数:10,代码来源:st_demo.c

示例10: demo_play_stick

static void demo_play_stick(int id, int a, float v, int bump)
{
    if (!bump)
        return;

    if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y0, a))
    {
        if (v < 0) set_speed(+1);
        if (v > 0) set_speed(-1);
    }
}
开发者ID:Anne017,项目名称:neverball-touch,代码行数:11,代码来源:st_demo.c

示例11: card_uart_setup

/*
 * card_uart_setup - specail setup for card reader UART
 *  @fd : card reader fd 
 *  @return : status 
 */
int card_uart_setup(int fd) 
{
#if 1
    struct termios option;

    memset(&option, 0, sizeof(option));
    option.c_cflag = B9600|CS8|CLOCAL|CREAD;
    option.c_iflag = IGNPAR;
    option.c_oflag = 0;
    option.c_lflag = 0;
    option.c_cc[VMIN] = 0;
    option.c_cc[VTIME] = 30;

    tcflush(fd, TCIFLUSH);

    if(tcsetattr(fd, TCSANOW, &option) < 0){
        return FAIL;
    }

#else
    int ret;
    set_speed(fd, 9600);
    ret = set_parity(fd, 8, 1, 'N');
    if (ret < 0)
        return FAIL;
#endif 

    return SUCCESS; 
}
开发者ID:LeonardoPhysh,项目名称:YB_IV,代码行数:34,代码来源:uart.c

示例12: get_joystick_direction

void EightDirections::update(float dt)
{
    if (max_speed == 0)
        return;

    bool on = false;
    int dir = get_joystick_direction(1);
    if (dir == 8)
        dir = instance->direction;
    else {
        on = true;
        dir *= 4;
        instance->set_direction(dir, false);
    }
    double mul = instance->frame->timer_mul;

    double change;
    if (on)
        change = get_accelerator(acceleration);
    else
        change = -get_accelerator(deceleration);

    set_speed(int_max(0, int_min(speed + change * mul, max_speed)));

    if (speed == 0)
        return;

    double add_x, add_y;
    get_dir(instance->direction, add_x, add_y);
    double m = get_pixels(speed) * mul;
    move(add_x * m, add_y * m);
    last_move = m;
}
开发者ID:tryzombie501,项目名称:anaconda,代码行数:33,代码来源:movement.cpp

示例13: xmos_dev_open

int xmos_dev_open()
{
	int fd_xmos = open_serial(SERIAL_DEV);
	if (fd_xmos == -1) {
		printf("Cannot open device\n");
        return ROKID_XMOS_ERROR_DEVICE_OPEN_FAILED;
	}
	int ret;
	ret = set_speed(fd_xmos, 115200);
	if (ret == -1) {
		printf("Set speed failed : %d\n", ret);
		return ROKID_XMOS_ERROR_INIT_FAILED;
	}
	ret = set_parity(fd_xmos, 8, 1, 0);
	if (ret == -1) {
		printf("Set parity failed : %d\n", ret);
		return ROKID_XMOS_ERROR_INIT_FAILED;
	}

	back_led_fd = open("/dev/dm163", O_RDWR | O_NONBLOCK);
	if (back_led_fd < 0) {
		perror("open dm163 error");
	}

	return fd_xmos;
}
开发者ID:terryonfly,项目名称:XMOSDev,代码行数:26,代码来源:rokid_xmos.c

示例14: main

int main(void)
{
	struct client *cl = (struct client *)malloc(sizeof(struct client));
	cl->state = initial;
	cl->inbuf = 0;
	cl->fd =  open("/dev/ttyUSB0", O_RDWR);
	if (cl->fd < 0) {
		fprintf(stderr, "Can't open the uart\n");
		exit(1);
	}

	set_speed(cl->fd, 115200);
	if (set_parity(cl->fd, 8, 1, 'N') == FALSE) {
		fprintf(stderr, "Set Parity Error\n");
		exit(0);
	}
	/* Infinite while loop -- server must be killed */
	while (1) {
		processclient(cl);
	}
	printf("-------------------\n");
	free(cl);
	close(cl->fd);
	return 1;
}
开发者ID:dreamflyforever,项目名称:easyxm,代码行数:25,代码来源:xmodemserver.c

示例15: brf_set_serial_params

static int brf_set_serial_params(struct bts_action_serial *serial_action,
						int fd, int *speed, struct termios *ti)
{
	fprintf(stderr, "texas: changing baud rate to %u, flow control to %u\n",
				serial_action->baud, serial_action->flow_control );
	tcflush(fd, TCIOFLUSH);

	if (serial_action->flow_control)
		ti->c_cflag |= CRTSCTS;
	else
		ti->c_cflag &= ~CRTSCTS;

	if (tcsetattr(fd, TCSANOW, ti) < 0) {
		perror("Can't set port settings");
		return -1;
	}

	tcflush(fd, TCIOFLUSH);

	if (set_speed(fd, ti, serial_action->baud) < 0) {
		perror("Can't set baud rate");
		return -1;
	}

	if (speed)
		*speed = serial_action->baud;

	return 0;
}
开发者ID:AlanApter,项目名称:steamlink-sdk,代码行数:29,代码来源:hciattach_ti.c


注:本文中的set_speed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。