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

Add optional state publishing to PID controller #37

Closed

Conversation

paulbovbel
Copy link

Also a minor change to computeCommand calls, to chain the two implementations rather than replicate code.

@adolfo-rt
Copy link
Member

Per-changeset comments:

  • 6dabd8f: In control_msgs there exists the JointControllerState, which is used in ros_controllers along with the control_toolbox::Pid class (example). If possible, my suggestion would be to leverage this existing message type. Also, if you prefer to incorporate the PID state publishing inside the control_toolbox::Pid class, it would be desirable to also propagate this change to the few other controllers that use it.
  • d68c920: Great to reduce code duplication!. I would suggest to make this a separate PR, as it's orthogonal to the above changeset.
  • 31dd5e5: What's wrong with the newline at the end of the file?. This is a good UNIX practice.

@paulbovbel
Copy link
Author

6dabd8f: Thanks for pointing out that message, didn't spot it before. I'm a little skeptical of using it, since the PID library wouldn't always be used to control a joint, so the message name would be a little deceptive. It seems that in ROS the pattern is to create per-application message types for clarity. Additionally, from inside the controller I don't have access to the setpoint (only the error), so I can't fill that field.

I could move the PID message to control_msgs if you'd be amenable to that?

@paulbovbel
Copy link
Author

Also, the JointStateController message doesn't include the three terms (p_term, i_term, d_term), which are the helpful bits for tuning a controller.

@adolfo-rt
Copy link
Member

I get that the JointControllerState name might be misleading, if you're using a PID to control a non-joint plant. I find it sensible to have a more generally named PidState message. There is in fact nothing joint-specific in the JointControllerState spec, and it kind of makes the assumptions that joint controllers are PID-based, which in general is not true.

I find the message type you propose less informative than JointControllerState. I get that the setpoint is not available from within the PID class, but if we're to propose a new message type, I'd really want it to convey as much useful information as possible.

Also, it would be best if new messages made it to control_msgs, and not to control_toolbox. The former has much lighter dependencies, and are all message related; while the latter brings more (and non-message related) dependencies.

@paulbovbel
Copy link
Author

Sounds good on all points. Any proposals for what additional information you'd like to see in the PidState message?

@paulbovbel
Copy link
Author

Moved message to control_msgs, depends on ros-controls/control_msgs#14

@paulbovbel
Copy link
Author

Depends on #44 or #42

@paulbovbel
Copy link
Author

Updated with ros-controls/control_msgs#14, other dependencies met, ping for review.

@adolfo-rt
Copy link
Member

Please rebase now that #46 has been merged, and we preserved the implementation in computeCommand.

Also, please make two commits: One with the style change, and another one with the enhancement.

@paulbovbel
Copy link
Author

Ping for review. No style change here.

// Publish controller state if configured
if (publish_state_ && state_publisher_.trylock())
{
state_publisher_.msg_.header.stamp = ros::Time::now();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I realize just now that under certain RTOSes, like Xenomai 2.6.X, ros::Time::now is a no-no, as there's a Linux system call involved.

Since state publishing is optional and comes disabled by default, I think your proposal is an acceptable compromise.

Could you please document the publish_state parameter here, and mention that if enabled, it may break real-time guarantees on certain RTOS?. I think that with this, the PR can be merged.

@paulbovbel
Copy link
Author

@adolfo-rt, added the documentation, thanks

@bmagyar
Copy link
Member

bmagyar commented Apr 15, 2016

Could you update this please?

@paulbovbel
Copy link
Author

Rebased on kinetic-devel

@bmagyar
Copy link
Member

bmagyar commented May 3, 2016

Unfortunately you have to open a new PR pointing to kinetic-devel, github is rigid on the "from-to" relations of PRs, cannot edit this one...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants