Mobile Robot using ROS and ESP32 (rosserial).
- ESP32.
- Motors.
- L298N.
- Xbox Controller.
- 18650 batteries.
In order for the project to work we need to have installed Ubuntu 20.04 LTS Focal Fossa alocated in a partition with a Windows dual boot or as the main Operating System of your machine.
You can try to virtualize it but in my experience, networking and driver problems arouse.
We need to install ROS Noetic Ninjemys, you can follow the documentation on how to install it or you can follow and run these few commands inside Ubuntu's terminal:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install ros-noetic-desktop-full
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
You can use any controller listed in the documentation. I'm personally using an 8bitdo Ultimate C 2.4GHz. It is not a Xbox Controller per se but I managed to find some drivers to trick Linux into thinking it is a generic Xbox Controller (you can find the post here):
touch /etc/udev/rules.d/99-8bitdo-xinput.rules
sudo nano /etc/udev/rules.d/99-8bitdo-xinput.rules
Inside 99-8bitdo-xinput.rules you type the following and save:
ACTION=="add", ATTRS{idVendor}=="2dc8", ATTRS{idProduct}=="3106", RUN+="/sbin/modprobe xpad", RUN+="/bin/sh -c 'echo 2dc8 3106 > /sys/bus/usb/drivers/xpad/new_id'"
Reload udevadm service
sudo udevadm control --reload
You also need to make your joystick device accesible:
ls -l /dev/input/jsX
You will see something similar to:
crw-rw-XX- 1 root dialout 188, 0 2009-08-14 12:04 /dev/input/jsX
We need to change XX to rw:
sudo chmod a+rw /dev/input/jsX
We initialize our master:
roscore
To initialize our serial node using tcp protocol:
rosrun rosserial_python serial_node.py tcp
To initialize our joy node using joy package:
rosrun joy joy_node _dev:="/dev/input/jsx"
If we want to see our joy node response:
rostopic echo joy