ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Moveit RobotTrajectory time_from_start not correct

asked 2022-06-27 08:22:05 -0500

joff gravatar image


I want to find out for how long my robot will be moving on a cartesian path. For that I plan the path between two waypoints with:

(plan, fraction) = self.move_group.compute_cartesian_path(pose_waypoints, self.eef_step, self.jump_threshold)

and then look into plan by doing:

duration_in_sec = plan.joint_trajectory.points[-1].time_from_start.nsecs / 1000000

The problem is that the duration I get is wrong. I do this multiple times for multiple waypoints and add the durations together. Something of about 30 seconds comes out, but the robot needs more than 100 seconds in this example. What am I doing wrong?

Thanks for your help, ask me anything if something is unclear.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-06-27 14:26:40 -0500

saltus gravatar image

You are only accessing the nanoseconds (minor unit) property of duration, and then are actually dividing by the incorrect unit. There are 1e9 nanoseconds in a second. You are dividing by 1e6, so the "30 seconds" that you're getting is actually 30 milliseconds, or .03 seconds.

To get the total trajectory time , you can add the secs property to nsecs/1e9. Or, IIRC there is a built in method to_sec() for duration objects that you can use.

edit flag offensive delete link more


Hey saltus, thanks a lot for the answer! I also stumbled around the wrong unit, somehow I must have copied an old piece of code. You are totally right, and also the to_sec() method works very nicely. Thanks!

joff gravatar image joff  ( 2022-06-27 16:15:55 -0500 )edit

Question Tools



Asked: 2022-06-27 08:22:05 -0500

Seen: 162 times

Last updated: Jun 27 '22