资源简介
e-puck_avoid_obstacles.zip
代码片段和文件信息
/*
* Description: Default controller of the e-puck robot
*/
/* include headers */
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* Device stuff */
#define DISTANCE_SENSORS_NUMBER 8
static WbDeviceTag distance_sensors[DISTANCE_SENSORS_NUMBER];
static double distance_sensors_values[DISTANCE_SENSORS_NUMBER];
static const char *distance_sensors_names[DISTANCE_SENSORS_NUMBER] = {
“ps0“ “ps1“ “ps2“ “ps3“
“ps4“ “ps5“ “ps6“ “ps7“
};
#define GROUND_SENSORS_NUMBER 3
static WbDeviceTag ground_sensors[GROUND_SENSORS_NUMBER];
static double ground_sensors_values[GROUND_SENSORS_NUMBER] = { 0.0 0.0 0.0 };
static const char *ground_sensors_names[GROUND_SENSORS_NUMBER] = {
“gs0“ “gs1“ “gs2“
};
#define LEDS_NUMBER 10
static WbDeviceTag leds[LEDS_NUMBER];
static bool leds_values[LEDS_NUMBER];
static const char *leds_names[LEDS_NUMBER] = {
“led0“ “led1“ “led2“ “led3“
“led4“ “led5“ “led6“ “led7“
“led8“ “led9“
};
static WbDeviceTag left_motor right_motor;
#define LEFT 0
#define RIGHT 1
#define MAX_SPEED 6.28
static double speeds[2];
/* Breitenberg stuff */
static double weights[DISTANCE_SENSORS_NUMBER][2] = {
{-1.3 -1.0}
{-1.3 -1.0}
{-0.5 0.5}
{0.0 0.0}
{0.0 0.0}
{0.05 -0.5}
{-0.75 0}
{-0.75 0}
};
static double offsets[2] = {
0.5*MAX_SPEED 0.5*MAX_SPEED
};
static int get_time_step() {
static int time_step = -1;
if (time_step == -1)
time_step = (int) wb_robot_get_basic_time_step();
return time_step;
}
static void step() {
if (wb_robot_step(get_time_step()) == -1) {
wb_robot_cleanup();
exit(EXIT_SUCCESS);
}
}
static void passive_wait(double sec) {
double start_time = wb_robot_get_time();
do {
step();
} while(start_time + sec > wb_robot_get_time());
}
static void init_devices() {
int i;
for (i=0; i distance_sensors[i]=wb_robot_get_device(distance_sensors_names[i]);
wb_distance_sensor_enable(distance_sensors[i] get_time_step());
}
for (i=0; i leds[i]=wb_robot_get_device(leds_names[i]);
// silently initialize the ground sensors if they exists
for (i=0; i ground_sensors[i] = (WbDeviceTag) 0;
int ndevices = wb_robot_get_number_of_devices();
for (i=0; i WbDeviceTag dtag = wb_robot_get_device_by_index(i);
const char *dname = wb_device_get_name(dtag);
WbNodeType dtype = wb_device_get_node_type(dtag);
if (dtype == WB_NODE_DISTANCE_SENSOR && strlen(dname) == 3 && dname[0] == ‘g‘ && dname[1] == ‘s‘) {
int id = dname[2] - ‘0‘;
if (id >=0 && id < GROUND_SENSORS_NUMBER) {
ground_sensors[id] = wb_robot_get_device(ground_sensors_names[id]);
wb_distance_sensor_enable(ground_sensors[id] get_time_step());
}
}
}
// get
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5700 2018-03-02 13:36 e-puck_avoid_obstacles.c
- 上一篇:数据挖据课程设计
- 下一篇:MIPS CPU设计、理想指令流水线设计
相关资源
- 2018全国各个城市一二三四线等级划分
- 中国省市区数据.xlsx
- 液晶温度计.zip
- 乘用车CAN总线物理层技术要求.pdf
- informatica9.5.1.txt
- teamcenter11.txt
- 996e1ab2a4ee5a44f0d43a127d4303ff.rar
- 数字图像处理.txt
-
weixin_42809254_10923344.xm
l - 格斗游戏.rar
- Matrixs.zip
- weixin_42597664_10518293.zip
- 317870火车头ecshop免登陆发布模块.zip
- RVDS安装包.txt
- 三级数据库大题知识.doc
- 菜鸟学习路线.txt
- MapInspect.exe
- vivado2018.txt
- RADStudioKeyPatch_Lite.rar
- 时空阁CC测试工具Ver1.0.exe
- 549090建设工程监理规范GBT50319-2013.pd
- 地址及解压密码.txt
- 尚硅谷电商项目.txt
- 第三章习题参考答案.rar
- f77f02f73edbf8cac9e0614d220a5407.docx
- CornerNet结构.pdf
- 体育水位计算0.rar
- CST2017.txt
- 百度盘分享地址.txt
- 小D课堂-亿级流量系列之jmeter4.x分布式
评论
共有 条评论