Software Documentation - lukasholtkamp/b.ob GitHub Wiki
This article lists the most necessary software that need to be met.
Status: 24.07.2024
- Joy Node:
- This publishes what buttons and axes are being pressed/moved.
- Drive Selection Node
- This takes the buttons pressed and changes the driving mode accordingly as well as reading when the emergency button is pressed to go back to Drive Selection Mode.
- Diffbot controller Node:
- This takes in the command velocities and does the calculations to find out what speed signals need to be sent to each motor.
- Joint state broadcaster Node
- This reads all state interfaces (position and velocity) of each wheel.
- IMU broadcaster Node
- This reads all state interfaces of the IMU.
- Robot State Publisher Node:
- This takes in the state interfaces and sends this information along with a robot description to the control manager.
- Control manager Node:
- This takes in the description of the robot and is able to output the position and velocity information.
- Transform listener Node:
- This transforms the axis according to ros2 control to be reflected in rviz.
- EKF filter Node:
- This take in the information of the IMU and the encoders and fuses them to get a better estimation of the position of B.ob.
- Teleop Node:
- This takes the button presses and axes movements and converts them into command velocities. This also ensures safe driving of B.ob by checking motor speeds before sending certain signals.
- Rplidar Composition Node:
- This Node gets the lidar information and publishes it on the /scan topic
- PID Node:
- This is lateral PID controller to maintain the same driving direction.
- Teleop Node:
- In this mode, there is the added functionality of setting the setpoint for the PID controller and sending the signals for maintaining the setpoint angle.
- SLAM toolbox Node:
- This takes in the lidar scans and creates a 2D map of the environment.
cd b.ob/docs
doxygen dconfig
Sometimes you may have issues reading the topics from the Rpi on your own PC. To solve this we used a Rpi3 as a hotspot.
This tutorial shows how to set up the Rpi3 as hotspot.
Your own PC must be connected to Ethernet to get internet access and the wifi must be connected to the Rpi3 hotspot. The Rpi of the robot must also be connected to the Rpi3 hotspot to be able to send the topics over that network.
with Rpi connected to a display, type in a terminal
sudo apt update
sudo apt install openssh-server -y
sudo ufw allow ssh
sudo systemctl status ssh
if succesful, the status should be active
Make sure you have arp-scan installed
sudo apt install arp-scan
To connect to Rpi via ssh, you need the IP address. You can run the following code in a terminal
sudo arp-scan -l
and look for the name "TP-LINK TECHNOLOGIES CO.,LTD.".
You can filter the results by using this name with grep
sudo arp-scan -l | grep "TP-LINK TECHNOLOGIES CO.,LTD."
However other devices may be using this TP-Link also. Hence we used the MAC address instead.
sudo arp-scan -l | grep "<YOUR-MAC-ADDRESS>" | awk '{print $1}'
Note: The MAC address be in the second column of the sudo arp-scan -l
output.
Once the IP is found you can type in
ssh ubuntu@<YOUR-IP-ADDRESS>
or
ssh ubuntu@$(sudo arp-scan -l | grep "<YOUR-MAC-ADDRESS>" | awk '{print $1}')
To have a script that runs automatically with no input, we need to remove the password for sudo commands. First, open visudo.
sudo visudo
at the end of the script, add line
<username> ALL=(ALL) NOPASSWD: ALL
save and close.
Create a bash script called start_up.sh
nano start_up.sh
copy and paste the following
#!/bin/bash
sudo killall pigpiod
sudo pigpiod
sudo chmod a+rw /dev/i2c-*
source /opt/ros/humble/setup.bash
cd b.ob
colcon build
source install/setup.bash
ros2 launch bob_bringup diffbot.launch.py
Once creating the bash script, make it executable,
chmod -R 777 start_up.sh
Go to the startup application preferences on the Rpi. Add a new start up program called start_up with the command
gnome-terminal -- .start_up.sh
- The Xbox gamepad is to be used as a manual input device.
- The assignment of the buttons must be documented to exclude duplicate use.
- The gamepad must be able to connect to b.ob automatically.
- Various driving modes can be started and stopped via the gamepad.
- A software emergency stop is to be triggered via the Xbox gamepad, which switches off the actuators on the software side.
- It must be possible to shut down the connected controller via the gamepad.
Button | Number | Axes | Number | |
---|---|---|---|---|
A | 0 | LSB-X | 0 | |
B | 1 | LSB-Y | 1 | |
X | 3 | RSB-X | 2 | |
Y | 4 | RSB-Y | 3 | |
LB | 6 | RT | 4 | |
RB | 7 | LT | 5 | |
View | 10 | D-Pad-X | 6 | |
Menu | 11 | D-Pad-Y | 7 | |
LSB | 13 | |||
RSB | 14 |
Button | Number | Axes | Number | |
---|---|---|---|---|
x | 0 | LSB-X | 0 | |
o | 1 | LSB-Y | 1 | |
□ | 3 | RSB-X | 3 | |
△ | 2 | RSB-Y | 4 | |
R1 | 5 | R2 | 5 | |
L1 | 4 | L2 | 2 | |
R2 | 7 | |||
L2 | 6 | |||
Up | 13 | |||
Down | 14 | |||
Left | 15 | |||
Right | 16 | |||
Select | 8 | |||
Start | 9 | |||
On | 10 | |||
LSB | 11 | |||
RSB | 12 |
When the Gamepad not connect automatically to the Robot, follow the following steps:
- Open a Terminal on the Pi
- Open the bluetooth settings
bluetoothctl
- Press the connecting button on the Gamepad (on the Back between LT and RT)
- Start the Device scan on the Pi
scan on
- When the XBox Controller as a new Device appears
[NEW] Device A5:B2:D3:A4:59:A8 Xbox Wireless Controller
stop the scan
scan off
- Connect the Gamepad with the given MAC-Adress
connect YOUR_MAC_ADRESS
- Add the Gamepad now to the secure list of trusted devices
trust YOUR_MAC_ADRESS
- Now the Gamepad is fully connected and connects automatically at the next start
- Leave the Bluetooth-Tool with Ctrl-D
After connecting the IMU with the Raspberry Pi 4 as shown in the Hardware Documentation, we need to perform some steps to check if the IMU is connected and working successfully.
To detect if the IMU is connected:
- Run
ls /dev/i2c-*
and you should see /dev/i2c-1
.
- The address of the IMU is 0x68, so when you run
sudo i2cdetect -y 1
you should see it listed.
- Run
sudo i2cdetect -l
if you have more than one I2C device.
Before we start with the calibration, there are some packages that need to be installed:
sudo apt install python3-smbus
sudo apt-get install ros-humble-imu-tools # for the rviz_imu_plugin
Then, after you compile the code with:
colcon build
In the b.ob directory, type:
source install/setup.bash
Then you will be able to run the calibration codes:
- To calculate the offsets, run:
ros2 run bob_bringup mpu6050_offsets
Copy the values and paste them into mpu6050_lib.h
.
- To calculate the covariances, run:
ros2 run bob_bringup mpu6050_covariances
Copy the values and paste them into bob.controllers.yaml
.
To check if the IMU is working, compile the code again:
colcon build
Then launch the diffbot.launch.py
:
ros2 launch bob_bringup diffbot.launch.py
After launching, open RViz by typing
rviz2
, and add the robot model. You should be able to see:
rviz_imu_plugin
|_ imu
|_ Mag
Add the imu and select the imu_broadcaster/imu
topic.
After that, the transform for the IMU plugin will be displayed. As soon as Bob (and thus the IMU) is moved, it will also move in RViz.
TBD
Good examples: