Add robot gimbal position push topic

master
PgSocks 6 months ago
parent 23a07f99d9
commit 11c3ac43fb

@ -312,6 +312,16 @@ struct PACKED PushPeriodMsg {
float y; float y;
float z; float z;
} position; } position;
struct {
uint16_t yaw_ground;
uint16_t pitch_ground;
uint16_t yaw;
uint16_t pitch;
struct {
uint8_t option_mode : 2;
uint8_t return_center : 1;
};
} gimbal;
}; };
struct Footer footer; struct Footer footer;
}; };

@ -30,6 +30,11 @@ struct RobotImp {
float x, y, z; float x, y, z;
uint16_t yaw_ground;
uint16_t pitch_ground;
uint16_t yaw;
uint16_t pitch;
enum { enum {
CONNECTING_TO_PROXY_PORT, CONNECTING_TO_PROXY_PORT,
SETTING_SDK_CONNECTION, SETTING_SDK_CONNECTION,
@ -39,6 +44,7 @@ struct RobotImp {
SUSBCRIBING_SUBNODE, SUSBCRIBING_SUBNODE,
SETTING_MOVEMENT_MODE, SETTING_MOVEMENT_MODE,
SUBSCRIBING_POSITION_STATUS, SUBSCRIBING_POSITION_STATUS,
SUBSCRIBING_GIMBAL_STATUS,
SENDING_HEARTBEAT, SENDING_HEARTBEAT,
WAITING, WAITING,
READY, READY,
@ -177,6 +183,14 @@ robot_work(Robot robot) {
{ {
add_sub_msg ( &req, robot->seq++, true, 20, 1, DDS_POSITION ); add_sub_msg ( &req, robot->seq++, true, 20, 1, DDS_POSITION );
req_send(robot->client->dev_conn, &req); req_send(robot->client->dev_conn, &req);
robot->state = SUBSCRIBING_GIMBAL_STATUS;
break;
}
case SUBSCRIBING_GIMBAL_STATUS:
{
add_sub_msg ( &req, robot->seq++, true, 21, 1, DDS_GIMBAL_POS );
req_send(robot->client->dev_conn, &req);
robot->state = WAITING; robot->state = WAITING;
break; break;
} }
@ -309,10 +323,18 @@ robot_work(Robot robot) {
robot->state = READY; robot->state = READY;
break; break;
case PUSH_PERIOD_MSG_CMD: case PUSH_PERIOD_MSG_CMD:
// assume it is a position status for now switch(resp.resp.push.msg_id) {
robot->x = resp.resp.push.position.x; case 20:
robot->y = resp.resp.push.position.y; robot->x = resp.resp.push.position.x;
robot->z = resp.resp.push.position.z; robot->y = resp.resp.push.position.y;
robot->z = resp.resp.push.position.z;
break;
case 21:
robot->yaw_ground = resp.resp.push.gimbal.yaw_ground;
robot->pitch_ground = resp.resp.push.gimbal.pitch_ground;
robot->yaw = resp.resp.push.gimbal.yaw;
robot->pitch = resp.resp.push.gimbal.pitch;
}
break; break;
} }

Loading…
Cancel
Save