ROS packages that can be used to plan and execute motion trajectories for a robot arm in simulation and real-life.
These packages were tested under ROS kinetic and Ubuntu 16.04 and it works perfectly on ROS melodic
The robot arm uses Moveit plugin to apply kinematics by the KDL solver. These packages can be tested in the gazebo simulation tool and the real robot arm, where the ROS system and Arduino code share the /joint_states
topic to control motors.
run this instruction inside your workspace:
$ rosdep install --from-paths src --ignore-src -r -y
make sure you installed all these packages:
$ sudo apt-get install ros-kinetic-moveit
$ sudo apt-get install ros-kinetic-joint-state-publisher ros-kinetic-joint-state-publisher-gui
$ sudo apt-get install ros-kinetic-gazebo-ros-control joint-state-publisher
$ sudo apt-get install ros-kinetic-ros-controllers ros-kinetic-ros-control
The robot arm has 5 joints, 4 joints to connect the arm links where the last joint for the gripper.
$ roslaunch arm_pkg check_motors.launch
You can also connect with hardware by running:
$ rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0 _baud:=115200
(Note: You may need to use ttyACM)
Run the following instructions to use gazebo
$ roslaunch arm_pkg check_motors.launch
$ roslaunch arm_pkg check_motors_gazebo.launch
$ rosrun arm_pkg joint_states_to_gazebo.py
(Note: you may need to make the python script executable by changing the permission)
$ roslaunch moveit_config_pkg demo.launch
You can also connect with hardware by running:
$ rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0 _baud:=115200
(Note: You may need to use ttyACM)
Run the following instruction to use gazebo
$ roslaunch moveit_config_pkg demo_gazebo.launch
Download webcam extension for VirtualBox
https://scribles.net/using-webcam-in-virtualbox-guest-os-on-windows-host/
Run color_thresholding.py to test the camera
Before running, find the camera index normally it is video0
$ ls -l /dev | grep video
If it is not, update line 8 in color_thresholding.py
8 cap=cv2.VideoCapture(0)
Then run
$ python color_thresholding.py
- In a terminal run
$ roslaunch moveit_config_pkg demo.launch
this will run Rviz
- connect with Arduino:
-
select the Arduino port to be used on Ubuntu system
-
change the permissions (it might be ttyACM)
$ ls -l /dev | grep ttyUSB
$ sudo chmod -R 777 /dev/ttyUSB0
-
upload the code from Arduino IDE
$ rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=115200
- In another terminal
$ rosrun moveit_config_pkg get_pose_openCV.py
This will detect blue color and publish the x,y coordinates to /direction topic
(Note: check the camera index and update the script if needed)
- Open another terminal
$ rosrun moveit_config_pkg move_group_interface
This will subscribe to /direction topic and execute motion by using Moveit move group
- In a terminal run
$ roslaunch moveit_config_pkg demo_gazebo.launch
this will run Rviz and gazebo
- In another terminal
$ rosrun moveit_config_pkg get_pose_openCV.py
This will detect blue color and publish the x,y coordinates to /direction topic
(Note: check the camera index and update the script if needed)
- Open another terminal
$ rosrun moveit_config_pkg move_group_interface
This will subscribe to /direction topic and execute motion by using Moveit move group