A demo to control two UR arms in gazebo via the "FollowJointTrajectiory" action server directly by extracting "pre-recorded" trajectories generated by MoveIt!
Gazebo simulation of two UR arms depend on the universal_robot package, for now. Thus, catkin_make from source (melodic-devel):
https://github.com/ros-industrial/universal_robot.git
For ros MongoDB core, msgs, etc:
sudo apt install ros-melodic-mongodb*
For MoveIt!:
sudo apt install ros-melodic-moveit*
Essentially are two parts to making this work.
To do this, we need to:
-
Namespace the UR arms' "FollowJointTrajectory" action server since all arms from universal robot's package are all named "arm_controller/follow_joint_trajectory".
-
Control the arms via the namespaced "FollowJointTrajectory" action server by creating a client to directly send requests.
Scripts/code involved:
-
arm_traj_controller.cpp and arm_traj_controller.hpp
-
a
arm_traj_controller
class that takes instd::string action_server_name
as an argument to create a client to send goal requests to the action server namedaction_server_name
-
Only has three main working functions. Description can be found in code's comment.
-
-
Launch files: main.launch <- two_arms.launch <- ur10_arm.launch/ur10_e_arm.launch:
-
ur10_arm.launch/ur10_e_arm.launch is your BASE launch file for launching an arm in gazebo.
-
two_arms.launch is where the namespacing happens.
-
main.launch is where an empty world is generated and the arms are spawned.
-
- To create a usable db (easy as ABC):
First, create an empty dir anywhere you like.
Then,
roslaunch mongodb_store mongodb_store.launch db_path:=<path_to_your_db_dir>
Done! you can rostopic echo to see if its up.
- Storing a "pre-generated" trajectory to the db:
First, launch a UR moveit package, you can use universal robot's default pkg:
roslaunch ur10_moveit_config demo.launch
Then, use moveit::planning_interface to plan a trajectory path then just store it to the up and running mongoDB (BE SURE IT"S UP AND RUNNING). You can refer to:
-
moveit_example.cpp (which just plans a path then stores it to the up and running mongodb)
-
mongodb_extract.cpp (which just extracts/queries the stored trajectory path by name)
Remember to compile!
catkin_make
There are three ros executables in total := moveit_example.cpp (GENERATING TRAJECTORY from moveit & STORING to DB), mongodb_extract.cpp (EXTRACTING TRAJECTORY from DB AND SENDING TO ACTION SERVER) and test.cpp (FOR TESTING SHIT for my own purposes).
Launch moveIt! & rviz in terminal A:
roslaunch ur10_moveit_config demo.launch
Then, launch your DB in terminal B:
roslaunch mongodb_store mongodb_store.launch db_path:=<path_to_your_db_dir>
Then run moveit_example.cpp in terminal C:
rosrun two_arms_sim moveit_example
You should see the arm move in Rviz and in the end, the terminal should confirm the storing of a trajectory to your DB.
Remember to close your previously opened RViz.
Launch the namespaced two arms in gazebo in terminal A:
Gazebo is paused initially, remember to unpause!
If it's not unpaused, action servers won't be up (rostopic to verify namespaced action servers)
roslaunch two_arms_sim main.launch
If you did close it previously, launch your DB in terminal B:
roslaunch mongodb_store mongodb_store.launch db_path:=<path_to_your_db_dir>
Then run mongodb_extract.cpp in terminal C:
rosrun two_arms_sim mongodb_extract
Enjoy the two arms move relentlessly as it hits the ground in sequence!
test.cpp just sends a manually scripted trajectory path to the arms' action server.
Launch the two arms in gazebo and DB in terminal A and B like before:
roslaunch two_arms_sim main.launch
roslaunch mongodb_store mongodb_store.launch db_path:=<path_to_your_db_dir>
Run the executable in Terminal C,
rosrun two_arms_sim two_arms_sim