Repository navigation
Port robot_trajectory to ROS2 - #39
Conversation
Authored by @anasarrak
| void RobotTrajectory::reverse() | ||
| { | ||
| std::reverse(waypoints_.begin(), waypoints_.end()); | ||
| for (robot_state::RobotStatePtr& waypoint : waypoints_) |
There was a problem hiding this comment.
Why are we removing this?
There was a problem hiding this comment.
@anasarrak I don't quite recall having removed this on purpose. Does something come to mind for you? @mlautman maybe this is the result of syncing with moveit1?
There was a problem hiding this comment.
This was recently added in moveit1, yes:
https://github.com/ros-planning/moveit/pull/1335/files#diff-93f52a3b52efb75e0963646beb76dfcfR104
please restore.
There was a problem hiding this comment.
@davetcoleman, not sure where this is coming from but reverting this as you pointed causes yet more problems when compiling:
/usr/local/include/octomap/OccupancyOcTreeBase.hxx:116:108: warning: unused parameter 'maxrange' [-Wunused-parameter]
void OccupancyOcTreeBase<NODE>::insertPointCloudRays(const Pointcloud& pc, const point3d& origin, double maxrange, bool lazy_eval) {
^
/Users/victor/ros2_moveit_ws/src/moveit2/moveit_core/robot_trajectory/src/robot_trajectory.cpp:108:15: error: no member named 'invertVelocity' in 'moveit::core::RobotState'
waypoint->invertVelocity();
~~~~~~~~ ^I'd suggest we finalize the ROS 2 porting and then we rebase things with respect MoveIt! (1).
There was a problem hiding this comment.
How shall we proceed about this?
There was a problem hiding this comment.
The issue here is that invertVelocity() has not yet been synced to the PRs base branch but the current master branch has this function (https://github.com/ros-planning/moveit2/pull/59/files#diff-15d4dc0e9e1eee143f7576803dfe8ea2L441). Did you try compiling these changes after a rebase to master? Actually it's the same problem as in PR #59 where invertVelocity() was accidently removed from the feature branch (https://github.com/ros-planning/moveit2/pull/59/files#diff-15d4dc0e9e1eee143f7576803dfe8ea2L441).
| total_time += duration_from_previous_[i]; | ||
|
|
||
| int seconds = (int)total_time; | ||
| dur_total = rclcpp::Duration((int32_t)seconds, (int32_t)((total_time-seconds)*1.0e+9)); |
There was a problem hiding this comment.
Would it be better to define a method for converting from a double to rclcpp::Duration? This logic takes a minute to process in context.
There was a problem hiding this comment.
One option would be to pass in the total nanoseconds as a rcl_duration_value_t which is really just an int64_t.
There was a problem hiding this comment.
I believe that all you would need is:
#include "rcl/time.h"
rclcpp::Duration time(static_cast<rcl_duration_value_t>time_in_nanoseconds);Although given that rcl_duration_value_t is an int64_t
# From rcl/time.h and rcutils/time.h
typedef int64_t rcutils_duration_value_t;
typedef rcutils_duration_value_t rcl_duration_value_t;you should be able to simply do:
rclcpp::Duration time(static_cast<int64_t>time_in_nanoseconds);There was a problem hiding this comment.
Let me know if that doesn't work
There was a problem hiding this comment.
Hello @mlautman, tried your recommendations but failed miserably and didn't manage to get it compiling. Maybe I simply didn't understood what you meant?
Can you please make a code suggestion that compiles?
| void RobotTrajectory::reverse() | ||
| { | ||
| std::reverse(waypoints_.begin(), waypoints_.end()); | ||
| for (robot_state::RobotStatePtr& waypoint : waypoints_) |
There was a problem hiding this comment.
This was recently added in moveit1, yes:
https://github.com/ros-planning/moveit/pull/1335/files#diff-93f52a3b52efb75e0963646beb76dfcfR104
please restore.
Misalignment when merging things with moveit1 moveit#39 (comment)
| for (std::size_t i = 0; i < state_count; ++i) | ||
| { | ||
| this_time_stamp = trajectory.header.stamp + trajectory.points[i].time_from_start; | ||
| this_time_stamp = trajStamp + rclcpp::Duration(trajectory.points[i].time_from_start.sec, |
There was a problem hiding this comment.
Isn't time_from_start already an rclcpp::Duration so we can just add it directly?
| total_time += duration_from_previous_[i]; | ||
|
|
||
| int seconds = static_cast<int>(total_time); | ||
| dur_total = rclcpp::Duration((int32_t)seconds, (int32_t)((total_time - seconds) * 1.0e+9)); |
There was a problem hiding this comment.
Maybe just a nit, but here we could also just create a rclcpp::Duration() of 1 second and multiply it with total_time.
| this_time_stamp = | ||
| trajectory.joint_trajectory.header.stamp + trajectory.joint_trajectory.points[i].time_from_start; | ||
| this_time_stamp = rclcpp::Time(trajectory.joint_trajectory.header.stamp) + | ||
| rclcpp::Duration(trajectory.joint_trajectory.points[i].time_from_start.sec, |
There was a problem hiding this comment.
Just add stamp and time_from_start directly?
| this_time_stamp = trajectory.multi_dof_joint_trajectory.header.stamp + | ||
| trajectory.multi_dof_joint_trajectory.points[i].time_from_start; | ||
| this_time_stamp = rclcpp::Time(trajectory.multi_dof_joint_trajectory.header.stamp) + | ||
| rclcpp::Duration(trajectory.multi_dof_joint_trajectory.points[i].time_from_start.sec, |
|
I tackled some of the issues. Please review it |
henningkayser
left a comment
There was a problem hiding this comment.
Looks good! I would vote for committing my suggested change and then lgtm.
| if (duration_from_previous_.size() > i) | ||
| total_time += duration_from_previous_[i]; | ||
|
|
||
| dur_total = rclcpp::Duration(static_cast<int64_t>(total_time*1e+9)); |
There was a problem hiding this comment.
I meant something like this:
| dur_total = rclcpp::Duration(static_cast<int64_t>(total_time*1e+9)); | |
| dur_total = rclcpp::Duration(1, 0) * total_time; |
I still think it's odd that rclcpp::Time and rclcpp::Duration don't have double constructors but to me this version would be more readable.
|
Otherwise looks good! |
Accepting as well. To take into account https://index.ros.org/doc/ros2/Contributing/Developer-Guide/#id3 for future reference Co-Authored-By: Dave Coleman <[email protected]>
|
@davetcoleman can we merge this? |
|
@davetcoleman friendly ping |
…nitor Port Planning scene monitor
No description provided.