This Repository will explain my first task in Robotics and AI department at SMART METHODS summer training.
- Control a robot arm actuator using Robot Operating System (ROS) platform with Rviz, Gazebo and Moveit Simulator.
-
Install Ubuntu to work with ROS platform. I will use Ubuntu-18.04 (You can install Ubuntu with Windows in a virtual machine like Virtual box or Vmware).
-
Instal ROS Melodic using the commands bellow in the terminal (Melodic is the version of ROS that correspond with Ubuntu-18.04).
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-get update
sudo apt install ros-melodic-desktop-full
apt search ros-melodic
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep
sudo rosdep init
rosdep update
-
Install a Catkin Workspace which is a folder to combine all packages for ROS.
sudo apt-get install ros-melodic-catkin
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
cd ~/catkin_ws/src
git clone https://github.com/smart-methods/arduino_robot_arm.git
we will use the arm from SM to work with.cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -r -y
sudo apt-get install ros-melodic-moveit
sudo apt-get install ros-melodic-joint-state-publisher ros-melodic-joint-state-publisher-gui
sudo apt-get install ros-melodic-gazebo-ros-control joint-state-publisher
sudo apt-get install ros-melodic-ros-controllers ros-melodic-ros-control
- open a file (bashrc) :
sudo nano ~/.bashrc
. - At the end of the file add the follwing line
source /home/mo7dsaleh/catkin_ws/devel/setup.bash
then press ctrl + o, (Note that mo7dsaleh is my ubuntu username). source ~/.bashrc
- To lunch the Rviz simulator with slider motors control (joint_state_publisher) use this command
roslaunch robot_arm_pkg check_motors.launch
- Rviz Simulator:
-
To control the robot arm physically if you need, connect the circuit diagram with your arm and the install Arduino IDE and ros_lib.
- Circuit Wiring:
- Install Arduino IDE software
wget https://downloads.arduino.cc/arduino-1.8.12-linux64.tar.xz
thentar -xvf arduino-1.8.12-linux64.tar.xz
thencd arduino-1.8.12/
thensudo ./install.sh
- Download rosserial to communicate with arduino using the following commands
sudo apt-get install ros-melodic-rosserial-arduino
thensudo apt-get install ros-melodic-rosserial
- Download ros_lib on arduino software using the following commands
cd Arduino/libraries
thenrm -rf ros_lib
thenrosrun rosserial_arduino make_libraries.py .
- To upload the Arduino code, select the Arduino port to be used on Ubuntu system, then we need to change the permissions (it might be ttyACM) by
ls -l /dev |grep ttyUSB
thensudo chmod -R 777 /dev/ttyUSB0
then upload the code from Arduino IDE - Run Rviz
roslaunch robot_arm_pkg check_motors.launch
rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0 _baud:=115200
-
Control the Arm in Gazebo simulator (real simulation).
- Change the permission
cd catkin/src/arduino_robot_arm/robot_arm_pkg/scripts
thensudo chmod +x joint_states_to_gazebo.py
- Open new terminal to launch Rviz
roslaunch robot_arm_pkg check_motors.launch
- Open new terminal to launch Gazebo
roslaunch robot_arm_pkg check_motors_gazebo.launch
- Then run the python script to communicate with Gazebo
rosrun robot_arm_pkg joint_states_to_gazebo.py
- Rviz with Gazebo:
- Different Angles:
- Change the permission
-
Now, lets used Moveit in Rvis which will help for kinematics, motion planning, trajectory processing and controlling the robot
roslaunch moveit_pkg demo.launch
- Moveit:
-
Task is Done 😍