Skip to content

validate multi-dof trajectories before execution#713

Merged
davetcoleman merged 2 commits intomoveit:kinetic-develfrom
ubi-agni:validate-multi-dof-traj
Jan 18, 2018
Merged

validate multi-dof trajectories before execution#713
davetcoleman merged 2 commits intomoveit:kinetic-develfrom
ubi-agni:validate-multi-dof-traj

Conversation

@rhaschke
Copy link
Copy Markdown
Contributor

@rhaschke rhaschke commented Dec 7, 2017

This is a follow up on #691, actually implementing the missing functionality.
@TroyCordie could you please test this patch on your setup?

@TroyCordie
Copy link
Copy Markdown
Contributor

I will give it a run early next week

@rhaschke rhaschke force-pushed the validate-multi-dof-traj branch from 3529272 to 33afea5 Compare December 7, 2017 22:57
@TroyCordie
Copy link
Copy Markdown
Contributor

sorry rhaschke I have check this and I thought I had replied.

if (!trajectory.joint_trajectory.points.empty())
{
// There is nothing to check
continue;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i prefer this style of breaking early (in this case with continue) rather than wrap all the functionality with increasing depths of indentation. why did you change it? it makes the PR harder to review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having both, single-dof and multi-dof joint trajectories, we cannot simply break out anymore. We have to check for both trajectory types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ack

const std::vector<geometry_msgs::Transform>& transforms =
trajectory.multi_dof_joint_trajectory.points.front().transforms;
const std::vector<std::string>& joint_names = trajectory.joint_trajectory.joint_names;
const std::size_t n = joint_names.size();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't use one letter variable names - how about num_joints? I think it would actually be cleaner to use joint_names.size() throughout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was called n before... Using joint_names.size() is an extra function call each time.

Copy link
Copy Markdown
Member

@bmagyar bmagyar Jan 17, 2018

Choose a reason for hiding this comment

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

It happens often that when we add new features or fixes to MoveIt we ask the contributor or assigned maintainer to touch up that part of the code. I also think that there's no need to put the size value into a temporary variable.

Calling a function like this won't have any measurable overhead. After a quick look at the code I could only find 2 occurences of this n being used.

The same temporary variable trick is done 2 times in this function, make sure however you decide to address this you handle both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I handled both of them ;-)

ROS_ERROR_STREAM_NAMED("traj_execution", "Unknown joint in trajectory: " << joint_names[i]);
return false;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add comment to this section describing process being taken

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK.

if ((offset.array() > allowed_start_tolerance_).any() || rotation.angle() > allowed_start_tolerance_)
{
ROS_ERROR_STREAM_NAMED("traj_execution",
"\nInvalid Trajectory: start point deviates from current robot state more than "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clarify this error is coming from the new Multi DOF Traj checks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK.

}

for (std::size_t i = 0; i < n; ++i)
for (std::size_t i = 0, end = joint_names.size(); i < end; ++i)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is end defined? Is this some C++ magic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just right after i=0 in the for loop's init condition. No magic there ;-)

@davetcoleman davetcoleman merged commit ad44e15 into moveit:kinetic-devel Jan 18, 2018
@rhaschke rhaschke deleted the validate-multi-dof-traj branch January 24, 2018 07:37
JafarAbdi pushed a commit to JafarAbdi/moveit that referenced this pull request Mar 24, 2022
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.

4 participants