65 if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
66 PLAYER_POSITION2D_CMD_VEL,
70 player_position2d_cmd_vel_t* pcmd = (player_position2d_cmd_vel_t*)data;
75 mod->
SetSpeed( pcmd->vel.px, pcmd->vel.py, pcmd->vel.pa );
81 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
82 PLAYER_POSITION2D_CMD_POS,
86 player_position2d_cmd_pos_t* pcmd = (player_position2d_cmd_pos_t*)data;
88 mod->
GoTo( pcmd->pos.px, pcmd->pos.py, pcmd->pos.pa );
93 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
94 PLAYER_POSITION2D_CMD_CAR,
98 player_position2d_cmd_car_t* pcmd = (player_position2d_cmd_car_t*)data;
100 mod->
SetSpeed( pcmd->velocity, 0, pcmd->angle );
105 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
106 PLAYER_POSITION2D_REQ_GET_GEOM,
114 player_position2d_geom_t pgeom;
116 pgeom.pose.py = geom.
pose.
y;
117 pgeom.pose.pyaw = geom.
pose.
a;
119 pgeom.size.sl = geom.
size.
x;
120 pgeom.size.sw = geom.
size.
y;
122 this->
driver->Publish( this->
addr, resp_queue,
123 PLAYER_MSGTYPE_RESP_ACK,
124 PLAYER_POSITION2D_REQ_GET_GEOM,
125 (
void*)&pgeom,
sizeof(pgeom), NULL );
130 PRINT_ERR2(
"config request len is invalid (%d != %d)",
136 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
137 PLAYER_POSITION2D_REQ_RESET_ODOM,
149 this->
driver->Publish( this->
addr, resp_queue,
150 PLAYER_MSGTYPE_RESP_ACK,
151 PLAYER_POSITION2D_REQ_RESET_ODOM );
156 PRINT_ERR2(
"config request len is invalid (%d != %d)",
162 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
163 PLAYER_POSITION2D_REQ_SET_ODOM,
166 if(hdr->size ==
sizeof(player_position2d_set_odom_req_t))
168 player_position2d_set_odom_req_t* req =
169 (player_position2d_set_odom_req_t*)data;
182 this->
driver->Publish( this->
addr, resp_queue,
183 PLAYER_MSGTYPE_RESP_ACK,
184 PLAYER_POSITION2D_REQ_SET_ODOM );
189 PRINT_ERR2(
"config request len is invalid (%d != %d)",
190 (
int)hdr->size, (
int)
sizeof(player_position2d_set_odom_req_t));
195 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
196 PLAYER_POSITION2D_REQ_MOTOR_POWER,
199 if(hdr->size ==
sizeof(player_position2d_power_config_t))
201 player_position2d_power_config_t* req =
202 (player_position2d_power_config_t*)data;
204 int motors_on = req->state;
206 PRINT_WARN1(
"Stage ignores motor power state (%d)",
208 this->
driver->Publish( this->
addr, resp_queue,
209 PLAYER_MSGTYPE_RESP_ACK,
210 PLAYER_POSITION2D_REQ_MOTOR_POWER );
215 PRINT_ERR2(
"config request len is invalid (%d != %d)",
216 (
int)hdr->size, (
int)
sizeof(player_position2d_power_config_t));
221 else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
222 PLAYER_POSITION2D_REQ_POSITION_MODE,
225 if(hdr->size ==
sizeof(player_position2d_position_mode_req_t))
234 PRINT_WARN2(
"Put model %s into %s control mode", this->mod->
Token(), mod ?
"POSITION" :
"VELOCITY" );
235 PRINT_WARN(
"set control mode not yet implemented") ;
237 this->
driver->Publish( this->
addr, resp_queue,
238 PLAYER_MSGTYPE_RESP_ACK,
239 PLAYER_POSITION2D_REQ_POSITION_MODE );
244 PRINT_ERR2(
"config request len is invalid (%d != %d)",
246 (
int)
sizeof(player_position2d_position_mode_req_t));
254 PRINT_WARN2(
"position doesn't support msg with type %d subtype %d",
255 hdr->type, hdr->subtype);
268 player_position2d_data_t ppd;
269 bzero( &ppd,
sizeof(ppd) );
285 ppd.stall = this->mod->
Stalled();
289 PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE,
290 (
void*)&ppd,
sizeof(ppd), NULL);
void GoTo(double x, double y, double a)
The Stage library uses its own namespace.
void SetSpeed(double x, double y, double a)
#define PRINT_WARN2(m, a, b)
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr_t *hdr, void *data)
meters_t z
location in 3 axes
#define PRINT_DEBUG3(m, a, b, c)
Pose est_pose
position estimate in local coordinates
virtual void Publish(void)
Velocity GetVelocity() const
InterfacePosition(player_devaddr_t addr, StgDriver *driver, ConfigFile *cf, int section)
#define PRINT_ERR2(m, a, b)
radians_t a
rotation about the z axis.
#define PRINT_WARN1(m, a)
const char * Token() const