Skip to content

Commit ced5d3f

Browse files
committed
fix bumper
1 parent b3eddc0 commit ced5d3f

10 files changed

+20
-17
lines changed

orcp2/keydrive.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int main(int argc, char* argv[])
143143
case ORCP2_MESSAGE_ROBOT_2WD_TELEMETRY:
144144
deserialize_robot_2wd(pkt.message.data, pkt.message.size, &robot_data);
145145
printf( "[i] Robot2WD Telemetry: bmp: %d PWM: [%d %d] US: %d IR: %d V: %d\n",
146-
robot_data.Bamper,
146+
robot_data.Bumper,
147147
robot_data.PWM[0], robot_data.PWM[1],
148148
robot_data.US[0],
149149
robot_data.IR[0],

orcp2/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int main(int argc, char* argv[])
167167
case ORCP2_MESSAGE_ROBOT_2WD_TELEMETRY:
168168
deserialize_robot_2wd(pkt.message.data, pkt.message.size, &robot_data);
169169
printf( "[i] Robot2WD Telemetry: bmp: %d PWM: [%d %d] US: %d IR: %d V: %d\n",
170-
robot_data.Bamper,
170+
robot_data.Bumper,
171171
robot_data.PWM[0], robot_data.PWM[1],
172172
robot_data.US[0],
173173
robot_data.IR[0],

orcp2/robot_2wd.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uint16_t serialize_robot_2wd(Robot_2WD* src, uint8_t* dst, uint16_t dst_size)
1313
return -1;
1414

1515
uint16_t l = 0;
16-
dst[l++] = src->Bamper;
16+
dst[l++] = src->Bumper;
1717

1818
int i;
1919
for(i=0; i<MOTORS_COUNT; i++) {
@@ -40,7 +40,7 @@ uint16_t deserialize_robot_2wd(uint8_t* src, uint16_t src_size, Robot_2WD* dst)
4040
return -1;
4141

4242
uint16_t l = 0;
43-
dst->Bamper = src[l++];
43+
dst->Bumper = src[l++];
4444

4545
int i;
4646
for(i=0; i<MOTORS_COUNT; i++) {

orcp2/robot_2wd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define BAMPER_2 2
2121

2222
typedef struct Robot_2WD {
23-
uint8_t Bamper;
23+
uint8_t Bumper;
2424
int16_t PWM [MOTORS_COUNT];
2525
uint32_t US [ULTRASONIC_COUNT];
2626
uint32_t IR [INFRARED_COUNT];

orcp2/robot_2wd_firmware.ino

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@ void motor_drive(int motor_id, int dir, int pwm)
298298
}
299299
}
300300

301-
void read_Bampers()
301+
void read_Bumpers()
302302
{
303303
#if defined(USE_BUMPER)
304-
robot_data.Bamper = 0;
304+
robot_data.Bumper = 0;
305305
for (int i=0; i<BAMPER_COUNT; i++) {
306306
bumperState[i] = digitalRead( bumperPin[i] );
307307
if(bumperState[i]) {
308-
robot_data.Bamper = robot_data.Bamper | (1 << i);
308+
robot_data.Bumper = robot_data.Bumper | (1 << i);
309309
}
310310
}
311311
#endif //#if defined(USE_BUMPER)
@@ -441,7 +441,7 @@ void loop()
441441
#if defined(DRIVE_BOARD)
442442
read_IR();
443443
read_US();
444-
read_Bampers();
444+
read_Bumpers();
445445

446446
send_telemetry();
447447
#endif //#if defined(DRIVE_BOARD)

pet/2wd_driver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ int main(int argc, char* argv[])
210210
case ORCP2_MESSAGE_ROBOT_2WD_TELEMETRY:
211211
deserialize_robot_2wd(pkt.message.data, pkt.message.size, &robot_data);
212212
printf( "[i] Robot2WD Telemetry: bmp: %d PWM: [%d %d] US: %d IR: [%d %d] V: %d\n",
213-
robot_data.Bamper,
213+
robot_data.Bumper,
214214
robot_data.PWM[0], robot_data.PWM[1],
215215
robot_data.US[0],
216216
robot_data.IR[0], robot_data.IR[1],
@@ -219,7 +219,7 @@ int main(int argc, char* argv[])
219219
// send telemetry
220220
if(client.sockfd != SOCKET_ERROR) {
221221
strncpy(cmd_telemetry_2wd.sig, "tlmtry", CMD_SIG_SIZE);
222-
cmd_telemetry_2wd.Bamper = robot_data.Bamper;
222+
cmd_telemetry_2wd.Bumper = robot_data.Bumper;
223223
cmd_telemetry_2wd.pwm[0] = robot_data.PWM[0];
224224
cmd_telemetry_2wd.pwm[1] = robot_data.PWM[1];
225225
cmd_telemetry_2wd.US = robot_data.US[0];

pet/commands.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef struct CmdAcknowledgment {
2626

2727
typedef struct CmdTelemetry2WD {
2828
char sig[CMD_SIG_SIZE]; // "tlmtry"
29-
uint8_t Bamper;
29+
uint8_t Bumper;
3030
int16_t pwm[2];
3131
uint32_t US;
3232
uint32_t IR[2];

pet/keydrive.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int main(int argc, char* argv[])
143143
case ORCP2_MESSAGE_ROBOT_2WD_TELEMETRY:
144144
deserialize_robot_2wd(pkt.message.data, pkt.message.size, &robot_data);
145145
printf( "[i] Robot2WD Telemetry: bmp: %d PWM: [%d %d] US: %d IR: [%d %d] V: %d\n",
146-
robot_data.Bamper,
146+
robot_data.Bumper,
147147
robot_data.PWM[0], robot_data.PWM[1],
148148
robot_data.US[0],
149149
robot_data.IR[0], robot_data.IR[1],

pet/pet.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ int Pet::make()
7070
if(cmd_buf_size > CMD_SIG_SIZE) {
7171
if( !strncmp(cmd_buf, "tlmtry", CMD_SIG_SIZE) && cmd_buf_size >= sizeof(cmd_telemetry_2wd) ) {
7272
memcpy(&cmd_telemetry_2wd, cmd_buf, sizeof(cmd_telemetry_2wd));
73-
printf("[i] 2WD telemetry: US: %d IR: [%d %d] PWM: [%d %d]\n", cmd_telemetry_2wd.US,
73+
printf("[i] 2WD telemetry: Bmp: %d US: %d IR: [%d %d] PWM: [%d %d]\n",
74+
cmd_telemetry_2wd.Bumper,
75+
cmd_telemetry_2wd.US,
7476
cmd_telemetry_2wd.IR[0], cmd_telemetry_2wd.IR[1],
75-
cmd_telemetry_2wd.pwm[0], cmd_telemetry_2wd.pwm[1]);
77+
cmd_telemetry_2wd.pwm[0], cmd_telemetry_2wd.pwm[1]);
7678

7779
us_measurement.add( cmd_telemetry_2wd.US );
7880
if(us_measurement.is_valid) {
@@ -188,7 +190,8 @@ int Pet::make_search_state()
188190
printf("[i][Pet][make_search_state] State: %d\n", search_state);
189191

190192
if( search_state != ST_MOVE_BACKWARD && search_state != ST_STOP ) {
191-
if( (us_measurement.is_valid && us_measurement.value < US_CLOSE_DISTANCE) ||
193+
if( cmd_telemetry_2wd.Bumper ||
194+
(us_measurement.is_valid && us_measurement.value < US_CLOSE_DISTANCE) ||
192195
(ir_measurement_left.is_valid && ir_measurement_left.value <= IR_MIN_DISTANCE) ||
193196
(ir_measurement_right.is_valid && ir_measurement_right.value <= IR_MIN_DISTANCE) ) {
194197
printf("[i][Pet][make_search_state] STOP!\n");

pet/test_2wd_telemetry.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int main(int argc, char* argv[])
167167
case ORCP2_MESSAGE_ROBOT_2WD_TELEMETRY:
168168
deserialize_robot_2wd(pkt.message.data, pkt.message.size, &robot_data);
169169
printf( "[i] Robot2WD Telemetry: bmp: %d PWM: [%d %d] US: %d IR: [%d %d] V: %d\n",
170-
robot_data.Bamper,
170+
robot_data.Bumper,
171171
robot_data.PWM[0], robot_data.PWM[1],
172172
robot_data.US[0],
173173
robot_data.IR[0], robot_data.IR[1],

0 commit comments

Comments
 (0)