-
Notifications
You must be signed in to change notification settings - Fork 580
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
feat: add remapping argument to MoveItPy initialization #3367
Open
KazuyaOguma18
wants to merge
3
commits into
moveit:main
Choose a base branch
from
TohokuQuix:moveitpy-remapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,7 +35,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||
/* Author: Peter David Fagan */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
#include "moveit_cpp.hpp" | ||||||||||||||||||||||||||||||||||||||||||||||
#include <pybind11/pytypes.h> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <moveit/utils/logger.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <string> | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
namespace moveit_py | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -62,7 +64,7 @@ void initMoveitPy(py::module& m) | |||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
.def(py::init([](const std::string& node_name, const std::string& name_space, | ||||||||||||||||||||||||||||||||||||||||||||||
const std::vector<std::string>& launch_params_filepaths, const py::object& config_dict, | ||||||||||||||||||||||||||||||||||||||||||||||
bool provide_planning_service) { | ||||||||||||||||||||||||||||||||||||||||||||||
bool provide_planning_service, const py::object& remappings) { | ||||||||||||||||||||||||||||||||||||||||||||||
// This section is used to load the appropriate node parameters before spinning a moveit_cpp instance | ||||||||||||||||||||||||||||||||||||||||||||||
// Priority is given to parameters supplied directly via a config_dict, followed by launch parameters | ||||||||||||||||||||||||||||||||||||||||||||||
// and finally no supplied parameters. | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -85,6 +87,21 @@ void initMoveitPy(py::module& m) | |||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
if (py::isinstance<py::list>(remappings)) | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
for (auto item : remappings) | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
py::tuple item_tuple = item.cast<py::tuple>(); | ||||||||||||||||||||||||||||||||||||||||||||||
if (item_tuple.size() != 2) | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
throw std::runtime_error("Remapping must be a list of tuples with 2 elements"); | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
launch_arguments.push_back("--remap"); | ||||||||||||||||||||||||||||||||||||||||||||||
launch_arguments.push_back(item_tuple[0].cast<std::string>() + | ||||||||||||||||||||||||||||||||||||||||||||||
":=" + item_tuple[1].cast<std::string>()); | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+90
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
// Initialize ROS, pass launch arguments with rclcpp::init() | ||||||||||||||||||||||||||||||||||||||||||||||
if (!rclcpp::ok()) | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -138,7 +155,7 @@ void initMoveitPy(py::module& m) | |||||||||||||||||||||||||||||||||||||||||||||
py::arg("launch_params_filepaths") = | ||||||||||||||||||||||||||||||||||||||||||||||
utils.attr("get_launch_params_filepaths")().cast<std::vector<std::string>>(), | ||||||||||||||||||||||||||||||||||||||||||||||
py::arg("config_dict") = py::none(), py::arg("provide_planning_service") = true, | ||||||||||||||||||||||||||||||||||||||||||||||
py::return_value_policy::take_ownership, | ||||||||||||||||||||||||||||||||||||||||||||||
py::arg("remappings") = py::none(), py::return_value_policy::take_ownership, | ||||||||||||||||||||||||||||||||||||||||||||||
R"( | ||||||||||||||||||||||||||||||||||||||||||||||
Initialize moveit_cpp node and the planning scene service. | ||||||||||||||||||||||||||||||||||||||||||||||
)") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just use a std::map as argument here. This simplifies casting code below.
Wrapping the map into
std::optional
allows to handle None values.