Jetson Nano Robot
UPDATE: 2/12/21
Added Raspberry Pi control with Bluetooth controller and HC-12 backup transceivers. Python object detection and multithreaded control code.
The HC-12's are 433Mhz and have up to 1.8Km range (at 9600 baud, not so great...) and the Raspberry Pi easily runs off battery so now we can have some robot fun at the park with long range if needed.
I bring a tiny wifi router so it uses modbus over wifi if its available, otherwise switches to the HC-12.
Raspberry Pi with HC-12 and Bluetooth Xbox controller
Nvidia Jetson Nano control and vision with 4-Wheel Steering, ROS2 RealSense2, RPlidar, BNO055, Python3, Pygame and ModBus to drive the Jetson Nano using modbus joystick commands
Using: PC - Ubuntu 20.04 and ROS2 FOXY
- 2 Joysticks, Thrustmaster HOTAS Joystick and Throttle
Jetson Nano - Ubuntu 18.04 and ROS2 Eloquent - Adafruit PCA9685 16 Channel PWM driver board - BNO055 gyro - USB wifi card - RPLidar - Realsense D435 - 4-Wheel Steering
Joystick Control - Pygame and Modbus: PyModbus
sudo pip3 install adafruit-servokit
sudo pip3 install pymodbus
sudo pip3 install pygame
Build the ROS2 packages if needed - realsense2, rplidar, bno055 or use your own camera solution
colcon build --symlink-install
start ROS2 Realsense And Lidar Nodes on the Jetson
ros2 launch realsense_examples rs_camera.launch.py
Lidar node - Lidar works well in ROS2 but it also has python code unimplemented now
sudo chmod 666 /dev/ttyUSB0
ros2 launch rplidar_ros rplidar.launch.py
Visualization - For the cameras, I keep the subscriptions to a minimum for a faster frame rate for just driving. Nav2 and slamtoolbox create maps and can create pathways but with no control node yet, I'm using Python.
rviz2
Python code
I actually need to get all this running in ROS2, but that becomes difficult when I want my PC to run Ubuntu 20.04 which is fine and can run ROS2 Foxy but... The Jetson Nano image only runs Ubuntu 18.04 and that only allows it to run ROS2 Eloquent which has less features.
Also running all the nodes in ROS2 gets crazy with 8 or more terminals open and although it's well written and distributed, there are many working parts all connected so super easy to break something when coding.
Also would have to build my own ROS2 PCA9658 package as one does not exist.
There is a Jetson Nano 20.04 image out there which would be great but i couldn't get it to work. There are several revision versions of the Nano so that makes it even harder.
Pygame is the easiest way to get Joystick data from the PC but pygame doesn't like to run remotely because it uses a display and can't find one through SSH. There are ways around this through Pygame but also around Pygame using ModBus.
I had never heard of ModBus but apparently it's ancient and works great.
I run these scripts in different terminal windows - next step, one PC run script and one Robot run script
sudo python3 sync_server.py
Run on the PC. Starts the ModBus server - Set for IP transfer. You will need to change the IP addresses to the machine running the server. can just use localhost addresses. Must change the settings to use UDP, binary, ASCII or serial transfers - there are async server examples in the documentation at: https://pymodbus.readthedocs.io/en/v1.3.2/examples/asynchronous-processor.html The server can be configured to only receive a set number of commands, but is currently configured to the maximum number I don't know what that is, hundreds or thousands I'd guess even though I'm only sending 5 right now.
sudo python3 modbus_joy.py
Run on the PC. Starts the Pygame Joystick modules and Modbus client -You will need to set your IP address to the machine running the sync_server. can use localhost addresses if its running on the same machine. Currently set for the Thrustmaster dual joystick setup described above. Need to set Joystick numbers, axis and buttons...
Read more »
Yes it's fast, I have the speed limited in the ros2_pca9685 package. It can also be limited in the Nav2 package parameters. You can have a different scale set up for the joysticks so you can run faster while joystick-controlled if needed. But to answer your question I have not done any speed tests yet; its a great question I'm guessing the maximum speed would be too fast for the controllers to keep up but I'd like to find out too