-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add position control (with interpolation) to control board plugin #83
Comments
CC @traversaro |
Looking at the code implementing @traversaro do you suggest to port this class as-is (updating only the calls to gazebo APIs) or there is some modification you have in mind? |
Yes, I think we can copy directly the class, we can leave future evolutions in the future. |
Note: the default trajectory generation type is minimum jerk. https://github.com/robotology/gazebo-yarp-plugins/blob/cb3521f7543a5a07e2a65a82dedd2eb2ec2cea12/plugins/controlboard/src/ControlBoardDriver.cpp#L131-L155 |
Note: a single generation type can be specified for all joints: https://github.com/robotology/gazebo-yarp-plugins/blob/cb3521f7543a5a07e2a65a82dedd2eb2ec2cea12/plugins/controlboard/src/ControlBoardDriver.cpp#L136-L144 |
I needed to modify the Here is an example for the minimum jerk generator: https://github.com/robotology/gazebo-yarp-plugins/blob/cb3521f7543a5a07e2a65a82dedd2eb2ec2cea12/plugins/controlboard/src/ControlBoardDriverTrajectory.cpp#L207-L208 Now the data about simulation time is passed to the system plugin interfaces like the I'm thinking about how to arrange the flow of the simulation period to trajectory generators. @traversaro the simulation period in Gazebo can change at each iteration? i.e. there is the possibility to use variable step solvers? |
In theory yes, in practice I guess we can stick to the simple case for now of assuming that the update period is constant. In any case it probably make sense to decouple the trajectory sampling time (that should be coupled to the control period) from the simulation step time. The control period should be fixed and should not depend on from the simulation step time. |
In particular, I am not sure how I missed this, but what I mean is that the PID should not run at every simulation step (as done in https://github.com/robotology/gz-sim-yarp-plugins/blob/main/plugins/controlboard/src/ControlBoard.cpp#L359), but instead we should have an independent sampling, and check if it needs to run again given the simulation time. Something like: void ControlBoard::PreUpdate(const UpdateInfo& _info, EntityComponentManager& _ecm)
{
// The class should have a m_controlUpdatePeriod attribute, parsed from config files
// and with a reasonable default (like 1ms)
// There should also be an attribute called m_lastControlUpdateInstant to capture the
// last time the update have been run (and should be reset)
if (_info.simTime-m_lastControlUpdateInstant > m_controlUpdatePeriod)
{
auto dt = _info.simTime-m_lastControlUpdateInstant;
if (!updateReferences(_info, _ecm, dt))
{
yError() << "Error while updating control references";
}
m_lastControlUpdateInstant = _info.simTime;
}
} |
See also robotology/gazebo-yarp-plugins#69 for the related bug on gazebo-yarp-plugins side. |
Interestingly, probably it could also make sense to only sample sensors measurements when the control loop is running, effectively subsampling the output of the simulator. By the way, this is similar to what we discussed yesterday with @DavideBarbone and @Gio-DS . |
Thank you @traversaro, now it's clear! while porting huge code portions and refactoring them is difficult to understand which are the specifications that the new plugin should maintain. I will try to be more verbose when reviewing the gazebo-yarp-plugins to try not to skip this kind of requirements. |
I opened:
|
Yes, in this particular case it was quite difficult as the old logic was "wrong" in a sense. |
While porting the I did not find any reference to the |
Also I've noted that some variables are rest only in the if branch in which the initial configuration is found, but they are not reset when using the actual positions. Is this wanted? It is not done since it is assumed that the trajectory generator reference positions are already equal to the actual joint position? |
I guess this worked just as the initial position of both without configuration file is 0. However, better to explicitly reset them, as this could one of the source of problems that people have in resets, fyi @rob-mau @S-Dafarra . |
Udpate: I should have ported the needed functionality to make the position control work with the single pendulum. Now I'm facing an issue when trying to control the single pendulum model with the yarpmotorgui, since when I launch it and try to change the reference position the yarpmotorgui and gazebo freeze and I have to kill them, most probably a deadlock condition. 2024-02-29_11-04-00.mp4 |
Fixed in ca3778f |
This is one of the first working demos: 2024-02-29_14-11-32.mp4I still have to test that the trajectory generation works with every type of generator and test different configurations and defaults. |
With 5528c12 I've added a simple unit test: I set a reference position and run the simulation (at batches of 1000 steps) until Here's a video of the test running: 2024-03-01_12-15-50.mp4In this case I'm using the default settings for the trajectory generation (min jerk trajectory with reference speed of |
We want to add a position control mode to the control board plugin, corresponding to the same control mode present in gazebo-yarp-plugins.
Acceptance criteria:
checkMotionDone
returns true the actual joint position is close to the reference oneinitialConfiguration
configuration parameter in .ini fileThe text was updated successfully, but these errors were encountered: