Add robot position push topic

master
PgSocks 7 months ago
parent 19861ca234
commit 23a07f99d9

@ -302,6 +302,20 @@ struct PACKED AddSubMsgResp {
struct Footer footer; struct Footer footer;
}; };
struct PACKED PushPeriodMsg {
struct Header header;
uint8_t sub_mode;
uint8_t msg_id;
union {
struct {
float x;
float y;
float z;
} position;
};
struct Footer footer;
};
union Request { union Request {
struct Header header; struct Header header;
struct SetSdkConnectionReq sdkconn; struct SetSdkConnectionReq sdkconn;
@ -335,6 +349,7 @@ union Response {
struct BlasterFireResp blaster; struct BlasterFireResp blaster;
struct StreamCtrlResp stream; struct StreamCtrlResp stream;
struct AddSubMsgResp sub; struct AddSubMsgResp sub;
struct PushPeriodMsg push;
}; };
union Message { union Message {
struct Header header; struct Header header;

@ -110,6 +110,8 @@ subscribe_add_node (
#define ADD_SUB_MSG_CMD 0x0348 #define ADD_SUB_MSG_CMD 0x0348
#define PUSH_PERIOD_MSG_CMD 0x0848
#define DDS_BATTERY 0x000200096862229f #define DDS_BATTERY 0x000200096862229f
#define DDS_GIMBAL_BASE 0x00020009f5882874 #define DDS_GIMBAL_BASE 0x00020009f5882874
#define DDS_VELOCITY 0x0002000949a4009c #define DDS_VELOCITY 0x0002000949a4009c

@ -28,6 +28,8 @@ struct RobotImp {
bool sdk_mode; bool sdk_mode;
float x, y, z;
enum { enum {
CONNECTING_TO_PROXY_PORT, CONNECTING_TO_PROXY_PORT,
SETTING_SDK_CONNECTION, SETTING_SDK_CONNECTION,
@ -36,7 +38,7 @@ struct RobotImp {
RESETTING_SUBNODE, RESETTING_SUBNODE,
SUSBCRIBING_SUBNODE, SUSBCRIBING_SUBNODE,
SETTING_MOVEMENT_MODE, SETTING_MOVEMENT_MODE,
SUBSCRIBING_GIMBAL_STATUS, SUBSCRIBING_POSITION_STATUS,
SENDING_HEARTBEAT, SENDING_HEARTBEAT,
WAITING, WAITING,
READY, READY,
@ -171,10 +173,10 @@ robot_work(Robot robot) {
break; break;
} }
case SUBSCRIBING_GIMBAL_STATUS: case SUBSCRIBING_POSITION_STATUS:
{ {
add_sub_msg ( &req, robot->seq++, true, 21, 1, DDS_GIMBAL_BASE ); add_sub_msg ( &req, robot->seq++, true, 20, 1, DDS_POSITION );
req_send(robot->client->sdk_conn, &req); req_send(robot->client->dev_conn, &req);
robot->state = WAITING; robot->state = WAITING;
break; break;
} }
@ -253,6 +255,8 @@ robot_work(Robot robot) {
switch(resp.header.cmd) { switch(resp.header.cmd) {
case 0: case 0:
break; break;
default:
break;
case SET_SDK_CONNECTION_CMD: case SET_SDK_CONNECTION_CMD:
// TODO: Do more with this // TODO: Do more with this
if(resp.resp.sdkconn.retcode) { if(resp.resp.sdkconn.retcode) {
@ -288,17 +292,13 @@ robot_work(Robot robot) {
robot->state = STOPPED; robot->state = STOPPED;
break; break;
} }
robot->state = SUBSCRIBING_GIMBAL_STATUS; robot->state = SUBSCRIBING_POSITION_STATUS;
break; break;
case ADD_SUB_MSG_CMD: case ADD_SUB_MSG_CMD:
if(resp.resp.sub.retcode) { if(resp.resp.sub.retcode) {
robot->state = STOPPED; robot->state = STOPPED;
break; break;
} }
if(resp.resp.sub.ack_node_id != host2byte(CLIENT_HOST, CLIENT_INDEX)) {
robot->state = STOPPED;
break;
}
robot->state = SENDING_HEARTBEAT; robot->state = SENDING_HEARTBEAT;
break; break;
case SDK_HEARTBEAT_CMD: case SDK_HEARTBEAT_CMD:
@ -308,6 +308,12 @@ robot_work(Robot robot) {
} }
robot->state = READY; robot->state = READY;
break; break;
case PUSH_PERIOD_MSG_CMD:
// assume it is a position status for now
robot->x = resp.resp.push.position.x;
robot->y = resp.resp.push.position.y;
robot->z = resp.resp.push.position.z;
break;
} }
return 1; return 1;

Loading…
Cancel
Save