Autor: Carlos Roberto | Publicado: 2016-08-24T13:57:00-07:00



Design and Implementation of Autonomous Vehicle System – Part 2


I had to split this project to facilitate the reading.
Depending on what you want to read, you can go directly to the part of your
interest. That said, here
is the Part
1 of this project.



Now that I have assembled the rover, as you can see in this
figure, is time to go to calibration. 
In the era of IoT devices like cell phones to control the temperature of your
home, measuring the electrical consume, displaying the rear view of your car or
where is your home in a map view, it is very important that the device is very
well calibrated to avoid bad results with bad consequences. 
Hopefully, actually we have some basic procedures and nice tools that can help
us a lot in calibration scenario. 



Camera calibration

According to Wikipedia, camera
calibration is the process of determining the intrinsic and extrinsic
parameters of a camera with respect to world coordinate system. In other words,
camera calibration relies on collecting a set of world points whose relative
coordinates are known and which image plane coordinates are also known. For
this process, I used the classical chessboard picture and the ROS Camera
Calibrator process. 
Basically I printed this
chessboard and used it with the following ROS command:




rosrun camera_calibration
cameracalibrator.py --size 8x6 --square 0.025 image:=/my_camera/image
camera:=/my_camera



Go to your raspberry pi installation and run the command
above. In the ROS tool you will see something similar to figure 1 below:




Figure 1 - Camera Calibration


The tool will try to fill the 4 items: X, Y, Size and Skew.
In this case, you need move the chessboard from right to left and vice-versa
and move back and forth so the utility can calculate distance, size and any
necessary data to calculate the intrinsic values. These movements must be
repeated until the utility ends the task of capture picture information to
process the calibration. When the utility ends, just click the calibrate button
and wait (it might take some minutes) until the resulting calibration values
are displayed in the monitor. If all is ok, you don’t need take care because
the tool will automatically save all the parameters. You can find more detailed
information about camera calibration in ROS site, here.



Sensor calibration

Sense HAT is the sensor I am using in this project but you
can use any other you think is good for you. You can find more details about
Sense HAT in Raspberry Pi here and some
documentation in the GitHub repository.
The Sense HAT is an add-on board for Raspberry Pi. It has an 8x8 RGB LED
matrix, a five button joystick and includes the following sensors:




·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Gyroscope
·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Accelerometer
·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Magnetometer
·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Temperature
·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Barometric Pressure
·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Humidity

<!--[if !supportLists]-->











For this project I will be using only the magnetometer and
accelerometer sensors.
Hopefully the raspbian installation provides the RTIMULib2 directory where we
will find utilities that we can use to calibrate and test sensor devices. 



Motor calibration

Motor calibration is also required to reduce navigational
errors. An error from the wheel odometry can result in accumulation of errors
in the position of the robot. &nbsp;In
addition, suppose if there is slip in the ground between the two wheels of 1
centimeter, it can cause more errors than in the odometry case. So, it is very
important try to minimize all these errors as short as possible. One very
simple test is to set the linear velocity to a known value, let say 0.3 m/s,
which means that the robot will travel 30 cm in one second. Mark the start and
final point of the robot after 1 sec and measure the displacement. Depending on
the material where the wheels are running, you can get slip in the start and
final. So try to use a good surface to minimize the slip behavior. Repeat the
process until you are confident that you have good values. 
So, based on our kinematic model, we can write the following equations:









The vr and vl are the linear velocities in the right and
left wheels of the robot. Note that if angular velocity w = 0, then vr = vl
which means that the robot will run in a straight line. By the other side, if w
= 0 but the robot is drifting to left or right, this means that one motor is
running faster (or slower) than the other making the robot to drift to one
side. In this case, you need add an offset value in the angular velocity to
compensate the difference of velocity between the two motors. Things like that
must be resolved and the calibration is used to fix these issues.
You can find more details about the Kinect model here.
The figure below shows what I used to calibrate the motors. For instance, if
you set the linear velocity to 0.3 m/s, then the robot must reach the mark of 30
cm in one second. For variations of this value, you will need increase or
decrease the gain of velocity to make sure the robot is having a behavior as
much as possible, near the setup values in the controller software.


Figure 2 - Motor Calibration


Basic tests

Ok, all the stuffs calibrated, then I need check if the
robot is working as designed. To do so, I just set values to linear and angular
velocities and see if it is working properly. If you want do a more sophisticated
test, you can use the motor.py code the you will find in the repository. To
facilitate the things, I just used v = 1 and w = 0.3. This will make the robot
run continuously in circle, in counterclockwise direction. 
In the video link you can see the
final result.
Note that for now, I have only provided basic functionalities just to test if
the driver and motors are working properly. 



  
 
 
 
























































In the next session, Part 3, I&nbsp;talk about tracking and so, I
will describe how to implement the Dijkstra’s algorithm. According to Wikipedia,
Dijkstra’s algorithm is an algorithm for finding the shortest path between
nodes in a graph, which may result, for example, in road network. 
Stay tuned…