aboutsummaryrefslogtreecommitdiffstats
path: root/serial/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'serial/serial.c')
-rw-r--r--serial/serial.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/serial/serial.c b/serial/serial.c
index 61be0aa..a2f253a 100644
--- a/serial/serial.c
+++ b/serial/serial.c
@@ -95,12 +95,16 @@ void parsePath(const lcm_recv_buf_t *rbuf, const char *channel,
95 } 95 }
96 v = msg->xyr[0][0]; 96 v = msg->xyr[0][0];
97 w = msg->xyr[0][1]; 97 w = msg->xyr[0][1];
98 printf("v: %f m/s, w: %f rad/s\n", v, w);
98 if (fabs(v) <= 0.01 && fabs(w) <= 0.01) { 99 if (fabs(v) <= 0.01 && fabs(w) <= 0.01) {
99 wheelSend(0x00, 0x00, 0x00, 0x00); 100 wheelSend(0x00, 0x00, 0x00, 0x00);
100 renewCurPose(); 101 renewCurPose();
101 curSpeed = 0; 102 curSpeed = 0;
102 curOmega = 0; 103 curOmega = 0;
103 } else { 104 } else {
105 if (w <= 0.2) {
106 w *= 2;
107 }
104 vWheels[0] = (int8_t)((double)(v - w * RADIUS) / FULLSPEED * 100); 108 vWheels[0] = (int8_t)((double)(v - w * RADIUS) / FULLSPEED * 100);
105 vWheels[1] = (int8_t)((double)(v + w * RADIUS) / FULLSPEED * 100); 109 vWheels[1] = (int8_t)((double)(v + w * RADIUS) / FULLSPEED * 100);
106 bWheels[0] = vWheels[0] > 0 ? 0x01 : 0x02; 110 bWheels[0] = vWheels[0] > 0 ? 0x01 : 0x02;
@@ -110,6 +114,7 @@ void parsePath(const lcm_recv_buf_t *rbuf, const char *channel,
110 curSpeed = (int8_t)((double)v / FULLSPEED * 100); 114 curSpeed = (int8_t)((double)v / FULLSPEED * 100);
111 curOmega = (int8_t)w; 115 curOmega = (int8_t)w;
112 } 116 }
117 printf("curSpeed: %d, curOmega: %f\n", curSpeed, curOmega);
113} 118}
114 119
115void setCurPose(const lcm_recv_buf_t *rbuf, const char *channel, 120void setCurPose(const lcm_recv_buf_t *rbuf, const char *channel,
@@ -127,16 +132,11 @@ void sendCurPose() {
127 while (true) { 132 while (true) {
128 renewCurPose(); 133 renewCurPose();
129 pthread_mutex_lock(&curPoseMutex); 134 pthread_mutex_lock(&curPoseMutex);
130 // pose.pos[0] = curPose[0]; 135 pose.pos[0] = curPose[0];
131 // pose.pos[1] = curPose[1]; 136 pose.pos[1] = curPose[1];
132 // pose.pos[2] = curPose[2]; 137 pose.pos[2] = curPose[2];
133 pose.pos[0] = 0.0;
134 pose.pos[1] = 0.0;
135 pose.pos[2] = 0.0;
136 pthread_mutex_unlock(&curPoseMutex); 138 pthread_mutex_unlock(&curPoseMutex);
137 pose_t_publish(lcm, "POSE", &pose); 139 pose_t_publish(lcm, "POSE", &pose);
138 // printf("sent (%lf, %lf, %lf)\n", pose.pos[0], pose.pos[1],
139 // pose.pos[2]);
140 usleep(15 * 1000); 140 usleep(15 * 1000);
141 } 141 }
142} 142}