Compare commits

..

3 Commits

@ -296,9 +296,23 @@ struct PACKED AddSubMsgResp {
struct Header header; struct Header header;
uint8_t retcode; uint8_t retcode;
uint8_t pub_node_id; uint8_t pub_node_id;
uint8_t ack_node_id; uint8_t ack_sub_mode;
uint8_t ack_msg_id; uint8_t ack_msg_id;
uint32_t ack_err_uid_data; uint16_t ack_err_uid_data;
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; struct Footer footer;
}; };
@ -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
@ -134,7 +136,6 @@ add_sub_msg (
union Request* req, union Request* req,
uint16_t seq, uint16_t seq,
bool ack, bool ack,
uint8_t node_id,
uint8_t msg_id, uint8_t msg_id,
uint8_t freq, uint8_t freq,
uint64_t subject_uuid ); uint64_t subject_uuid );

@ -102,12 +102,11 @@ add_sub_msg (
union Request* req, union Request* req,
uint16_t seq, uint16_t seq,
bool ack, bool ack,
uint8_t node_id,
uint8_t msg_id, uint8_t msg_id,
uint8_t freq, uint8_t freq,
uint64_t subject_uuid ) { uint64_t subject_uuid ) {
req->sub.node_id = node_id; req->sub.node_id = host2byte(CLIENT_HOST, CLIENT_INDEX);
req->sub.msg_id = msg_id; req->sub.msg_id = msg_id;
req->sub.reserved = 0; // NOTE: Always 0 req->sub.reserved = 0; // NOTE: Always 0
req->sub.sub_mode = 0; // NOTE: Always 0 req->sub.sub_mode = 0; // NOTE: Always 0

@ -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,6 +38,7 @@ struct RobotImp {
RESETTING_SUBNODE, RESETTING_SUBNODE,
SUSBCRIBING_SUBNODE, SUSBCRIBING_SUBNODE,
SETTING_MOVEMENT_MODE, SETTING_MOVEMENT_MODE,
SUBSCRIBING_POSITION_STATUS,
SENDING_HEARTBEAT, SENDING_HEARTBEAT,
WAITING, WAITING,
READY, READY,
@ -170,6 +173,14 @@ robot_work(Robot robot) {
break; break;
} }
case SUBSCRIBING_POSITION_STATUS:
{
add_sub_msg ( &req, robot->seq++, true, 20, 1, DDS_POSITION );
req_send(robot->client->dev_conn, &req);
robot->state = WAITING;
break;
}
case READY: case READY:
{ {
if(robot->dirty_wheels) { if(robot->dirty_wheels) {
@ -244,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) {
@ -279,6 +292,13 @@ robot_work(Robot robot) {
robot->state = STOPPED; robot->state = STOPPED;
break; break;
} }
robot->state = SUBSCRIBING_POSITION_STATUS;
break;
case ADD_SUB_MSG_CMD:
if(resp.resp.sub.retcode) {
robot->state = STOPPED;
break;
}
robot->state = SENDING_HEARTBEAT; robot->state = SENDING_HEARTBEAT;
break; break;
case SDK_HEARTBEAT_CMD: case SDK_HEARTBEAT_CMD:
@ -288,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