- Arduino Uno or Nano - 1 nos
- BO motor (DC toy motor) - 1 nos
- L298 or L293 motor driver - 1 nos
- Include the required header files
- Declare the arduino pins connected to motor, PWM pins
- Instantiate a ROS node handler
- Define the functions for moving the bot : forward, backward, turn left, turn right, stopping
- Define the cmd velocity call back function
- Instantiate a ROS subscriber that subscribes to the topic cmd_vel
- Within the Arduino setup function :
- Set the pin modes
- Initialize the baud rate
- Initialize the node
- Initialize the subscriber
- Within the Arduino loop function :
- Process the subcriber callback (nh.spinOnce())
- Add a small delay
1.1. Launch roscore in a terminal
roscore
- In another terminal type in following to launch a rosserial connection with Arduino
rosrun rosserial_arduino serial_node.py _baud:=115200
- In yet another terminal run teleop_twist_keyboard to control the motor. Since we have interfaced only one motor we can verify the following functionalities - bot_forward, bot_backward and bot_stop. The bot_left and bot_right functionalities can be verified by interfacing one more motor.
rosrun teleop_twist_keyboard teleop_twist_keyboard.py