0

Line Robot - lidars and motors

Lidars

First, let's change lidars' CAN Bus addresses. Each of 3 of them received a unique address automatically after power-on, but it is quite likely that they are not correct for a Rescue Line robot. On the picture left lidars' device id numbers are designated with green letters and are 0 to 2. You will have to change CAN Bus addresses to get this configuration. In terminal use command "idc" to show all the addresses. If there is a lidar named "Lidar2m-0", change its address to 3. If there is none, there is nothing to do here. Any of the both possibilities will result with no sensor name "Lidar2m-0" in the list, which You can also get using "can" command.

Now, having address 0 free, we can assign the leftmost sensor to it. Execute "li2" command and watch the sensors measuring distances. Put an object in front of L0 sensor (0) and find its position in the list as the numbers in that column will change according the the objects distance. Let's say it is in the 2nd column.

Run "idc" again and find 2nd lidar from the top. That is the L0 lidar, probably with a wrong address. Change its address to 0. That completes this step and the L0 lidar has address 0 assigned.

Run "can" again and You will find a gap in names, Lidar2m-1 or lidar Lidar2m-2 will be missing. That it the chosen lidar's old address. Let's say that is 1. Look at the picture and note that this is L1 sensor. We should now do the same procedure for L1, as we did for L0. This step should be repeated for the last sensor.

If this procedure seems to be complicated, You can also disassemble the sensors and connect them in the right order.

Motors

Look at the picture above again: M1 designates 1st motor (connected to motor controller's output connector 1), M2 the second, and so on. Connect them in this order. Alternatively, You can connect the any way You like, but will have to change software setup. If You choose the latter option, find this part of the code in C:\Users\[Your login]\Documents\Arduino\libraries\mrm-robot\src\mrm-robot-line.cpp:

motorGroup = new MotorGroupDifferential(mrm_mot4x3_6can, 0, mrm_mot4x3_6can, 2, mrm_mot4x3_6can, 1, mrm_mot4x3_6can, 3);
2nd parameter (0 in this case) is the number of output connector assigned to first motor, 4th second, 6th third, and 8th fourth. Note that output connectors have numbers 0 - 3 (in code) instead of 1 - 4 (PCB designations).

Any method chosen, You must confirm the result by running "mot" command, which must turn the motors on in the right sequence: first M1, then M2, M3, and M4.

Now directions of rotation: "can" must start each motor first CCW (counter-clockwise), then CW. Note which motors did not obey this rule. In that case You have 2 solutions.

  • If You want to change, for example, direction of first motor (0), include (for example after command listed above) command
    mrm_mot4x3_6->directionChange(0); 
    
  • Although not the best solution, You can just change mrm-robot-line.cpp, line
    mrm_mot4x3_6can->add(false, "Mot3.6-0");
    
    This code is again for the first motor. Change "false" into "true". Changing base class is not the best option because other robots may use it.

Run "mot" again to make sure that everything works correctly now.