Robobot calibration

From Rsewiki

Back to Robobot


Sending commands to the Teensy board using MQTT

Line sensor

The line sensor blinks the LED illumination and subtracts the non-illuminated from the illuminated.

These (raw) values are then normalized relative to a calibrated expected white value.

The normalized value is between 0 (black - no reflection) and 1000 (calibrated white reflection).

Start calibration

Place the sensor at the expected distance over a white surface with the expected reflectance (i.e. white tape).

Send the command, e.g.:

licw 100

where 100 means average over 100 samples.

Once finished, save the values in the Teensy flash by:

eew

Get normalized data

Subscribe to data from the Teensy by the command

sub livn 7

where 7 means update every 7 ms. This could be as low as 1, but the traffic load may give communication bottlenecks resulting in delay or lost messages. The communication limit is approximately 4000 messages per second (each below 64 characters).

Distance sensor calibration

The distance sensor needs calibration.

The sensor is calibrated with two sensor values, 13 cm and 50 cm.

The datasheet states that the analogue voltage out of the sensor is something like:

It can be seen that distances below 5cm can give the same voltage as most other distances.

The easiest way is to have console access directly to the Teensy. Connect to the robot using, e.g., Putty to get two command lines on the Robot's Raspberry. Or a serial console if the Teensy is connected directly to a PC.

Sensor values 13 cm

Subscribe to sensor data and calibration values every 300ms:

Send this message to the Teensy

sub ir 300

Using MQTT this is:

topic: robobot/cmd/T0/sub
message: it 300

Watch the message (either using using cat or MQTT)

cat /dev/ttyACM0

Using MQTT, subscribe to

topic: robobot/drive/T0/ir

Should get this

ir 0.124 0.137 15698 14219 15000 4600 15000 4100 1
ir 0.124 0.137 15660 14220 15000 4600 15000 4100 1
ir 0.124 0.137 15666 14207 15000 4600 15000 4100 1
ir 0.124 0.137 15698 14219 15000 4600 15000 4100 1
ir 0.124 0.137 15652 14214 15000 4600 15000 4100 1

Obstacles are here at 13 cm for both sensors. The first two values show the distance, and they are here close to 13 cm. The raw (filtered) values are approximately 15660 and 14210, respectively. This is relatively close to the already calibrated values of 15000.

The last value 1 shows that the sensor is on, if not; then send the on command:

iron 1

Sensor values 50 cm

The 50cm values could be

ir 0.496 0.426 4633 4761 15000 4600 15000 4100 1
ir 0.500 0.426 4600 4770 15000 4600 15000 4100 1
ir 0.496 0.426 4628 4764 15000 4600 15000 4100 1
ir 0.494 0.426 4641 4762 15000 4600 15000 4100 1
ir 0.498 0.426 4616 4761 15000 4600 15000 4100 1
ir 0.496 0.427 4627 4759 15000 4600 15000 4100 1
ir 0.481 0.427 4741 4756 15000 4600 15000 4100 1

The value seems fine for sensor 1 (default side-mounted); it is a bit off for the other sensor.

Implement calibration

To implement the new calibration values use (in this case).

  • Help text is: irc A1 B1 A2 B2 V Set calibration values A=13cm value, B=50cm (sensor 1 and 2) V=1 in on.
irc 15660 4600 14210 4760 1
eew

The last value is to leave the sensor on. The eew command saves the values to the configuration flash.

The values at 50cm now looks like:

ir 0.501 0.501 4590 4756 15660 4600 14210 4760 1
ir 0.491 0.498 4669 4770 15660 4600 14210 4760 1
ir 0.498 0.501 4619 4754 15660 4600 14210 4760 1
ir 0.499 0.499 4610 4765 15660 4600 14210 4760 1
ir 0.493 0.501 4654 4755 15660 4600 14210 4760 1

After this calibration, the actual values should be within 3-5 cm in the range between 10cm and 50cm.

Reflections

If the sensor looks into a reflecting surface, then this may disturb the reading.

Back to normal

The teensy_interface was terminated, and further, the CRC was disabled.

Turn on CRC:

echo "i 0" >/dev/ttyACM0

Restart the teensy_interface, or maybe better, reboot the Raspberry:

sudo reboot now

alternatively, restart

cd ~/svn/robobot/teensy_interface/build
./teensy_interface -l

But the restarted process will be terminated sometime after you terminate the command line access.