In this session, we will assemble a simple two-wheeled robot and learn how it moves around. The goal is to develop an intuition of how changing the direction and speeds of individual wheels can steer such a robot around a space. There are two components to this session:
Each robot has requires the following components:
- Chassis (to be 3D printed)
- 2x DC motor + wheel
- Motor driver (L9110 or L298N)
- Raspberry Pi (Model 4 and above preferred)
- Jumper wires
- Any powerbank
- M3 screws, M3 nuts, M2 screws, thread inserts Tools required: Allen keys, phillips screw driver, soldering iron
Fix the motors to the chassis with the help of the M3 screws and nuts as shown above. There is a small cylindrical extrustion on the motor that will fit into the hole in center hole. Then push the wheels into the motor shaft.
Mount the RPi and motor driver to the chassis using M2 screws.
The following configuration on the RPi are needed:
- Install Ubuntu 22.04 + ROS 2 Humble on the RPi
- Clone this repository
git clone https://github.com/yadunund/nirmitsu-ros2
On a laptop, follow insturctions from here to install the programming interface. Launch the software with these commands.
cd ws_nirmitsu
source install/setup.bash
ros2 run nirmitsu_ros2_flowgraph nirmitsu
A grey canvas will open up. If you right click on the canvas, a list of items which can be added will open up. They are grouped into 3 categories: Input, Display and Robot. We will not "assemble" the robot in software following the instructions below.
TODO
After assembling the robot in hardware and software, it's time to learn how the robot moves.
First, move the slider connected to the Left Wheel
and observe how the speed of rotation changes as you slide along. Click on the Reverse
switch to flip the direction of rotation. Then try the same with the Right Wheel
.
- Set the sliders for both wheels to the same value and turn on the robot. What direction does the robot move?
- Now flip the direction of both wheels. Does the direction of the robot change?
- What happens when one wheel is not in reverse but the other is?
- What happens when both wheels have the same direction but one is spinning faster than the other?
Now that we're familair with how each individual wheel should spin to move the robot, let's have some fun. Right click on the canvas and add the Joystick
input. Then connect the output of the Joystick
to the Joystick
input on the robot node as shown below. As you move the joystick around, the robot should follow the same direction and speed. You will notice that the joystick automatically sets the direction and speed of each wheel to follow the requested motion. But in principle, it does exactly what you did in the steps above 🙂