justagist / franka_ros_interface

A ROS/Python API for controlling and managing the Franka Emika Panda robot (real and simulated).
http://justagist.github.io/franka_ros_interface
Apache License 2.0
167 stars 59 forks source link

move_to_joint_positions in simulation #7

Closed guyjacob closed 4 years ago

guyjacob commented 4 years ago

First, thank you for this and the other repositories - they are incredibly useful!

Wondering about this: https://github.com/justagist/franka_ros_interface/blob/6868607855d010f22a3228dbb28e3c1cc2386e1f/franka_interface/src/franka_interface/arm.py#L657-L660

Can you elaborate on why move_to_joint_positions is not enabled in simulation? What are the roadblocks to support that?

justagist commented 4 years ago

Glad to hear that you found them useful! The method move_to_joint_positions() makes use of either the follow_joint_trajectory service or moveit service, both of which requires any one of the joint_trajectory_controller variants to be running. The position_joint_trajectory_controller is available for the real robot when using the official franka_ros package (and also franka_ros_interface), which is why the move_to_joint_positions() and the franka_moveit package works on the real robot. However, the panda_simulator package uses custom controllers (panda_sim_controllers) which imitate the other low-level controllers I have defined for the real robot in franka_ros_controllers, and does not include any joint_trajectory_controller. I was unable to incorporate a joint_trajectory_controller to the controllers for the simulator (I found that to make the joint_trajectory_controller work, I had to disable all my custom controllers). I didn't spend much time on fixing it because I only needed the other controllers to work for my purposes at the time. But if you need to use these functionalities and do not need the other low-level controllers in simulation, an alternative is to use the default controllers from the gazebo_ros_control package (apt-get install ros-$ROS_DISTRO-gazebo-ros-control). The main changes you'll have to make for using it are in the panda.transmission.xacro file in the franka_panda_description package, and the panda_sim_controllers.launch file in the panda_simulator package. (A simulator that uses only the joint_trajectory_controller can be found here: https://github.com/erdalpekel/panda_simulation. You can refer to their implementation to make the required changes if you want). But you should understand that this would disable all the custom controllers, and the simulated robot will not be fully functional with the franka_ros_interface package anymore.

However, if you are able to combine a joint_trajectory_controller with the controllers defined in panda_sim_controllers plugin in the panda_simulator, you would then be able to use all the functionalities of moveit and the follow_joint_trajectory services with the franka_ros_interface package. This would also be a great addition to the repo.

guyjacob commented 4 years ago

Thank you very much for the detailed response.

You call this in move_to_joint_positions: https://github.com/justagist/franka_ros_interface/blob/f25f0289fb59e75acdab752dde98f5a2277107ef/franka_interface/src/franka_interface/arm.py#L663

Looking at the code for set_motion_controller - it makes sure only the required controller is started and stops any others. So when you say "_I found that to make the joint_trajectory_controller work, I had to disable all my custom controllers_" - what exactly do you mean? You mean they couldn't co-exist at all in simulation - can't be loaded at the same time?

justagist commented 4 years ago

The problem is not in that code; it is that there is no joint_trajectory_controller defined for the gazebo simulation. All the controllers for the simulator are defined in panda_simulator/panda_sim_controllers as a plugin for gazebo. I was not able to load the gazebo default controllers (which has trajectory controllers) alongside my custom controllers; loading both plugins disable either one, depending on the order of loading. I am hoping to work on this at some point soon, but I am not sure when.

justagist commented 4 years ago

If you are still interested, move_to_joint_positions and other trajectory client services (JointTrajectoryActionClient in the franka_ros_interface package) should now work in the simulator as well. MoveIt! is also now supported for the ROS Melodic version. Pull the latest state of the panda_simulator (https://github.com/justagist/panda_simulator/commit/967434abf321b40ac36762ed3de93f69f9954100) and franka_ros_interface packages.

guyjacob commented 4 years ago

Thank you! Will definitely give it a try. My setup at the moment is on Kinetic. This might be a silly question, but should I expect any trouble trying to run the melodic-devel branch on Kinetic? Or should I try to port the changes to the master branch?

Thanks again.

justagist commented 4 years ago

I would expect some trouble compiling the branch in Kinetic, but I have not tested.