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

Can MoveItPy be used with rclpy.node.Node? #1017

Open
ymollard opened this issue Feb 6, 2025 · 3 comments
Open

Can MoveItPy be used with rclpy.node.Node? #1017

ymollard opened this issue Feb 6, 2025 · 3 comments

Comments

@ymollard
Copy link

ymollard commented Feb 6, 2025

Hi,

The MoveItPy tutorials do not create a rclpy.node.Node instance:

def main():
###################################################################
# MoveItPy Setup
###################################################################
rclpy.init()
logger = get_logger("moveit_py.pose_goal")
# instantiate MoveItPy instance and get planning component
panda = MoveItPy(node_name="moveit_py")
panda_arm = panda.get_planning_component("panda_arm")
logger.info("MoveItPy instance created")
###########################################################################
# Plan 1 - set states with predefined string
###########################################################################
# set plan start state using predefined state
panda_arm.set_start_state(configuration_name="ready")
# set pose goal using predefined state
panda_arm.set_goal_state(configuration_name="extended")
# plan to goal
plan_and_execute(panda, panda_arm, logger, sleep_time=3.0)

In my opinion this is somehow inconsistent with rclpy tutorials that recommand to inherit from rclpy.node.Node here:
https://docs.ros.org/en/jazzy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html

That makes integration of MoveItPy with other rclpy tools (subscribers, services, ...) more complicated for beginners who cannot rely on official ROS 2 tutorials to assemble with MoveItPy.

Is there a recommanded way to use the MoveItPy + rclpy.node.Node combo?

@sea-bass
Copy link
Contributor

sea-bass commented Feb 7, 2025

It seems like MoveItPy internally contains its own node and executor:

https://github.com/moveit/moveit2/blob/99227040ebe4bac4cc1a95afbe44ee9c543e3c02/moveit_py/src/moveit/moveit_ros/moveit_cpp/moveit_cpp.cpp#L55

You might be able to create something that subclasses from a node and stick the MoveItPy instance inside it as an attribute, but I haven't tried this myself.

@ymollard
Copy link
Author

Yes, it works pretty well like this: https://gitlab.com/f2m2robserv/jazzy-ros-ynov/-/blob/main/src/tiago_pick_and_place/tiago_pick_and_place/pick.py

Shouldn't the tutos create a regular node like this instead? This is confusing for newcomers, they're told in regular ROS tutorials to create a node via class inheritance, but MoveItPy is not demonstrated this way.

@sea-bass
Copy link
Contributor

Great to hear, and your example does look nice!

If you'd be willing to add a new tutorial on "Using MoveItPy in existing ROS 2 nodes", that would be a good addition to the currently small set of Python tutorials.

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

No branches or pull requests

2 participants