z1_sdk/include/unitree_arm_sdk/message/arm_common.h

117 lines
2.0 KiB
C
Raw Normal View History

2022-07-20 11:20:01 +08:00
#ifndef _UNITREE_ARM_ARM_COMMON_H_
#define _UNITREE_ARM_ARM_COMMON_H_
#include <stdint.h>
#pragma pack(1)
2022-11-16 16:23:36 +08:00
namespace UNITREE_ARM {
2022-07-20 11:20:01 +08:00
// 4 Byte
enum class ArmFSMState{
INVALID,
PASSIVE,
JOINTCTRL,
CARTESIAN,
MOVEJ,
MOVEL,
MOVEC,
TRAJECTORY,
TOSTATE,
SAVESTATE,
TEACH,
TEACHREPEAT,
CALIBRATION,
2022-09-13 19:52:44 +08:00
SETTRAJ,
2022-07-20 11:20:01 +08:00
BACKTOSTART,
NEXT,
LOWCMD
};
2022-09-13 19:52:44 +08:00
enum class TrajType{
MoveJ,
MoveL,
MoveC,
Stop
};
2022-07-20 11:20:01 +08:00
// 20 Byte
struct JointCmd{
float T;
float W;
float Pos;
float K_P;
float K_W;
};
2022-11-11 18:17:07 +08:00
typedef struct{
uint8_t reserved : 6 ;
uint8_t state : 2 ;//whether motor is connected; 0-ok, 1-disconnected, 2-CRC error
}Motor_Connected;
typedef struct{
int8_t temperature;
/* 0x01: phase current is too large
* 0x02: phase leakage
* 0x04: overheat(including the motor windings and the motor shell)
* 0x20: jumped
* 0x40: nothing
*/
uint8_t error;
Motor_Connected isConnected;
}Motor_State;
2022-07-20 11:20:01 +08:00
struct JointState{
float T;
float W;
float Acc;
float Pos;
2022-11-11 18:17:07 +08:00
Motor_State state[2];
2022-07-20 11:20:01 +08:00
};
struct Posture{
2023-01-28 16:02:16 +08:00
double rx;
double ry;
double rz;
2022-09-13 19:52:44 +08:00
double x;
double y;
double z;
2022-07-20 11:20:01 +08:00
};
2022-09-13 19:52:44 +08:00
struct TrajCmd{
TrajType trajType;
Posture posture[2];
double gripperPos;
double maxSpeed;
double stopTime;
2023-01-28 16:02:16 +08:00
int trajOrder;
2022-07-20 11:20:01 +08:00
};
union ValueUnion{
2022-09-13 19:52:44 +08:00
char name[10];
2022-07-20 11:20:01 +08:00
JointCmd jointCmd[7];
2022-09-13 19:52:44 +08:00
TrajCmd trajCmd;
2022-07-20 11:20:01 +08:00
};
struct SendCmd{
uint8_t head[2];
ArmFSMState state;
bool track;// whether let arm track jointCmd in State_JOINTCTRL or posture[0] in State_CARTESIAN
2022-07-20 11:20:01 +08:00
ValueUnion valueUnion;
};
2022-11-11 18:17:07 +08:00
2022-07-20 11:20:01 +08:00
struct RecvState{
uint8_t head[2];
ArmFSMState state;
JointState jointState[7];
Posture cartesianState;
};
2022-11-11 18:17:07 +08:00
constexpr int SENDCMD_LENGTH = (sizeof(SendCmd));
constexpr int RECVSTATE_LENGTH = (sizeof(RecvState));
constexpr int JointCmd_LENGTH = (sizeof(JointCmd));
constexpr int JointState_LENGTH = (sizeof(JointState));
2022-07-20 11:20:01 +08:00
#pragma pack()
2022-11-16 16:23:36 +08:00
}
2022-07-20 11:20:01 +08:00
#endif // _UNITREE_ARM_ARM_MSG_H_