Add command to rotate gimbal to specific coordinates

This commit is contained in:
2024-05-09 10:33:59 -05:00
parent c0f2b11db5
commit 98f10c20c9
6 changed files with 216 additions and 0 deletions
+18
View File
@@ -18,3 +18,21 @@ gimbal_ctrl_speed (
int16_t p,
int16_t y,
int16_t r );
#define GIMBAL_ROTATE_CMD 0xb03f
void
gimbal_rotate (
union Request* req,
uint16_t seq,
bool ack,
int16_t p,
int16_t y );
void
gimbal_rotate_to (
union Request* req,
uint16_t seq,
bool ack,
int16_t p,
int16_t y );
#define GIMBAL_ACTION_PUSH_CMD 0xb13f
+70
View File
@@ -185,6 +185,73 @@ struct PACKED GimbalCtrlSpeedReq
struct Footer footer;
};
struct PACKED GimbalActionPush {
struct Header header;
uint8_t id;
uint8_t progress;
uint8_t state;
int16_t yaw;
int16_t roll;
int16_t pitch;
};
struct PACKED GimbalRotateReq {
struct Header header;
uint8_t id;
//union {
uint8_t control_bitfield;
// struct {
// // always 0 for start
// uint8_t control : 1;
// uint8_t frequency : 2;
// };
//};
//union {
uint8_t coord_bitfield;
// struct {
// uint8_t coordinate : 3;
// // always true
// uint8_t pitch_valid : 1;
// // always false
// uint8_t roll_valid : 1;
// // always true
// uint8_t yaw_valid : 1;
// };
//};
union {
int16_t yaw;
struct {
int8_t l_yaw;
int8_t h_yaw;
};
};
int16_t roll;
union {
int16_t pitch;
struct {
int8_t l_pitch;
int8_t h_pitch;
};
};
uint16_t error;
uint16_t yaw_speed;
uint16_t roll_speed;
uint16_t pitch_speed;
struct Footer footer;
};
struct PACKED GimbalRotateResp {
struct Header header;
uint8_t retcode;
uint8_t accept;
struct Footer footer;
};
struct PACKED GimbalCtrlSpeedResp
{
struct Header header;
@@ -339,6 +406,7 @@ union Request {
struct SubNodeResetReq subnodereset;
struct SubscribeAddNodeReq subnodeadd;
struct GimbalCtrlSpeedReq gimbspeed;
struct GimbalRotateReq gimbalrot;
struct BlasterFireReq blaster;
struct StreamCtrlReq stream;
struct AddSubMsgReq sub;
@@ -356,10 +424,12 @@ union Response {
struct SubNodeResetResp subnodereset;
struct SubscribeAddNodeResp subnodeadd;
struct GimbalCtrlSpeedResp gimbspeed;
struct GimbalRotateResp gimbalrot;
struct BlasterFireResp blaster;
struct StreamCtrlResp stream;
struct AddSubMsgResp sub;
struct PushPeriodMsg push;
struct GimbalActionPush gimbalaction;
};
union Message {
struct Header header;
+3
View File
@@ -42,6 +42,9 @@ int robot_stop(Robot robot);
*/
int robot_aim(Robot, float p, float y);
int robot_target(Robot robot, float pitch, float yaw);
int robot_target_to(Robot robot, float pitch, float yaw);
/*
* Set the velocity of the robot chassis. A packet will be sent to the robot on
* the next ready tick of the work function.