08: Building a ROS2 joystick controller
I look at my options for adding a joystick controller to my ROS2 project. So far I have been creating Twist messages to move the base in a SSH terminal, but being able to do it with a joystick will be easier and I will get a better feal for moving the robot and how the base is responding. I al review where I am with this preliminary phase of the ourBotManager project (Near the end) and look at some improvements to the platform (Upgrade to a 8GB RPI, set up a copy of my github code on the joystick controller, and install I2C and ADC python libraries). This description includes the commands used during the setup, at the end.
00:00 Introduction and overview
01:19 VScode was running slow on my 2GB RPI. I used the “top” command to try and identify the bottleneck slowing vscode down.
01:42 I upgrade the RPI hardware that will be running on the robot to a 8GB model
02:54 The 8GB RPI model shows a much better memory profile.
03:56 I review my checklist for the preliminary phase of this project. Next up will be to create a joystick controller, then just some final tuning and cleanup. After that I will start the next phase where I am using a real robot base.
05:01 I review the design decisions that lead to my final joystick approach.
07:40 I look at the problems I had with the first joystick design approach (PS3 controller on the RPI)
08:55 I run the PS3 on a i386 laptop running ROS2. Things work but there is more hardware involved than I am happy with.
10:07 I decide to build a custom joystick controller. (The link to the joystick component is at the end of this description)
10:27 I need a case for the controller, I use fusion 360 to design a case I can 3d print. (A link to the design file is at the end of this description.)
11:23 Review the 3d printed case and components (Joystick, RPI and ads1115)
12:03 I needed to clone my ourBotManager_ros github repository to the joystick controller RPI. I show how I did this. I walk through other software components needed on the Joystick RPI
13:32.I look at the first cut of the joy_node code I used to interface to the joystick (This did not include publishing twist messages)
15:41 A test of the initial code.
15:54 I walk through the MVP (Minimum viable product) version of the updated joy_node code. This includes the code to publish twist messages and tune the hardware.
20:43 A demonstration of everything working together. The joystick controller, the base_motor_controller node and the PI Pico microcontroller running the motors.
Creating a copy of the ourBotManager_ros repository
1. Start with an empty ros2_ws folder
2. Clone the repository with the . option
3. Do a colcon build (and add the source to the ~/ros2_ws/install/setup.bash)
Install vscode (see video ourbotmanager06 and https://code.visualstudio.com/docs/setup/linux)
Install supporting libraries for i2c and the ads1115
sudo apt install -y i2c-tools python3-pip
sudo pip3 install smbus2
sudo pip3 install adafruit-ads1x15
Check i2c device is visible on i2c bus #1
sudo i2cdetect -y 1
Other diagnostics for the usb devices
dmesg | grep usb
lsusb
Open the i2c permissions
sudo chmod a+rw /dev/i2c-1
Info if using the Foxe joystick packages
https://index.ros.org/p/joy/
Add Joystick : sudo apt install ros-foxy-joy
https://index.ros.org/p/teleop_twist_joy
Add Joystick : sudo apt install ros-foxy-teleop-twist-joy
Add joystick utilities: sudo apt install joystick
Test out your joystick: jstest /dev/input/js0
Running the node:
ros2 run joy joy_node –ros-args -p device_name:=/dev/input/js0
ros2 run joy joy_node –ros-args -p device_name:=/dev/input/js0 -p autorepeat_rate:=0.0
ros2 run teleop_twist_joy teleop_node
More info: https://medium.com/vacatronics/getting-started-with-raspberry-pi-i2c-and-ubuntu-server-eaa57ee0baf2
Joystick I used : https://www.amazon.com/gp/product/B08NG5B6H1
Lupincorp : https://www.lupincorp.com
ROS 1 for Beginners: https://www.udemy.com/course/ros-for-beginners/
ROS 2 for Beginners: https://www.udemy.com/course/ros2-for-beginners/
Github ourBotManager_ros repository: https://github.com/somervda/ourbotmanager_ros/tree/aee694a7ed7b690a2cd5d1bde1680b1d38fe4ee1
Github ourBoatManager_uController: https://github.com/somervda/ourBotManager_uController/tree/b8b851a6d23652806beac72168210bd43ee66a8f
VSCode install on Ubuntu: https://code.visualstudio.com/docs/setup/linux
by LupinCorp
linux foundation