53 char buf[MAX_BUF_LEN+1];
56 double GpsOrin[3]={0};
59 int SelfCheckMainState=0;
60 int SelfCheckSubState=0;
68 uint64_t m_start_time = 0;
73 m_cmd.ioSilInts[0] = 5;
82 int recvlen=udp.RecvNoblock(buf,RecvIP,RecvPort,MAX_BUF_LEN);
85 if (udp.needFilter && (RecvIP != TargetIP)){
94 onUdpMessage((uint8_t*)buf, recvlen);
102 void onUdpMessage(uint8_t *buf,
int recvlen){
104 unpackStruct(buf, m_recv);
109 unsigned int length = packStruct(m_cmd, (uint8_t*)buf);
112 udp.SendTo((
const char *)buf,length,TargetIP,TargetPort);
117 void setBit(
int &num,
int n) {
125 void SendSetAction(
int mode)
127 m_cmd.ioSilInts[1] = 0;
128 setBit(m_cmd.ioSilInts[1], 0);
129 setBit(m_cmd.ioSilInts[1], 5);
130 m_cmd.ioSilInts[2] = mode;
134 void SendMove(
float vx,
float vy,
float yaw_rate)
136 m_cmd.ioSilInts[1] = 0;
137 setBit(m_cmd.ioSilInts[1], 0);
138 setBit(m_cmd.ioSilInts[1], 19);
139 m_cmd.ioSilFloats[3] = vx;
140 m_cmd.ioSilFloats[4] = vy;
141 m_cmd.ioSilFloats[14] = yaw_rate;
145 bool isBitTrue(uint32_t value,
int bitIndex) {
146 return (value & (1U << bitIndex)) != 0;
150 void SendMavlinkReal(
double **u,
double t){
152 int cmdBitmap = (int)*u[1];
153 int typeMask = (int)*u[2];
155 if (isBitTrue(cmdBitmap, 0)){
156 if (isBitTrue(cmdBitmap, 5)){
158 SendSetAction(typeMask);
161 if (isBitTrue(cmdBitmap, 19)){
163 SendMove((
float)*u[11], (
float)*u[12], (
float)*u[22]);