-
Notifications
You must be signed in to change notification settings - Fork 1
arduino_asserv
This packaged is not a ROS package, but an Arduino one. The goal of the arduino_asserv package is to control the robot movement using an Arduino board.
-
v1.0 (A17) : @tfuhrman
- First working version
The section present where to find arduino_asserv files. The current architecture is a little bit complicated because all files are not stored in a single directory.
You can find the root of all files in the arduino directory from the coupe18 repository.
- common : folder containing common code, common stands for "can be compiled for small robot and big robot".
- gr : folder containing the big robot specific files
- asserv contains the arduino_asserv specific files for the big robot (motor controller code and parameters)
- others : not used anymode
- pr : folder containing the small robot specific files
- asserv contains the arduino_asserv specific files for the small robot (motor controller code and parameters)
- others : not used anymore
As a separate package the arduino_asserv code has to be compiled without using the ROS system. To make it very easy you just have to launch a script, it will handles the compilation and the writing of the binary on the Arduino board.
cd arduino
./generate_arduino.sh
The script will ask you the following things
- Target : this is the Arduino board you want to flash with the arduino_asserv code. For the small robot it's nano326 and for the big it's mega2560.
- Robot : the robot where the board will be.
- Program : the program you want to flash on the Arduino. Currently the only program supported is "asserv".
If the Arduino board is connected with an USB serial wire the script will automatically flash the Arduino. If not there will be an error at the end ("can't open device XXX: No such file or directory").
For now there is kind of a configuration using the parameters.h file of the corresponding robot. Here is the list of parameters you can modify.
Parameter name | Values | Function |
---|---|---|
ENCODER_EVAL |
1, 2, 4 | This parameter is used to change the encoder evaluation. An encoder works with 2 signals (A and B) and you can check the rising or falling edge of each signal. If the parameter is 1, the odometry will only check A signal rising edge. If 2 the check is done on A and B rising edges. If 4 the check is done on the rising and falling edges of A and B. The more encoder evaluation is big the more the robot odometry will be accurate. But more accuracy stands for more computation of the board and too much computation can lead to miss encoder signals and if so the odometry will be very inaccurate. |
SPD_MAX |
Positive number, in m/s | Set the maximal speed of the robot, in meters / seconds. This parameter impact the control law. |
ACC_MAX |
Positive number, in m/s² | Set the maximal acceleration of the robot, in meters / seconds². This parameter impact the control law. |
RATIO_ROT_SPD_MAX |
Decimal number | Ratio between the SPD_MAX and the rotational speed. |
BLOCK_TIME |
Positive number, in ms | Time to wait before firing a message telling that the robot is blocked (this message is fired only if the robot has to go somewhere, has not reached the position and has not moved until the BLOCK_TIME). |
BLOCK_MIN_DIST |
Positive number, in mm | Distance in millimeters that tells the robot has moved. |
ENC_LEFT_RADIUS |
Decimal number, in mm | Radius of the left encoder wheel. This radius has to be set by tests to have a more accurate odometry. This value can be different from the ENC_RIGHT_RADIUS. |
ENC_RIGHT_RADIUS |
Decimal number, in mm | Radius of the right encoder wheel. This radius has to be set by tests to have a more accurate odometry. This value can be different from the ENC_LEFT_RADIUS. |
ENTRAXE_ENC |
Decimal number, in mm | Distance between the two encoder wheels, in millimeters. This distance has to be set by tests to have a more accurate odometry. |
ERROR_ANGLE |
Decimal number, in rad | Minimal angle error, in radians. |
ERROR_POS |
positive number, in mm | Minimal position error (x and y), in millimeters. |
CONE_ALIGNEMENT |
Decimal number, in rad | Cone to determine if the robot has to move foward or backward. A value of 100 will disable the functionality. |
PID_P |
Decimal number | Proportional coefficient of the control law. |
PID_I |
Decimal number | Integral coefficient of the control law. |
PID_D |
Decimal number | Derivative coefficient of the control law. |
KEEP_LAST_GOAL |
0, 1 | If 1 the arduino_asserv will keep the last goal position (if GOTO) or angle (if GOTOA or ROT), if the robot is manually moved it will automatically move back to the previous location. |
A serial protocol has been developed to communicate between the arduin_asserv board and the ard_asserv
ROS driver. The goal of this section is to explain the protocol.
First of all the protocol file is located in common/asserv folder under protocol?h name and is defined as follow :
order;id;arg1;arg2;argn
Where :
- order is the identifiers of the order (see the table below)
- id is an unique unsigned integer id used to identify each order sent by the ROS driver. This id is used by the arduino_asserv package to tell the ROS driver when the order has been processed.
- arg is all the arguments going with the order (see the table below)
Order name | Corresponding order | Arguments | Function |
---|---|---|---|
START |
S | none | Ask the Arduino board to start. Before being started the board will not accomplish any orders. |
HALT |
H | none | Ask the Arduino board to halt. |
GOTOA |
c | x (int in mm), y (int in mm), a (decimal in rad), direction (int, -1 is backward, 1 is forward, 0 is any, optional) | Ask the Arduino board to move to a position with and angle. |
GOTO |
d | x (int in mm), y (int in mm), direction (int, -1 is backward, 1 is forward, 0 is any, optional) | Ask the Arduino board to move to a position. |
ROT |
e | a (decimal in rad) | Ask the robot to move to a an angle (can't turn more than 1 turn). |
ROTNOMODULO |
a | a (decimal in rad) | Ask the robot to move to a an angle (can't turn more than 1 turn). |
KILLG |
f | none | Go to next internal order. |
CLEANG |
g | none | Remove all internal orders. |
PIDLEFT |
p | p (decimal), i (decimal), d (decimal) | Set the PID coefficients of the left wheel. |
PIDRIGHT |
i | p (decimal), i (decimal), d (decimal) | Set the PID coefficients of the right wheel. |
PIDALL |
u | p (decimal), i (decimal), d (decimal) | Set the PID coefficients of the two wheels. |
PWM |
k | left (int), right (int), duration (int, ms) | Ask the robot to move using a PWM signal. Left and right parameters has to be lower than 255 (maximal power is applied on motors). |
SPD |
b | linear (int, m/s), angular (int, rad/s), duration (int, ms) | Ask the robot to move using speed. You have to set linear OR angular but not both. |
ACCMAX |
l | acceleration (int, m/s²) | Set the maximal acceleration of the robot. |
SPDMAX |
x | linear (int, m/s), ratio (decimal) | Set the maximal linear speed and angular speed ratio of the robot. |
SET_POS |
m | x (int in mm), y (int in mm), a (decimal in rad) | Set the robot position. This will over-right the current robot position. |
PAUSE |
q | none | Pause the control. |
RESUME |
r | none | Resume the control. |
RESET_ID |
s | none | Reset the last finished id to 0. |
SETEMERGENDYSTOP |
A | enable (int, 0 disable, 1 enable) | Enables or disables the emergency_stop mode. |
Note : if you check the protocol.h file you will see more orders. There are not present here because not used.
If you open a serial connection with the Arduino (Putty, CuteCom, Minicom) board you can directly send orders using the protocol.
S;0;
: to start the Arduino board
m;1;0;0;0;
: to set the robot position to (0, 0, 0)
c;2;1000;1500;3.1415;1
: to ask the robot to go in (1000, 1500, 3.1415) position, forward
Compile and upload the code on an Arduino board, the package will run automatically when the Arduino is powered up.
//TODO control law //TODO PID setting
Wiki UTCoupe 2018, Université de Technologie de Compiègne, France.
Any questions or comments ? Wanna join our team ? Contact us at utcoupe@assos.utc.fr!