-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for multi pipeline planning
- Loading branch information
1 parent
acf41e6
commit 01d5dc8
Showing
13 changed files
with
387 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
moveit_py/src/moveit_py/moveit_core/planning_interface/planning_response.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2022, Peter David Fagan | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of PickNik Inc. nor te names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Peter David Fagan */ | ||
|
||
#include "planning_response.h" | ||
|
||
namespace moveit_py | ||
{ | ||
namespace bind_planning_interface | ||
{ | ||
|
||
std::shared_ptr<robot_trajectory::RobotTrajectory> | ||
get_motion_plan_response_trajectory(std::shared_ptr<planning_interface::MotionPlanResponse>& response) | ||
{ | ||
return response->trajectory_; | ||
} | ||
|
||
py::object get_motion_plan_response_start_state(std::shared_ptr<planning_interface::MotionPlanResponse>& response) | ||
{ | ||
py::module_ rclpy_serialization = py::module_::import("rclpy.serialization"); | ||
py::module_ moveit_msgs = py::module_::import("moveit_msgs.msg"); | ||
|
||
py::object robot_state = moveit_msgs.attr("RobotState")(); | ||
moveit_msgs::msg::RobotState robot_state_msg = response->start_state_; | ||
py::bytes serialized_msg = serializeMsg(robot_state_msg); | ||
rclpy_serialization.attr("deserialize_message")(serialized_msg, robot_state); | ||
return robot_state; | ||
} | ||
|
||
py::object get_motion_plan_response_error_code(std::shared_ptr<planning_interface::MotionPlanResponse>& response) | ||
{ | ||
py::module_ rclpy_serialization = py::module_::import("rclpy.serialization"); | ||
py::module_ moveit_msgs = py::module_::import("moveit_msgs.msg"); | ||
|
||
py::object error_code = moveit_msgs.attr("MoveItErrorCodes")(); | ||
moveit_msgs::msg::MoveItErrorCodes error_code_msg = | ||
static_cast<moveit_msgs::msg::MoveItErrorCodes>(response->error_code_); | ||
py::bytes serialized_msg = serializeMsg(error_code_msg); | ||
rclpy_serialization.attr("deserialize_message")(serialized_msg, error_code); | ||
return error_code; | ||
} | ||
|
||
double get_motion_plan_response_planning_time(std::shared_ptr<planning_interface::MotionPlanResponse>& response) | ||
{ | ||
return response->planning_time_; | ||
} | ||
|
||
std::string get_motion_plan_response_planner_id(std::shared_ptr<planning_interface::MotionPlanResponse>& response) | ||
{ | ||
return response->planner_id_; | ||
} | ||
|
||
void init_motion_plan_response(py::module& m) | ||
{ | ||
py::class_<planning_interface::MotionPlanResponse, std::shared_ptr<planning_interface::MotionPlanResponse>>( | ||
m, "MotionPlanResponse", R"()") | ||
|
||
//.def(py::init<>(), R"()") | ||
|
||
.def_property("trajectory", &moveit_py::bind_planning_interface::get_motion_plan_response_trajectory, nullptr, | ||
py::return_value_policy::copy, R"()") | ||
|
||
.def_readonly("planning_time", &planning_interface::MotionPlanResponse::planning_time_, | ||
py::return_value_policy::copy, R"()") | ||
|
||
.def_property("error_code", &moveit_py::bind_planning_interface::get_motion_plan_response_error_code, nullptr, | ||
py::return_value_policy::copy, R"()") | ||
|
||
.def_property("start_state", &moveit_py::bind_planning_interface::get_motion_plan_response_start_state, nullptr, | ||
py::return_value_policy::copy, R"()") | ||
|
||
.def_readonly("planner_id", &planning_interface::MotionPlanResponse::planner_id_, py::return_value_policy::copy, | ||
R"()") | ||
|
||
.def("__bool__", [](std::shared_ptr<planning_interface::MotionPlanResponse>& response) { | ||
return response->error_code_.val == moveit_msgs::msg::MoveItErrorCodes::SUCCESS; | ||
}); | ||
} | ||
} // namespace bind_planning_interface | ||
} // namespace moveit_py |
67 changes: 67 additions & 0 deletions
67
moveit_py/src/moveit_py/moveit_core/planning_interface/planning_response.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2022, Peter David Fagan | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of PickNik Inc. nor te names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Peter David Fagan */ | ||
|
||
#pragma once | ||
|
||
#include <pybind11/pybind11.h> | ||
#include <pybind11/eigen.h> | ||
#include <pybind11/stl.h> | ||
#include <moveit_msgs/msg/robot_state.h> | ||
#include <moveit_msgs/msg/move_it_error_codes.h> | ||
#include <serialize_ros_msg.h> | ||
#include <moveit/planning_interface/planning_response.h> | ||
|
||
namespace py = pybind11; | ||
|
||
namespace moveit_py | ||
{ | ||
namespace bind_planning_interface | ||
{ | ||
|
||
std::shared_ptr<robot_trajectory::RobotTrajectory> | ||
get_motion_plan_response_trajectory(std::shared_ptr<planning_interface::MotionPlanResponse>& response); | ||
|
||
py::object get_motion_plan_response_start_state(std::shared_ptr<planning_interface::MotionPlanResponse>& response); | ||
|
||
py::object get_motion_plan_response_error_code(std::shared_ptr<planning_interface::MotionPlanResponse>& response); | ||
|
||
double get_motion_plan_response_planning_time(std::shared_ptr<planning_interface::MotionPlanResponse>& response); | ||
|
||
std::string get_motion_plan_response_planner_id(std::shared_ptr<planning_interface::MotionPlanResponse>& response); | ||
|
||
void init_motion_plan_response(py::module& m); | ||
} // namespace bind_planning_interface | ||
} // namespace moveit_py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.