diff options
author | 2024-06-24 22:10:01 +0800 | |
---|---|---|
committer | 2024-06-24 22:10:01 +0800 | |
commit | 6c06f515f18f5913a027ba2c84092c4861e8cf45 (patch) | |
tree | 56ecdd968a78ba7dcc641efd9f8d119d5288793b /udp2lcm | |
parent | 692b77cc3b1bb030ed83416d76b561d11a57d1e0 (diff) | |
download | WheelCtrl-6c06f515f18f5913a027ba2c84092c4861e8cf45.tar.gz WheelCtrl-6c06f515f18f5913a027ba2c84092c4861e8cf45.zip |
Update sth && add "cancel target"
- set sita as rad
- fix the change between little to big end
- sth else
Diffstat (limited to 'udp2lcm')
-rw-r--r-- | udp2lcm/udp2lcm.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/udp2lcm/udp2lcm.c b/udp2lcm/udp2lcm.c index 9ac380f..36100da 100644 --- a/udp2lcm/udp2lcm.c +++ b/udp2lcm/udp2lcm.c | |||
@@ -116,14 +116,22 @@ void parseCmd(const char *buffer, int bytesReceived) { | |||
116 | x = swapEndian(*(int16_t *)&buffer[3]); | 116 | x = swapEndian(*(int16_t *)&buffer[3]); |
117 | y = swapEndian(*(int16_t *)&buffer[5]); | 117 | y = swapEndian(*(int16_t *)&buffer[5]); |
118 | sita = 0; | 118 | sita = 0; |
119 | // printf("End point: x: %d, y: %d, sita: %d\n", x, y, sita); | ||
120 | // printf("Original buffer: ", buffer); | ||
121 | robotCtrlInit(&robotCtrlData, 0, 20, 0, 3, 0, 0, 0); | 119 | robotCtrlInit(&robotCtrlData, 0, 20, 0, 3, 0, 0, 0); |
122 | robotCtrlData.dparams[0] = (double)x / 20; | 120 | robotCtrlData.dparams[0] = (double)x / 20; |
123 | robotCtrlData.dparams[1] = (double)y / 20; | 121 | robotCtrlData.dparams[1] = (double)y / 20; |
124 | robotCtrlData.dparams[2] = sita; | 122 | robotCtrlData.dparams[2] = sita; |
125 | robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData); | 123 | robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData); |
126 | freeRobotCtrl(&robotCtrlData); | 124 | freeRobotCtrl(&robotCtrlData); |
125 | } else if (buffer[0] == 4) { | ||
126 | // 取消导航,删除上一个目标点 | ||
127 | robotCtrlInit(&robotCtrlData, 0, 23, 0, 0, 0, 0, 0); | ||
128 | robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData); | ||
129 | } else { | ||
130 | fprintf(stderr, "Error: Invalid command: "); | ||
131 | for (int i = 0; i < 9; i++) { | ||
132 | fprintf(stderr, "%02hhx ", buffer[i]); | ||
133 | } | ||
134 | fprintf(stderr, "\n"); | ||
127 | } | 135 | } |
128 | } | 136 | } |
129 | 137 | ||
@@ -147,7 +155,6 @@ void poseHandler(const lcm_recv_buf_t *rbuf, const char *channel, | |||
147 | heartBeat[7] = sita >> 8; | 155 | heartBeat[7] = sita >> 8; |
148 | heartBeat[8] = sita; | 156 | heartBeat[8] = sita; |
149 | pthread_mutex_unlock(&heartBeatMutex); | 157 | pthread_mutex_unlock(&heartBeatMutex); |
150 | printf("curpose: x: %d, y: %d, sita: %d\n", x, y, sita); | ||
151 | } | 158 | } |
152 | 159 | ||
153 | int16_t swapEndian(int16_t val) { return (val << 8) | ((val >> 8) & 0xFF); } \ No newline at end of file | 160 | int16_t swapEndian(int16_t val) { return (val << 8) | ((val >> 8) & 0xFF); } \ No newline at end of file |