-
Notifications
You must be signed in to change notification settings - Fork 493
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
Port robot_trajectory to ROS2 #39
Port robot_trajectory to ROS2 #39
Conversation
Authored by @anasarrak
moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h
Show resolved
Hide resolved
@@ -101,11 +102,6 @@ void RobotTrajectory::append(const RobotTrajectory& source, double dt, size_t st | |||
void RobotTrajectory::reverse() | |||
{ | |||
std::reverse(waypoints_.begin(), waypoints_.end()); | |||
for (robot_state::RobotStatePtr& waypoint : waypoints_) |
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.
Why are we removing 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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How shall we proceed about 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.
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).
for (std::size_t i = 0; i < waypoints_.size(); ++i) | ||
{ | ||
if (duration_from_previous_.size() > i) | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help with this @mlautman?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if that doesn't work
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.
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?
@@ -101,11 +102,6 @@ void RobotTrajectory::append(const RobotTrajectory& source, double dt, size_t st | |||
void RobotTrajectory::reverse() | |||
{ | |||
std::reverse(waypoints_.begin(), waypoints_.end()); | |||
for (robot_state::RobotStatePtr& waypoint : waypoints_) |
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 was recently added in moveit1, yes:
https://github.com/ros-planning/moveit/pull/1335/files#diff-93f52a3b52efb75e0963646beb76dfcfR104
please restore.
moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h
Show resolved
Hide resolved
moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h
Show resolved
Hide resolved
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't time_from_start
already an rclcpp::Duration
so we can just add it directly?
for (std::size_t i = 0; i < waypoints_.size(); ++i) | ||
{ | ||
if (duration_from_previous_.size() > i) | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
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.
same
I tackled some of the issues. Please review it |
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.
Looks good! I would vote for committing my suggested change and then lgtm.
for (std::size_t i = 0; i < waypoints_.size(); ++i) | ||
{ | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Commited! ;)
Otherwise looks good! |
That seems right https://index.ros.org/doc/ros2/Contributing/Developer-Guide/#id3 Co-Authored-By: Dave Coleman <dave@picknik.ai>
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 <dave@picknik.ai>
@davetcoleman can we merge this? |
@davetcoleman friendly ping |
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.
Great!
…nitor Port Planning scene monitor
No description provided.