justagist / panda_simulator

A Gazebo simulator for the Franka Emika Panda robot with ROS interface, supporting sim-to-real code transfer (Python). Exposes customisable controllers and state feedback from robot in simulation.
Apache License 2.0
188 stars 58 forks source link

how to transfer the controller from sim to real. #32

Closed RanCao2018 closed 3 years ago

RanCao2018 commented 3 years ago

Hi, thanks for your work. I have a question about how to transfer the controller from sim to real. Can I directly use the controller designed in "panda simulator" to drive Franka robot in reality? For example, I change the script "task_space_control_with_fri.py" as an impedance controller, and it works in the simulator. Can I directly copy it and paste in "franka_ros_interface/franka_ros_controllers/scripts/test" , and run it as "test_controller.py"?

justagist commented 3 years ago

Hi, The code and all methods should work directly on the real robot once you run "interface.launch" of the franka_ros_interface package, but you have to be careful with parameters such as the controller gains, control loop rate, etc. These values may not be the same for sim and real. I would suggest you test your code with a simple motion first (or even zero motion) on the real robot to find a reasonable set of control parameters. Then you can improve from there. You may also find that you have to run the control loop at a higher frequency to get smooth motion.

Just as an aside, for my experiments, I run the control loop in one machine as a node that subscribes to a topic listening for the goal values. A second node publishes the trajectory points as required from another machine where all my other computations are done (I have some learning, planning etc. algorithms running on this machine). The control loop runs on the first machine alone at a high frequency ensuring that control commands to the robot are sent without additional delay.

P.S. You don't have to copy the file to the package. You can leave it anywhere (as long as you have sourced your catkin workspace) and run it as python [file_name].

Hope this helps. -- Saif