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

Port robot_trajectory to ROS2 #39

Merged
merged 9 commits into from
May 21, 2019

Conversation

vmayoral
Copy link
Contributor

No description provided.

moveit_core/robot_trajectory/CMakeLists.txt 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_)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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).

Copy link
Contributor Author

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?

Copy link
Member

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).

moveit_core/robot_trajectory/src/robot_trajectory.cpp Outdated Show resolved Hide resolved
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));
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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);

Copy link
Contributor

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

Copy link
Contributor Author

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?

moveit_core/robot_trajectory/src/robot_trajectory.cpp Outdated Show resolved Hide resolved
moveit_core/robot_trajectory/src/robot_trajectory.cpp Outdated 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_)
Copy link
Member

Choose a reason for hiding this comment

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

vmayoral added a commit to AcutronicRobotics/moveit2 that referenced this pull request Mar 30, 2019
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,
Copy link
Member

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));
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

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

same

@ahcorde
Copy link
Contributor

ahcorde commented May 6, 2019

I tackled some of the issues. Please review it

Copy link
Member

@henningkayser henningkayser left a 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));
Copy link
Member

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:

Suggested change
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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Commited! ;)

@davetcoleman
Copy link
Member

Otherwise looks good!

Víctor Mayoral Vilches and others added 2 commits May 16, 2019 23:42
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>
@ahcorde
Copy link
Contributor

ahcorde commented May 17, 2019

@davetcoleman can we merge this?

@ahcorde
Copy link
Contributor

ahcorde commented May 20, 2019

@davetcoleman friendly ping

Copy link
Member

@davetcoleman davetcoleman left a comment

Choose a reason for hiding this comment

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

Great!

@davetcoleman davetcoleman merged commit cd585ee into moveit:master May 21, 2019
JafarAbdi pushed a commit to JafarAbdi/moveit2 that referenced this pull request Oct 28, 2019
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.

None yet

6 participants