-
Notifications
You must be signed in to change notification settings - Fork 9
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
Set position constraints via Moveit's PositionConstraint message #51
Conversation
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.
Awesome to see! Few things I think should change in this one before we merge it.
As another optional recommendation, especially as we also seek to add orientation constraints, it might be helpful to factor out the addition of constraints to a separate function within this file.
@@ -23,6 +23,7 @@ find_package(pluginlib REQUIRED) | |||
find_package(rclcpp REQUIRED) | |||
find_package(rviz_visual_tools REQUIRED) | |||
find_package(warehouse_ros REQUIRED) | |||
find_package(shape_msgs REQUIRED) |
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.
nit: in this whole file, can you add shape_msgs
in alphabetical order?
res/ktopt_moveit_parameters.yaml
Outdated
@@ -4,6 +4,11 @@ ktopt_interface: | |||
description: "Robot description to be loaded by the internal Drake MultibodyPlant", | |||
default_value: "package://drake_models/franka_description/urdf/panda_arm_hand.urdf", | |||
} | |||
link_ee: { | |||
type: string, | |||
description: "Name of the end-effector frame as per urdf/sdf", |
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.
description: "Name of the end-effector frame as per urdf/sdf", | |
description: "Name of the end-effector frame as per urdf/srdf", |
res/ktopt_moveit_parameters.yaml
Outdated
@@ -4,6 +4,11 @@ ktopt_interface: | |||
description: "Robot description to be loaded by the internal Drake MultibodyPlant", | |||
default_value: "package://drake_models/franka_description/urdf/panda_arm_hand.urdf", | |||
} | |||
link_ee: { |
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 do we need this parameter? The constraint message itself contains a link name field and we should likely use that:
https://github.com/moveit/moveit_msgs/blob/ros2/msg/PositionConstraint.msg#L5-L6
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 put this because I did not see a panda_EE frame on the visualised robot_description on RViz. Whereas the Drake urdf has it, and the PositionConstraint requires this. I'll debug this further.
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.
Hmmm, weird. Can you use another frame that does exist in both URDFs?
Or maybe this is sufficient to have us make a local version of the Drake URDF? Worth discussing in 30 min.
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.
Per discussion, let's just use the link_name
field in the constraint message and "trust" that the planner has a URDF that knows about this frame (or errors if one is not found).
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.
Latest commit reflects this.
src/ktopt_planning_context.cpp
Outdated
// constraint_region.primitives Assuming it is a box | ||
// (shape_msgs::SolidPrimitive::BOX) and has dimensions in [x, y, z] | ||
const auto& primitive = position_constraint.constraint_region.primitives[0]; | ||
if (primitive.type == shape_msgs::msg::SolidPrimitive::BOX) |
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 prefer the reverse: If the primitive is not a box, raise a warning and continue the loop; else, carry on.
This, in addition to being more readable, will save you an indent level.
src/ktopt_planning_context.cpp
Outdated
for (int i = 0; i < 10; ++i) | ||
{ | ||
trajopt.AddPathPositionConstraint( | ||
std::make_shared<PositionConstraint>(&plant, plant.world_frame(), lower_bound, upper_bound, link_ee_frame, | ||
Eigen::Vector3d(0.0, 0.1, 0.0), &plant_context), | ||
static_cast<double>(i) / 10.0); |
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 10
here should not be hard-coded; it should be a parameter. See e.g. how the collision constraints are setup with num_collision_check_points
:
https://github.com/moveit/moveit_drake/blob/main/res/ktopt_moveit_parameters.yaml#L31
src/ktopt_planning_context.cpp
Outdated
{ | ||
trajopt.AddPathPositionConstraint( | ||
std::make_shared<PositionConstraint>(&plant, plant.world_frame(), lower_bound, upper_bound, link_ee_frame, | ||
Eigen::Vector3d(0.0, 0.1, 0.0), &plant_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.
Where does this Eigen::Vector(0.0, 0.1, 0.0)
come from for the p_BQ argument?
Based on this description:
"Constrains the position of a point Q, rigidly attached to a frame B, to be within a bounding box measured and expressed in frame A."
It then seems like we should probably use all zeros for the translation if the point we're constraining is exactly the target frame?
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.
Oops, good catch, I copied the argument list from one of my personal examples. You are right, i'll change this.
moveit_core | ||
moveit_msgs | ||
EIGEN3 | ||
shape_msgs) |
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.
Here too re: alphabetical order
res/ktopt_moveit_parameters.yaml
Outdated
@@ -4,6 +4,11 @@ ktopt_interface: | |||
description: "Robot description to be loaded by the internal Drake MultibodyPlant", | |||
default_value: "package://drake_models/franka_description/urdf/panda_arm_hand.urdf", | |||
} | |||
link_ee: { |
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.
Hmmm, weird. Can you use another frame that does exist in both URDFs?
Or maybe this is sufficient to have us make a local version of the Drake URDF? Worth discussing in 30 min.
const auto& primitive = position_constraint.constraint_region.primitives[0]; | ||
if (primitive.type != shape_msgs::msg::SolidPrimitive::BOX) | ||
{ | ||
continue; |
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.
Worth a warning here? E.g.
"Geometric primitive must be a box. Cannot add position constraint."
src/ktopt_planning_context.cpp
Outdated
Eigen::Vector3d upper_bound = box_center + Eigen::Vector3d(x_dim, y_dim, z_dim); | ||
|
||
// Add position constraint to each knot point of the trajectory | ||
for (int i = 0; i < 10; ++i) |
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.
Use the parameter here as well
// auto robot_instance = Parser(plant_, | ||
// scene_graph_).AddModelsFromString(robot_description_, ".urdf"); |
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.
weird line break, is this from an autoformatter?
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.
yup. Ill change it
This PR setsup a MoveIt PositionConstraint transcription. It achieves the following