125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
char
check_data_byte(
char
byte)
{
if
(is_data(byte))
return
0;
play(
"o3c"
);
clear();
print(
"Bad data"
);
lcd_goto_xy(0,1);
print_hex_byte(byte);
previous_byte();
return
1;
}
/////////////////////////////////////////////////////////////////////
// COMMAND FUNCTIONS
//
// Each function in this section corresponds to a single serial
// command.
The functions are expected to do their own argument
// handling using read_next_byte() and check_data_byte().
// Sends the version of the slave code that is running.
// This function also shuts down the motors and disables PID, so it is
// useful as an initial command.
void
send_signature()
{
serial_send_blocking(
"3pi1.0"
, 6);
set_motors(0,0);
pid_enabled = 0;
}
// Reads the line sensors and sends their values.
This function can
// do either calibrated or uncalibrated readings.
When doing calibrated readings,
// it only performs a new reading if we are not in PID mode.
Otherwise, it sends
// the most recent result immediately.
void
send_sensor_values(
char
calibrated)
{
if
(calibrated)
{
if
(!pid_enabled)
read_line_sensors_calibrated(sensors, IR_EMITTERS_ON);
}
else
read_line_sensors(sensors, IR_EMITTERS_ON);
serial_send_blocking((
char
*)sensors, 10);
}
// Sends the raw (uncalibrated) sensor values.
void
send_raw_sensor_values()
{
send_sensor_values(0);
}
// Sends the calibated sensor values.
void
send_calibrated_sensor_values()
{
send_sensor_values(1);
}
// Computes the position of a black line using the read_line()
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
10. Expansion Information
Page 70 of 85
Содержание 0J5840
Страница 24: ...Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 5 How Your 3pi Works Page 24 of 85...
Страница 67: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 67 of 85...
Страница 77: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 77 of 85...