Tutorial resources to Raspberry pi /Jetson Nano, ROS, Arduino: Guide to Autonomous car building
My background: I am new to ROS (Robot Operating System). I’d like to explore the use of Jetson and Raspberry pi in IoT applications and I am interesting in deep learning. Autonomous cars are one of the targets where deep learning is used. Building the autonomous car software can be done with the help of software like ROS. I wander around to find resources and understand ROS and its software library related to car control while I don’t have any background in Mathematics, controls, and Arduino.
Here I record the related websites that I read which I found it is interesting. I also list the study topics in phrases in order to accomplish the goal.
Prerequisite: I think the necessary backgrounds are
- Ubuntu basic since mostly we run ROS on Ubuntu. Lots of terminals are needed. Command line basis is required. Also basic of compiling using cmake, Make
- C/C++ programming and Python: ROS supports both C/Python programming. Previously, people have done ROS projects using C/C++.
Since first, I focus on Jetson nano. I look for tutorials in installation and dependency.
- ROS on Jetson Nano. For ROS, the workable to me is ROS-melodic for Ubuntu on Jetson, or even Pi. I have also asked many robot builder vendors, and they said their implementation is on ROS-melodic. I have tried the ROS2 but it is totally different from ROS1. On Jetson, it needs lots of package source compilation. So, I gave up for ROS2 for now and for with ROS-melodic. The guideline for installation from the official website is good enough.
- Necessary dependencies (library required for the project). Since we will control the robot from ROS which is on Ubuntu host, the host communicate with Arduino using serial with message publishing style. We need packages like rosserial to begin with. I have read the tutorial for rosserial from the official site and will need rossserial Arduino so we can send the message to Arduino with rosserial. Next, the game pad controller is needed. You need a joystick to manually control the car. The reading is here 1, 2 for controlling, testing your joystick.
- The development environment for Arduino on jetson is by jetsonhack. Then practices on this one to understand how Jetson communicates with Arduino.
How to compose robot your own.
To build your robot on your own, some toy car robot is a good start. This tutorial gives me an idea how to compose the robot toy car. Also, the site provides the Arduino code for controlling the motor and other sensors. The last part uses the ROS which I leave it at last after understanding the ROS well enough.
Overview of Robot Control
This tutorial gives you a good tutorial of understanding the overview block diagram of ROS control with teleoperation.
The python code is elaborate with arduino underneath. The code operates with Cythron motors and control 4 wheels Macanum wheels with encoders.
// Left motors
CytronMD motorFL(PWM_DIR, 3, 2); // PWM 1 = Pin 3, DIR 1 = Pin 2
CytronMD motorRL(PWM_DIR, 5, 4); // PWM 2 = Pin 4, DIR 2 = Pin 5 // Right motors
CytronMD motorFR(PWM_DIR, 9, 8); // PWM 1 = Pin 9, DIR 1 = Pin 8
CytronMD motorRR(PWM_DIR, 11, 10); // PWM 2 = Pin 11, DIR 2 = Pin 10
I like the overall block diagram showing the details which is a good understanding of motor control and voltages.
Deep down block diagrams, code, and some concepts.
To understand the basis of robot car control, I like this tutorial. It tells you by using the C++ code how to construct each part of the robot along with the control mathematics. The example uses 2 wheel robots as a case study.
First, the block diagram shows the hierarchy. Then the article explains the command control loop, pose control loop, motor control, etc. and robot in global frame and local frame which can help understand the concept of navigation in ROS, eg. transform.
The message structures in ROS which is used by Arduino client for extracting values for motor control operations. So, when looking at the code in Arduino, I can understand how the values are derived and then the Adrian adopts them to compute the pwm, and directions.
Useful github to start
After all trying, I found that the difficult part to make the navigation work is the good hardware, correct firmware and correct base, as well as some experience tuning. The important hardware for differential drives includes the motors, encoders, and motor controller. They should form a good foundation and you need to calibrate to get the right parameters e.g, encoder counts per wheel since they are basis for calculating correct position, velocity etc. I look for the code for the firmware (Arduino) for reading encoder values. The dronebot website is a good complete tutorial for building from the base until firmware.
Cerus robot is a good one I first look up for testing the base controller. The code is for 4WD differential drive but you get the idea to make it 2WD. The base controller in C shows how to move the robot around from joystick.
One of the most popular one is Nox robot. It provides a complete code use in the project of Sunjik. It provides all codes in firmware, base code, and launch file.
A linobot is one of the good ones as well. The github provides the template for navigation used for 2WD and 4WD. I keep it as a bookmark for reference.
Thai learners may find the tutorial from success robotic useful. You can google around and find the 7 youtube tutorial on ROS. The tutorials have the attached github code, though it is not full code.
As you start working on it, you find out there are a variety of implementing the firmware depending on the hardware used, the PID types etc. They are various ways to compute the linear velocity / angular velocity depending on the theories. The sensors used can be varied (3D camera, LIDAR, IMU, ). The sensor messages can be fused using algorithm like EKL, etc. Also, there are many slam/mapping algorithms (gmapping, hector, etc). They are many types of planners (global and local). At last, the visualization styles are varies (rviz, rtabmap, gazeboo).