qiayuanl / legged_control

Nonlinear MPC and WBC framework for legged robot based on OCS2 and ros-controls
BSD 3-Clause "New" or "Revised" License
854 stars 217 forks source link

How to change the loop frequency of legged_controller #49

Open jn6201 opened 11 months ago

jn6201 commented 11 months ago

it seems like the update frequency is fixed to 1000 Hz, since the ros topic "_mpc_observation" is always published at 1000 Hz in the update() function of LeggedController. I tried to reset the publish rate of the customized ros_controller to 500 HZ by adding "publish_rate:500" in the controllers.yaml which can work on joint_state_controller. But cant really change the rate of legged_controller. May anyone tell me what's wrong, or how to confirm the main control loop frequency?

jn6201 commented 11 months ago

I figured out the rate setting problem, maybe we can set the whole control loop's period by adding in the gazebo plugin label in robot's urdf file `

/ legged_robot_description legged_gazebo/LeggedHWSim 0.001

` When I set it to 0.002, the publish rate turned into 500 Hz, but facing a new problem: the controller seems to be unstable, the robot couldn't hold it's position. Is it because the frequency is not enough or somewhere in the code set the frequency must be 1000 Hz?