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

How to use c++ headers of other ros packages ? #263

Open
whiteplatin opened this issue Sep 20, 2022 · 3 comments
Open

How to use c++ headers of other ros packages ? #263

whiteplatin opened this issue Sep 20, 2022 · 3 comments

Comments

@whiteplatin
Copy link

whiteplatin commented Sep 20, 2022

Hello,
is there a guide or has anyone used MoveIt2 with ros2_rust ?

Example:
https://moveit.picknik.ai/humble/doc/tutorials/your_first_project/your_first_project.html

https://github.com/ros-planning/moveit2/blob/main/moveit_ros/planning_interface/move_group_interface/include/moveit/move_group_interface/move_group_interface.h

#include <memory>

#include <rclcpp/rclcpp.hpp>
#include <moveit/move_group_interface/move_group_interface.h>

int main(int argc, char * argv[])
{
  // Initialize ROS and create the Node
  rclcpp::init(argc, argv);
  auto const node = std::make_shared<rclcpp::Node>(
    "hello_moveit",
    rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true)
  );

  // Create a ROS logger
  auto const logger = rclcpp::get_logger("hello_moveit");

  // Next step goes here

  // Shutdown ROS
  rclcpp::shutdown();
  return 0;
}

Any ideas on how to get started ?
Do I need to use cxx for example or can I take different route to use this with ros2_rust ?

@nnmm
Copy link
Contributor

nnmm commented Sep 20, 2022

cc @tylerjw

In general, I don't think we're there yet. The two major options are (1) writing C wrappers for using either of C++/Rust in the other language or (2) trying out cxx.

What would you like to do more concretely?

@tylerjw
Copy link

tylerjw commented Sep 20, 2022

Hello, this is something I really want and have been trying to make possible but right now it is relatively involved as @nnmm stated. I created this: https://github.com/tylerjw/add_cargo_library

which can make it easier to add cxx rust code into your C++ code. This does not automate creating bindings, you'll have to create that boundary layer yourself with cxx.

This also does not make MoveIt work with ros2-rust as ros2-rust is a rust client library and MoveIt depends on the C++ client library. There is no bridging of the types between these two libraries so you can't for example create a node in ros2-rust and pass it to MoveIt through cxx and have it do anything that useful with it.

However, MoveIt does have ROS interfaces through move_group so you could write rust code using ros2-rust that communicates using ROS to MoveIt through those interfaces. You can also write a C++ application that wraps some behavior you want to express in ROS interfaces and interact through those interfaces.

@pmirabel
Copy link

Hello!
If anyone get here with the goal to interface ros2-rust and MoveIt!2, I think the better way to go is to wait for (or contribute to) action support.

However, MoveIt does have ROS interfaces through move_group so you could write rust code using ros2-rust that communicates using ROS to MoveIt through those interfaces.

Doing so would be tricky Because ros2-rust does not implement action yet and MoveIt!2 dropped the service interface for executing trajectories (to be confirmed, but I cannot see in the default capabilities file.

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

4 participants