Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify controlling models with PIDs #231

Merged

Conversation

diegoferigo
Copy link
Collaborator

core.JointControlMode_position is among the supported joint control modes we have implemented. Given a model, it can be enabled model-wise as follows:

# Enable position control
panda: scenario.bindings.gazebo.Model = world.get_model("panda").to_gazebo()
panda.set_controller_period(0.001)
panda.set_joint_control_mode(core.JointControlMode_position)

# Set a reference
joint1 = panda.get_joint("panda_joint1")
joint1.set_position_target(position=joint1_reference)

However, this was not enough. In order to insert the PIDs in the simulation, the user also had to add the JointController plugin to the model as follows:

panda.insert_model_plugin("JointController", "scenario::plugins::gazebo::JointController")

The main reason is that, similarly to custom controllers (#167), also the JointController is a plugin that runs in its own thread. This was done in this way to allow running Python code at a lower rate than the controller and the physics (by executing multiple iterations every GazeboSimulator.run).

However, this plugin insertion is quite a low-level detail, and it requires the user to downcast the scenario.bindings.core.Model object to a scenario.bindings.gazebo.Model. This PR loads the plugin automatically as soon as either Position or Velocity control modes are enabled to any of the model joints.

@diegoferigo
Copy link
Collaborator Author

cc @paolo-viceconte

@diegoferigo diegoferigo merged commit c7b507a into robotology-legacy:devel Aug 18, 2020
@diegoferigo diegoferigo deleted the feature/simplify-pid-usage branch August 18, 2020 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant