Setup the Roboclaw - SwarmUS/Pioneer-Mechanical-Update GitHub Wiki
Roboclaw setup
This page is guide on how to setup the Roboclaw motor controllers with our configuration.
Initial setup
Requirements
You will need to:
- Clone the SwarmUS-ROS repo
- Download Motion Studio from BasicMicro link (Windows).
- Have a Roboclaw board
- A micro usb cable to link the roboclaw to our computer
- A power source to power the Roboclaw via the main voltage terminals or the logic voltage pins. See the datasheet for the connection and the voltage level
Setup
- If the setup is made while the roboclaw is controlling real actuators, safety measures should be taken to ensure that the robot can't do any harm if the motors are set to full speed (ex: putting a wheeled robot on a stand so the wheels won't touch the ground). 2.Connect the power to the Roboclaw. A green LED should light up to indicate that it's powered. If a red LED is light up, look at the error definition in the Roboclaw user manual in the Status LEDs section.
- Connect the USB cable from the roboclaw to the computer
- Launch BasicMicroMotionStudio and connect to the roboclaw buy clicking on the "Connect Selected Uni"button. You should see the following page:
- Update the firmware if needed:
For the next steps you can either load our configuration for a roboclaw 2x30A for a Pioneer 2DX or do your own setup.
Loading config and tuning
- Go to File->Load Settings:
- Go to where you cloned the SwarmUS-ROS repo. Then go to SwarmUS-ROS/src/swarmus_pioneer/config. You should see 2 config files:
The two configs have the same general settings for the serial communication, battery voltages, max currents and encoder configuration. They differ on the parameters of their velocity PID. The roboclaw_1st_pioneer.cfg PID was configured with the auto tune function and represents a more agressive controller without overshoot compared to the roboclaw_slow_config.cfg which was manually tuned with a lower speed limit and acceleration. I suggested to use the roboclaw_1st_pioneer.cfg config since the low speed behavior needed will be handle by a ROS node.
- You should see the following settings in General Settings:
-
baudrate: Match the serial communication baudrate set in ROS
-
Timeout: Time after which the motor will stop if no serial messages are received
-
Main Battery (Max and Min): Input voltage at which the motor controller will try to brake the motor and let them go into freewheels. Set to +2V over the max voltage and -2V below the minimum operating voltage of our battery (recommendation from the Roboclaw manual).
-
Logic Battery (Max and Min): Not used but set anyway to 5V (min limit) and 14V (max limit) which is around +2V the max voltage of our battery.
-
Max Current: Set below the stall current of our motors (17A) and set below our main fuse divided by 2 (25A/2=12.5A).
-
Default Speed: Not used directly since its used for position control and for RC and analog control mode. Set to a speed of 0.3 m/s with a Pioneer 2DX
-
Default Accel and Decel: Not used directly since its used for RC, Analog and commands without Accel and Deccel arguments. Our ROS roboclaw drivers sends speed and accel commands so this parameter is not overwritten. Set to have a 0.3 m/s^2 based on the User manual.
-
Encoder 2 Mode: Invert it since our electrical harness is connected has such.
4.You should see the following settings in Velocity Settings:
The PID was tuned with a fully charge battery and with the "Tune M1" and "Tune M2" command. This tuning should be done for each robot to have a better control loop for each systems.
Using UART pins on Raspberry Pi 4 instead of USB
Instead of using a USB port on the Raspberry Pi 4, it's possible to use a UART interface from the Pi'S GPIO pins to connect to the UART pins of the roboclaw.
Requirements
You will need to:
- Clone the SwarmUS-ROS repo and build it
- Have a Roboclaw board
- A Raspberry Pi 4
- 100 mils female header connectors
- Wires
- libraspberrypi-bin
- If the Pi is running Ubuntu, it might not be installaed. Can be download with
sudo apt install libraspberrypi-bin
- If the Pi is running Ubuntu, it might not be installaed. Can be download with
Config
-
Verify that you have the following directory
/boot/firmware/overlay
and that you can run the following commanddtoverlay -a
. If not, libraspberrypi-bin might not be installed. -
Open a text editing tool to modify
/boot/firmware/usercfg.txt
as super user:sudo nano /boot/firmware/usercfg.txt
-
The next step is to activate another UART than the default UART on pins 14 and 15 since it's a mini-UART (link to Pi's UARTs). For our robot we took the UART2. So you need to tell the firmware to activate the UART2's pins by adding the following line in the
usercfg.txt
:dtoverlay=uart2
-
After reboot, the device file
/dev/ttyAMA1
should be present. -
Since the roboclaw node connects to the device
/dev/roboclaw
an additional Udev rule should be added to create a symbolic link betweenttyAMA1
androboclaw
.- Create a new rule with:
sudo /etc/udev/rules.d/41-roboclaw_uart.rules
- Add the following line in the new rule:
KERNEL=="ttyAMA1", SYMLINK+="roboclaw" MODE="0666"
- Create a new rule with:
-
Reboot the Pi
-
After reboot, run
ls -l /dev/roboclaw
and you should the symbolic see link as follows:lrwxrwxrwx 1 root root 7 Apr 1 2020 /dev/roboclaw -> ttyAMA1
-
Turn off the Pi for safety
-
Connect the pins 27 and 28 of the Raspberry Pi to the pins S1 and S2 of the Roboclaw respectively. You will also need to connect the GND of the two boards together. Twisting the 3 wires together can help reducing the noise on the lines.
Warning: this setup creates a ground loop because of the new GND path between the Roboclaw and the battery through the Pi's GND. An isolator should be used to remove any future electrical problems. An addition to that, the Raspberry Pi might not boot if the RoboClaw is not powered-up since the Raspberry Pi doesn't detect a valid state of its GPIO 1 on boot.
-
Boot up the Pi
-
Run
roslaunch swarmus_pioneer pioneer_bringup.launch
and the roboclaw node should start without problems.
Useful link: Pi-4 Activating additional UART ports - Raspberry Pi Forums