-
Notifications
You must be signed in to change notification settings - Fork 934
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
Fix servo trajectory point timestamping #2375
Fix servo trajectory point timestamping #2375
Conversation
…vent trajectory points being dropped due to being too old.
… trajectory points being 0.0000s in the past.
Codecov Report
@@ Coverage Diff @@
## master #2375 +/- ##
==========================================
- Coverage 56.27% 56.21% -0.06%
==========================================
Files 287 287
Lines 24450 24447 -3
==========================================
- Hits 13757 13740 -17
- Misses 10693 10707 +14
Continue to review full report at Codecov.
|
@@ -595,7 +593,6 @@ void ServoCalcs::composeJointTrajMessage(const sensor_msgs::JointState& joint_st | |||
trajectory_msgs::JointTrajectory& joint_trajectory) const | |||
{ | |||
joint_trajectory.header.frame_id = parameters_.planning_frame; |
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.
I think the same comment as well as explicitly setting the stamp to 0 would be good here:
// When a joint_trajectory_controller receives a new command, a stamp of 0 indicates "begin immediately"
// See http://wiki.ros.org/joint_trajectory_controller#Trajectory_replacement
initial_joint_trajectory->header.stamp = ros::Time(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.
Will wait to +1 until we get some related issues sorted out on a PickNik project
@@ -810,6 +807,8 @@ void ServoCalcs::suddenHalt(trajectory_msgs::JointTrajectory& joint_trajectory) | |||
joint_trajectory.points.clear(); | |||
joint_trajectory.points.emplace_back(); | |||
trajectory_msgs::JointTrajectoryPoint& point = joint_trajectory.points.front(); | |||
point.time_from_start.fromNSec(1); |
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 seems a little dangerous. Wouldn't we want to set it to 0, to ensure the joint_trajectory_controller begins stopping as soon as it receives the message? (per the same wiki section you mentioned, http://wiki.ros.org/joint_trajectory_controller#Trajectory_replacement)
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.
Oh, never mind. That's a different message field (header.stamp). I think this is fine.
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.
Please add a comment about why you did 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.
If time_from_start
is zero and the trajectory start time is also zero, then it's all zeros and that leads to warnings about points being 0 seconds in the past (and like I said in the PR description, it's a bit weird). This is a way to work around that problem. Well, actually it makes perfect sense. I added a comment about why that 1ns is added as time_from_start
.
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 is actually a weird issue but your fix is a reasonable workaround.
This PR removes trajectory point timestamping which causes warnings about trajectory points being dropped due to having old timestamps:
By removing explicit timestamping, the stamps will default to 0, meaning the trajectory execution defaults to start now. For more details, see section 2.3: http://wiki.ros.org/joint_trajectory_controller
Small time from start is added to the trajectory point generated in
suddenHalt
to prevent warnings about trajectory point being 0.0000 seconds in the past (not sure if this should be considered as a bug or not, but it is clearly a corner case).Finally, there is a tiny optimization added to the way twist command is passed to publisher from
calculateTwistCommand
function. It is not strictly related but felt too small for its own PR.