-
Notifications
You must be signed in to change notification settings - Fork 524
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
JointGroupPositionController: Set current position as target in starting() #504
JointGroupPositionController: Set current position as target in starting() #504
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change has no dependence on #503, could you please trim the branch down to just the relevant commit to make it easier to review and merge.
LGTM, especially because this is already what's done in most other position controllers. Set cmd=pos, reset PID.
enforceJointLimits(current_positions[i], i); | ||
pid_controllers_[i].reset(); | ||
} | ||
commands_buffer_.writeFromNonRT(current_positions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
starting()
is in the RT domain, so rather than calling writeFromNonRT()
, you should write to the command buffer directly. (The realtime buffer lacks a proper writeFromRT method since it's really intended for writing from a single non-RT thread, reading from a single RT thead. I haven't worked through the accesses and how safe this aooriach is, but from these examples by people much smarter than me, it seems this is a safe solution)
Examples:
ros_controllers/position_controllers/src/joint_group_position_controller.cpp
Lines 42 to 50 in 1fd8d25
void forward_command_controller::ForwardJointGroupCommandController<T>::starting(const ros::Time& time) | |
{ | |
// Start controller with current joint positions | |
std::vector<double> & commands = *commands_buffer_.readFromRT(); | |
for(unsigned int i=0; i<joints_.size(); i++) | |
{ | |
commands[i]=joints_[i].getPosition(); | |
} | |
} |
ros_controllers/velocity_controllers/src/joint_group_velocity_controller.cpp
Lines 42 to 46 in 1fd8d25
void forward_command_controller::ForwardJointGroupCommandController<T>::starting(const ros::Time& time) | |
{ | |
// Start controller with 0.0 velocities | |
commands_buffer_.readFromRT()->assign(n_joints_, 0.0); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at this again, I think the right solution is to just use initRT()
. In practical senses, it'll be pretty much the same thing, but with less overhead and also less hackey.
I think those examples I linked should probably be updated to initRT()
as well. I'll look into that (#511).
745f2ab
to
e25a037
Compare
Thank you for the review and feedback @matthew-reynolds. I updated the PR to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me, ping @bmagyar for another set of eyes and potential merge
@bmagyar are we good to merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much appreciated guys, thank you!
…ition in starting Currently, the target position upon starting is all zeros. This is not great if a command is not issued immediately. To be safer, set the goal position to the current sensed position and also reset the PID internal state upon starting.
35ccf33
to
997e909
Compare
I've rebased this on the latest upstream which should have the CI fixed, merging when all turns green |
I still consider a diff_drive_controller failure green ;) |
Thanks for the fix @wxmerkt , merging |
Currently, the target position upon starting is all zeros. This is not great if a command is not issued immediately (and even then). To be safer, set the goal position to the current sensed position and also reset the PID internal state upon starting.
(This PR is on top of #503)