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 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 {
struct Header header;
struct SetSdkConnectionReq sdkconn;
@ -335,6 +349,7 @@ union Response {
struct BlasterFireResp blaster;
struct StreamCtrlResp stream;
struct AddSubMsgResp sub;
struct PushPeriodMsg push;
};
union Message {
struct Header header;

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

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

Loading…
Cancel
Save