• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ set_speed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

int main(int argc, char **argv) {
    int fd;
    int nread;
    char *ptr = argv[2];
    char *dev = argv[1]; //maybe "/dev/ttyS0";

    if (argc < 3) {
        printf("pls usage %s /dev/ttyS[n] your_message.\n", argv[1]);
        exit(EXIT_FAILURE);
    }

    if ((fd = open(dev, O_RDWR)) == -1) {
        perror("open");
        exit(EXIT_FAILURE);
    }

    set_speed(fd, 19200);

    if (set_Parity(fd, 8, 1, 'N') == FALSE) {
        printf("Set Parity Error\n");
        exit(EXIT_FAILURE);
    }

    if (write(fd, ptr, strlen(ptr)) < 0) {
        perror("write");
        exit(EXIT_FAILURE);
    }

    printf("pls check the tty data\n");
    close(fd);
    exit(EXIT_SUCCESS);
}
开发者ID:AKSahai,项目名称:Linux_Programming,代码行数:32,代码来源:read_write_serial.c


示例17: change_rshape

void dt_circle_note_on::set_beats(int beat_num){
	seq->setup(beat_num);
	data.rev_speed = (float)360.0 / (float)seq->total_steps;
	change_rshape(ofRandom(-1000, 1000));
	
	set_speed(data.speed);
}
开发者ID:hiroMTB,项目名称:dt_,代码行数:7,代码来源:dt_circle_note_on.cpp


示例18: main

 /** 
 *@breif     main() 
 */  
 int main(int argc, char **argv)  
 {  
     int fd;  
     int nread;  
     char buff[512];  
     char *dev ="/dev/ttty0";  
     fd = OpenDev(dev);  
     if (fd>0)  
     set_speed(fd,19200);  
     else  
         {  
         printf("Can't Open Serial Port!\n");  
         exit(0);  
         }  
   if (set_Parity(fd,8,1,'N')== FALSE)  
   {  
     printf("Set Parity Error\n");  
     exit(1);  
   }  
   while(1)  
     {  
         while((nread = read(fd,buff,512))>0)  
         {  
             printf("\nLen %d\n",nread);  
             buff[nread+1]='\0';  
             printf("\n%s",buff);  
         }  
     }  
     //close(fd);  
     //exit(0);  
 }  
开发者ID:174high,项目名称:ldd3-examples-3.x,代码行数:34,代码来源:test-tty.c


示例19: create_planet

void create_planet()
{
  Uint32 x, y;
  Uint32 i;
  char *image = NULL;

  /* Get random coordinates. */
  x = ( rand() % screen_width() );
  y = -( rand() % 1000) + 100;

  /* Get random image name. */
  i = ( rand() % PLANET_IMAGE_NUM ) + 1; 
  switch( i ) {
  case 1: image = get_data( MOON_1_IMAGE, DATA_IMAGES ); break;
  default: image = NULL;
  }

  /* Make the planet sprite. */
  planet = new_sprite( x, y, 1, image, 0 );
  set_speed( planet, PLANET_SPEED ); 
  if( planet == NULL ) {
    fprintf( stderr, "Error creating new sprite: %s.\n",
              SDL_GetError() );
    exit(-1);
  }
}
开发者ID:vivounicorn,项目名称:eaburns.space,代码行数:26,代码来源:planet.c


示例20: load_config

void load_config(char * path)
{
	int i;
	char *p;

	//__android_log_print(ANDROID_LOG_DEBUG, "org.rin", "path in load_config: %s",path);

	jfile fd = jfopen(env_game_thread, path, JF_MODE_READ, NULL, 0);

	if(!fd)
	{
		init_config();
		return;
	}
	
	memset(&setting, 0, sizeof(setting));
	jfread(env_game_thread, fd, &setting, sizeof(setting));
	jfclose(env_game_thread, fd);

	tmpsetting = setting;
	memcpy(m_pal16[PAL_CUSTOM_LOCAL],setting.custom_palette, sizeof(short)*4*3);
	check_config();
	set_gb_type();
	set_speed(setting.speed);
	
}
开发者ID:BelmonduS,项目名称:rin,代码行数:26,代码来源:saveload.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_state函数代码示例发布时间:2022-05-30
下一篇:
C++ set_solib_svr4_fetch_link_map_offsets函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap