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

improve [get|set]JointValueTarget in python wrapper #858

Merged
merged 7 commits into from
Mar 19, 2019

Conversation

rhaschke
Copy link
Contributor

As pointed out in #845, the signature and semantics of getJointValueTarget() doesn't match the one of the corresponding setter, which renders both functions rather useless. As I pointed out in #845 (comment) a proper solution of this issue, should consider:

  • Add a new method MoveGroupInterface::getJointValueTarget(std::vector<double>&) that matches the corresponding setJointValueTarget(const std::vector<double>&) method and should use RobotState::copyJointGroupPositions(const JointModelGroup*, std::vector<double>&) to do so.
  • Depreacate the old method MoveGroupInterface::getJointValueTarget()
    (currently returning the full RobotState) and
  • Instead add a better-named method MoveGroupInterface::getJointStateTarget() to correctly reflect the semantics of returning the full robot state.
  • To make the difference even clearer, one could think about renaming the getter to getTargetRobotState(), both in MoveGroupInterface and MoveGroupInterfaceImpl.
  • Deprecate the dangerous functions setJointValueTarget(const robot_state::RobotState&) and setJointValueTarget(const sensor_msgs::JointState&), which allow to set joint values that are not member of the JointModelGroup.

This PR considers all of them as well as a sanity check in some other joint setters.

@rhaschke
Copy link
Contributor Author

@willcbaker Please review.

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.

This has been on pause for some time.
I think your changes really make sense, I'm just a little hesitant to make those setJointValueTarget() functions deprecated right away since they are really convenient and could be 'fixed' easily.

@@ -400,7 +399,7 @@ class MoveGroupInterface

If these values are out of bounds then false is returned BUT THE VALUES
ARE STILL SET AS THE GOAL. */
bool setJointValueTarget(const sensor_msgs::JointState& state);
MOVEIT_DEPRECATED bool setJointValueTarget(const sensor_msgs::JointState& state);
Copy link
Member

Choose a reason for hiding this comment

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

Why not just change the implementation to match setJointValueTarget(const std::map<std::string, double>& variable_values)? It would probably make sense to use a setJointValueTarget(const std::vector<std::string>& variable_names, const std::vector<double>& variable_names) for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already a setJointValueTarget(const std::map<std::string, double>& variable_values).
I'm not sure about your intention.

Copy link
Member

Choose a reason for hiding this comment

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

My intention is to keep support for setting target states from robot trajectory waypoints directly (from both message and class types). I don't get why setJointValueTarget(const sensor_msgs::JointState& state) should be deprecated only because there can be joints that are not member of the group. IMO this function should just ignore non-member joints just like setJointValueTarget(const std::map<std::string, double>& variable_values) does.
Alternatively I would suggest adding a setJointValueTarget(const std::vector<std::string>& variable_names, const std::vector<double>& variable_names) function that is more convenient to use than the map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My intention is to keep support for setting target states from robot trajectory waypoints directly

Makes sense. Please feel free to augment to this PR branch.

@@ -362,7 +361,7 @@ class MoveGroupInterface

If these values are out of bounds then false is returned BUT THE VALUES
ARE STILL SET AS THE GOAL. */
bool setJointValueTarget(const robot_state::RobotState& robot_state);
MOVEIT_DEPRECATED bool setJointValueTarget(const robot_state::RobotState& robot_state);
Copy link
Member

Choose a reason for hiding this comment

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

I agree that these functions should not set any positions other than those inside the corresponding joint model group.
Rather than making these deprecated I would really prefer changing the implementation to just use RobotState::copyJointGroupPositions() or RobotState::getVariablePositions() selectively.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I my opinion, the RobotState shouldn't be exposed by move-group methods.

Copy link
Member

Choose a reason for hiding this comment

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

In that case setStartState(robot_state::RobotState) should be deprecated as well. But does this really improve usability?

Copy link
Contributor Author

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

@willcbaker
Copy link
Contributor

Iirc I had added robotstate python bindings a while back to expose the robot state methods as at the time it was one of the only ways to get the current full state of the robot and set multidof joint goals.

@henningkayser
Copy link
Member

Iirc I had added robotstate python bindings a while back to expose the robot state methods as at the time it was one of the only ways to get the current full state of the robot and set multidof joint goals.

@willcbaker so you agree with this changes or not?
@rhaschke could you fix CI so we can get this merged?

@willcbaker
Copy link
Contributor

I haven't had much time to play around with this yet, but it from what I can tell by reading:

RE: The get target robot state being protected:

  • The set_start_state is difficult to use (in general). And to @henningkayser 's point improve [get|set]JointValueTarget in python wrapper #858 (comment) this does not increase usability. The public method was used to retrieve potential future robot states and nicely complemented this function.
    I had in the past been using this method in the python wrapper as a way to concatenate plans together to make the robot do complex behaviors, e.g.
group.set_joint_value_target(x0,x1,..xn)
plan  = group.plan()
next_start_state = function_to_extract_robot_state_from_trajectory(plan)
group.set_start_state(next_start_state)
group.set_joint_value_target(y0,y1,..yn)
plan2 = group.plan()
complete_plan = function_to_concatenate_plans(plan, plan2)
group.execute(complete_plan)

I had also been using the robot state functions to create robot markers from robot state messages, I'm sure there are other ways to do this, but it was a nice to have at this level. (was heading down a route for more interactive planning other than the rviz gui, future work to come!)

RE: Deprecating robot state joint value setter:

  • can we confirm we can set multi dof joints via the setJointValue target?

@henningkayser
Copy link
Member

@willcbaker Your described behavior would still be possible if the robot state is removed from the interface. You just have to pass the joint states instead of the full RobotState message. Also the waypoint from a RobotTrajectory message returned from plan() would have to be converted either way.

can we confirm we can set multi dof joints via the setJointValue target?

I think this wouldn't be possible anymore. But what is the use case for this? To my knowledge it's not possible to plan for different multi-dof joint poses via the MoveGroupInterface.

@rhaschke rhaschke changed the base branch from kinetic-devel to master March 19, 2019 10:18
@rhaschke
Copy link
Contributor Author

I rebased and targeted this PR against master. As setJointValueTarget(RobotState) is still used in the rviz plugin (as pointed out by the Travis warning), I suggest to revert the deprecation of this function as well, but not expose it in the Python interface anymore, i.e. remove set_state_value_target.

@henningkayser henningkayser merged commit c6e8df9 into moveit:master Mar 19, 2019
@henningkayser
Copy link
Member

@rhaschke do you want this to be cherry-picked into other branches as well?

@rhaschke
Copy link
Contributor Author

As this changes API, I wouldn't backport this to any other branch. @henningkayser, thanks for merging.

@rhaschke rhaschke deleted the python-wrapper branch March 19, 2019 16:55
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

4 participants