42 namespace bind_planning_component
45 plan(std::shared_ptr<moveit_cpp::PlanningComponent>& planning_component,
46 std::shared_ptr<moveit_cpp::PlanningComponent::PlanRequestParameters>& parameters)
51 std::shared_ptr<const moveit_cpp::PlanningComponent::PlanRequestParameters> const_single_plan_parameters =
52 std::const_pointer_cast<const moveit_cpp::PlanningComponent::PlanRequestParameters>(parameters);
54 return planning_component->plan(*const_single_plan_parameters);
56 return planning_component->plan();
59 bool setGoal(std::shared_ptr<moveit_cpp::PlanningComponent>& planning_component,
60 std::optional<std::string> configuration_name, std::optional<moveit::core::RobotState> robot_state,
61 std::optional<geometry_msgs::msg::PoseStamped> pose_stamped_msg, std::optional<std::string> pose_link,
62 std::optional<std::vector<moveit_msgs::msg::Constraints>> motion_plan_constraints)
65 if (configuration_name && robot_state)
67 throw std::invalid_argument(
"Cannot specify both configuration name and robot state");
69 else if (configuration_name && pose_stamped_msg)
71 throw std::invalid_argument(
"Cannot specify both configuration name and pose msg");
73 else if (configuration_name && motion_plan_constraints)
75 throw std::invalid_argument(
"Cannot specify both configuration name and motion plan constraints");
77 else if (robot_state && pose_stamped_msg)
79 throw std::invalid_argument(
"Cannot specify both robot state and pose msg");
81 else if (robot_state && motion_plan_constraints)
83 throw std::invalid_argument(
"Cannot specify both robot state and motion plan constraints");
85 else if (pose_stamped_msg && motion_plan_constraints)
87 throw std::invalid_argument(
"Cannot specify both pose goal and motion plan constraints");
89 else if ((pose_stamped_msg && !pose_link) || (!pose_stamped_msg && pose_link))
91 throw std::invalid_argument(
"Must specify both message and corresponding link");
95 if (!configuration_name && !robot_state && !pose_stamped_msg && !pose_link && !motion_plan_constraints)
97 throw std::invalid_argument(
"Must specify at least one argument");
101 if (configuration_name)
103 return planning_component->setGoal(*configuration_name);
106 else if (robot_state)
108 return planning_component->setGoal(*robot_state);
111 else if (pose_stamped_msg && pose_link)
113 return planning_component->setGoal(*pose_stamped_msg, *pose_link);
118 return planning_component->setGoal(*motion_plan_constraints);
122 bool setStartState(std::shared_ptr<moveit_cpp::PlanningComponent>& planning_component,
123 std::optional<std::string> configuration_name, std::optional<moveit::core::RobotState> robot_state)
126 if (configuration_name && robot_state)
128 throw std::invalid_argument(
"Cannot specify both configuration name and robot state");
132 if (!configuration_name && !robot_state)
134 throw std::invalid_argument(
"Must specify at least one argument");
138 if (configuration_name)
140 return planning_component->setStartState(*configuration_name);
145 return planning_component->setStartState(*robot_state);
149 moveit_msgs::msg::RobotState
152 moveit_msgs::msg::RobotState robot_state_msg = plan_solution->start_state;
153 return robot_state_msg;
156 moveit_msgs::msg::MoveItErrorCodes
159 moveit_msgs::msg::MoveItErrorCodes error_code_msg =
160 static_cast<moveit_msgs::msg::MoveItErrorCodes
>(plan_solution->error_code);
161 return error_code_msg;
164 std::shared_ptr<robot_trajectory::RobotTrajectory>
167 return plan_solution->trajectory;
173 std::shared_ptr<moveit_cpp::PlanningComponent::PlanRequestParameters>>(m,
"PlanRequestParameters",
175 Planner parameters provided with a MotionPlanRequest.
177 .def(py::init([](std::shared_ptr<moveit_cpp::MoveItCpp>& moveit_cpp) {
178 const rclcpp::Node::SharedPtr& node =
moveit_cpp->getNode();
185 str: The planner id to use.
189 str: The planning pipeline to use.
193 int: The number of planning attempts to make.
197 float: The amount of time to spend planning.
199 .def_readwrite("max_velocity_scaling_factor",
202 float: The maximum velocity scaling factor that can be used.
204 .def_readwrite("max_acceleration_scaling_factor",
207 float: The maximum scaling factor that can be used.
213 py::class_<moveit_cpp::PlanningComponent, std::shared_ptr<moveit_cpp::PlanningComponent>>(m,
"PlanningComponent",
215 Represents a joint model group and motion plans corresponding to this joint model group.
218 .def(py::init<const std::string&,
const std::shared_ptr<moveit_cpp::MoveItCpp>&>(),
219 py::arg(
"joint_model_group_name"), py::arg(
"moveit_py_instance"),
221 Constructs a PlanningComponent instance.
224 joint_model_group_name (str): The name of the joint model group to plan for.
225 moveit_py_instance (:py:class:`moveit_py.core.MoveItPy`): The MoveItPy instance to use.
230 dict: The joint values for targets specified by name.
235 str: The name of the planning group to plan for.
240 list of str: The names of the named robot states available as targets.
246 Set the start state of the plan to the current state of the robot.
250 py::arg(
"configuration_name") =
nullptr, py::arg(
"robot_state") =
nullptr,
252 Set the start state of the plan to the given robot state.
255 configuration_name (str): The name of the configuration to use as the start state.
256 robot_state (:py:class:`moveit_msgs.msg.RobotState`): The robot state to use as the start state.
260 py::return_value_policy::reference_internal,
262 Returns the current start state for the planning component.
266 .def(
"set_goal_state",
267 py::overload_cast<std::shared_ptr<moveit_cpp::PlanningComponent>&, std::optional<std::string>,
268 std::optional<moveit::core::RobotState>, std::optional<geometry_msgs::msg::PoseStamped>,
269 std::optional<std::string>, std::optional<std::vector<moveit_msgs::msg::Constraints>>>(
271 py::arg(
"configuration_name") =
nullptr, py::arg(
"robot_state") =
nullptr,
272 py::arg(
"pose_stamped_msg") =
nullptr, py::arg(
"pose_link") =
nullptr,
273 py::arg(
"motion_plan_constraints") =
nullptr,
275 Set the goal state for the planning component.
278 configuration_name (str): The name of the configuration to set the goal to.
279 robot_state (moveit_py.core.RobotState): The state to set the goal to.
280 pose_stamped_msg (geometry_msgs.msg.PoseStamped): A PoseStamped ros message.
281 pose_link (str): The name of the link for which the pose constraint is specified.
282 motion_plan_constraints (list): The motion plan constraints to set the goal to.
289 py::return_value_policy::move,
291 Plan a motion plan using the current start and goal states.
294 plan_parameters (moveit_py.core.PlanParameters): The parameters to use for planning.
298 py::return_value_policy::move,
300 Set the path constraints generated from a moveit msg Constraints.
303 path_constraints (moveit_msgs.msg.Constraints): The path constraints.
308 py::arg(
"min_z"), py::arg(
"max_x"), py::arg(
"max_y"), py::arg(
"max_z"),
310 Specify the workspace bounding box. The box is specified in the planning frame (i.e. relative to the robot root link start position). The workspace applies only to the root joint of a mobile robot (driving base, quadrotor) and does not limit the workspace of a robot arm.
313 min_x (float): The minimum x value of the workspace.
314 min_y (float): The minimum y value of the workspace.
315 min_z (float): The minimum z value of the workspace.
316 max_x (float): The maximum x value of the workspace.
317 max_y (float): The maximum y value of the workspace.
318 max_z (float): The maximum z value of the workspace.
323 Remove the workspace bounding box from planning.
328 py::class_<moveit_cpp::PlanningComponent::PlanSolution, moveit_cpp::PlanningComponent::PlanSolutionPtr>(
329 m,
"PlanSolution", R
"(
330 Represents a planning solution, including the trajectory and any error codes.)")
332 py::return_value_policy::copy,
"The starting state used for planning.")
334 py::return_value_policy::copy,
"The resulting planned trajectory.")
336 py::return_value_policy::copy,
"The MoveIt error code of the planning request.")
339 "Return True if planning was successful.");
void setStartStateToCurrentState()
Set the start state for planning to be the current state of the robot.
std::map< std::string, double > getNamedTargetStateValues(const std::string &name)
Get the joint values for targets specified by name.
void unsetWorkspace()
Remove the workspace bounding box from planning.
const std::string & getPlanningGroupName() const
Get the name of the planning group.
void setWorkspace(double minx, double miny, double minz, double maxx, double maxy, double maxz)
Specify the workspace bounding box. The box is specified in the planning frame (i....
bool setPathConstraints(const moveit_msgs::msg::Constraints &path_constraints)
Set the path constraints generated from a moveit msg Constraints.
const std::vector< std::string > getNamedTargetStates()
Get the names of the named robot states available as targets.
moveit::core::RobotStatePtr getStartState()
Get the considered start state if defined, otherwise get the current state.
std::shared_ptr< robot_trajectory::RobotTrajectory > getMotionPlanSolutionTrajectory(std::shared_ptr< moveit_cpp::PlanningComponent::PlanSolution > &plan_solution)
moveit_cpp::PlanningComponent::PlanSolution plan(std::shared_ptr< moveit_cpp::PlanningComponent > &planning_component, std::shared_ptr< moveit_cpp::PlanningComponent::PlanRequestParameters > ¶meters)
moveit_msgs::msg::MoveItErrorCodes getMotionPlanSolutionErrorCode(std::shared_ptr< moveit_cpp::PlanningComponent::PlanSolution > &plan_solution)
void initPlanSolution(py::module &m)
bool setGoal(std::shared_ptr< moveit_cpp::PlanningComponent > &planning_component, std::optional< std::string > configuration_name, std::optional< moveit::core::RobotState > robot_state, std::optional< geometry_msgs::msg::PoseStamped > pose_stamped_msg, std::optional< std::string > pose_link, std::optional< std::vector< moveit_msgs::msg::Constraints >> motion_plan_constraints)
moveit_msgs::msg::RobotState getMotionPlanSolutionStartState(std::shared_ptr< moveit_cpp::PlanningComponent::PlanSolution > &plan_solution)
bool setStartState(std::shared_ptr< moveit_cpp::PlanningComponent > &planning_component, std::optional< std::string > configuration_name, std::optional< moveit::core::RobotState > robot_state)
void initPlanningComponent(py::module &m)
void initPlanRequestParameters(py::module &m)
Planner parameters provided with the MotionPlanRequest.
double max_velocity_scaling_factor
void load(const rclcpp::Node::SharedPtr &node)
double max_acceleration_scaling_factor
std::string planning_pipeline
The representation of a plan solution.