I want to update my TurtleBot3 Burger to the latest ROS2. This will be Humble because they don't exist in Jazzy for now.
**For more information about ROS2:**
### Burger Hardware
First we need to know more about the TurtleBot3. As it comes from the firm **ROBOTIS** (robotis.com) we find all the infos in there emanual: .
Special about TurtleBot3 are the smart actuators **DYNAMIXEL**, developed by ROBOTIS, for driving.
The main board is called `OpenCR1.0`: . It contains an STM32F7 microcontroller and that can be flashed with the Arduino IDE. So let's first update the firmware:
Arduino needs to know the board, so we add the following string to the `Additional boards manager URLs` in the `File -> Preferences...` menu:
**https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/arduino/opencr_release/package_opencr_index.json**
Next we install the board in the Boards manager, connect the board to the PC and choose the board and the right port under `Tools`.
Under `Files -> Examples` we find the ROS2_TurtleBot3 firmware for the Burger:
Before we compile we need to install the `Dynamixel2Arduino` library, that we find in the library manager.
Than we compile and flash the firmware.
### Installing the ROS2 TurtleBot3 packages
The first step is to install the packages for the TurtleBot 3. As stated we do this on `Humble` (Ubuntu 22.04). I will use a Raspi4 for this. The installation of Ubuntu and ROS2 is described on [ROS2_basics](https://www.weigu.lu/sb-computer/ros2_basics/index.html).
We have 2 types of ROS2 packages. Binary packages are in Ubuntu provided as debian packages (`apt install`). Build-from-source packages can be provided by ROS2 or are programmed by ourselves. They have to reside in the `src` folder of a ROS2 workspace.
In Humble the TurtleBot3 packages are not in the ROS2 package list. We can check with the following commands:
The TurtleBot3 LDS has been updated (LDS-02) since 2022. I have the older LDS. We need to specify which LDS with an environment variable.
ROS Domain ID must be the same on PC and bot. Default ID of TurtleBot3 is 30.
And now we are able to start the TurtleBot3 (The battery and LDS must be connected!)
### Teleoperate the TurtleBot3
#### Using a keyboard
On the main computer I tried to install gazebo to simulate the Turtlebot3, but for the moment this is not working on Raspi4.
The TurtleBot3 can be teleoperated by various remote controllers Let's start with a keyboard on the main computer.
We need to set up some environment variables and can then start a `teleop_keyboard` node to control the TurtleBot3 with a keyboard:
To better understand the topic look at the [ROS2 conventions](http://www.weigu.lu/sb-computer/ros2_basics/index.html#link_6).
#### Using a joystick
Next step is to use my Xbox One S Controller (1708). First step was an update of the controller with a Windows app called Xbox accessories (You need updated Win10/11 and the app was only in the store when setting location to US).
ROS2 has two packages that make working with gamepads and joysticks easy. The first node (`joy`)communicates with the Xbox controller through the Linux drivers and publishes a `sensor_msgs/Joy` message. This is a list of buttons and axes, and we see in live what button or axes in manipulated. This data can than be used by other nodes.
The second node (`teleop_node`) picks out the thumbstick values and publishes an appropriate Twist message (`/cmd_vel`).
Using two nodes makes changing the joystick much more easy as not everything has to be rewritten for every joystick.
First I tried to use the controller with an USB cable, but this does not work. Apparently the cable is mainly used for charging and updates but not to use the controller with USB.
We power the Xbox controller on (`X` button) and set it in bluetooth pairing mode (`)))` button).
##### Connect the controller on the GUI
Raspi4
This is by far the easiest way, but you have to connect a Screen.
After switching the Xbox controller on we see it under bluetooth settings and are able to connect.
We test if the controller is ok with the joy node. Joy_enumerate_devices should show the controller. We run the node and look at the topic in a second terminal:
We could the use in a second terminal `ros2 run teleop_twist_joy teleop_node` but there is a better way to do it.
We stop the `joy` node and use the following launch command to start `teleop_twist_joy`. The `launch` command also starts the `joy` node (only one terminal) and has a parameter to define the controller.
And here I had a problem, because the teleop node displayed `Teleop enable button 2`. There is a button that has to be pressed to send messages from the thumbstick (dead man's switch) and none of the buttons corresponded to button2!
So I tested the buttons with the joy node and edited the config file:
`/opt/ros/humble/share/teleop_twist_joy/config/xbox.config.yaml` and changed the following lines:
enable_button:6# Left trigger buttonenable_turbo_button:7# Right trigger button
Now I was able to use the Xbox controller.
##### Connect the controller on the terminal
This is more complicated. A good documentation is here:
we use the `bluetoothctl` command and get an interactive shell to run the bluetooth commands.
+ `show` shows us the controller (e.g. E4:5F:01:00:AD:21). If not powered on:
+ `power on` the controller, if not discoverable:
+ `discoverable on`
+ `list` if more than one controller
+ `select E4:5F:01:00:AD:21` if more controller
+ `scan on` to find the Xbox controller (e.g. 98:7A:14:29:AA:94)
+ `devices` to show the devices
+ `pair 98:7A:14:29:AA:94` to pair the controller
+ `connect 98:7A:14:29:AA:94` to to connect to the controller
If everything is ok we test with: