Tutorial on my YouTube channel here: https://www.youtube.com/watch?v=2jEhv6k0qoU&list=PL2WFkLlnc7_sC9Yg80icHE9x0goyS_JQl
Thanks to yoraish https://github.com/yoraish for the ROS setup tutorial.
I have used the chasis of the robot model "4WD mecanum wheel mobile arduino robotics car" from Nexusrobot.com . I changed all the electronic using these devices:
- Arduino Due
- Raspberry Pi 4 ( I think that also Raspberry Pi 3 Model B will work)
- Polulu Motors 37Dx70L with encoder 64 CPR and reductor 70:1
- Adafruit MotorShield v2
- Adafruit BNO055 IMU 9DOF
- YDLIDAR X4 lidar
Go and check his project here https://github.com/yoraish/lidar_bot I followed step by step his tutorial, I will report here just the modification maded to fit my setup.
I used this Image with ROS Melodic preinstalled. https://disk.yandex.ru/d/YfLc4stnCBljTA.
Same as yoraish. My observer machine is based on Ubuntu 20.04 and I use this PC to run the Matlab GUI.
I preferred to assign a static ip to the Raspberry like this: Open and modify wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Adding this line at the end of the file:
network={
ssid="your-networks-SSID"
psk="your-networks-password"
}
Open and modify /etc/dhcpcd.conf:
sudo nano /etc/dhcpcd.conf
Adding this line at the end of the file matching your network setup.
interface wlan0
static ip_address=192.168.11.13
static routers=192.168.11.1
I am using the YDLIDAR X4 for this build. The first step is to install the necessary drivers. The driver is a ROS package.
-
cd catkin_ws/src
-
git clone https://github.com/YDLIDAR/ydlidar_ros.git
-
cd ..
-
catkin_make
-
source devel/setup.bash
-
Follow the directions from the repository, written below:
-
roscd ydlidar_ros/startup
-
sudo chmod 777 ./*
-
sudo sh initenv.sh
-
Note: every reboot, you need to
source devel/setup.bash
fromcd catkin_ws
or consider to include in .bashrc on home user folder.
Test the lidar with roslaunch ydlidar_ros X4.launch
. Visualize the scans in Rviz, by adding the topic /scan
.
Step 6 and 7 are the same as yoraish. I haven't performed step 8,9,10.
The robot architecture is explained in the figure:
The robot works also without the Matlab application. You can control the robot sending message directly via ROS, but with the app is easier!
Dependencies:
- MATLAB Support Package for Raspberry Pi Hardware
- Ros Toolbox
Install the application: Open Matlab -> Apps-> Install App -> Install MatlabGUI.mlappinstall or run MatlabGUI.mlapp in /Matlab/src folder.
Copy the two script from Raspberry folder to your Raspberry in home position.
In order to work with your setup change the ip address.
This script are called by the Matlab app and executed in the raspberry to run ros packages, if you don't want to use the app, run it by terminal.