ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Use rclcpp API outside of typical ros-node in 3rdParty app

asked 2018-06-20 07:59:31 -0500

bhmth gravatar image

updated 2018-06-21 02:33:36 -0500

gvdhoorn gravatar image

Hi, I am using ROS 2 Ardent Apalone - 2018-03-07, build from Source with FastRTPS on Win 10 with VS2015. I want to use rclcpp in another application to communicate via ros2's pub/sub implementation between some ros nodes and my application.

For example somwhere in my code i want to do something like this.

m_pPublisher = this->create_publisher<std_msgs::msg::String>("test_topic");
m_pPublisher->publish(someRandomMsg);

Is it possible to link against the needed dll's to make this work? or can it only be done by calling the local_setup.batch ?

Thanks


Edit: Hi, Thanks for your answer, so the local_setup sets up some Paths ?

  • C:\ros2_ws\install\opt\rviz_yaml_cpp_vendor\bin
  • C:\ros2_ws\install\opt\rviz_ogre_vendor\bin
  • C:\ros2_ws\install\opt\rviz_assimp_vendor\bin
  • C:\ros2_ws\install\opt\libcurl_vendor\bin
  • C:\ros2_ws\install\Scripts
  • C:\ros2_ws\install\bin

I found these in >echo %Path% is there more ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-20 11:25:27 -0500

Dirk Thomas gravatar image

updated 2018-06-21 10:10:11 -0500

The local_setup.bat only sets up environment variable so that when you build your package all dependencies are being found. So that part is "necessary" or you have to setup the environment variable manually on your own.

Yes, you can write your own application and use rclcpp as a library. The demo_nodes_cpp package is doing exactly the same.

Beside your posted code snippet you will need to initialize rclcpp, create a node as well as an executor and spin. Just the same as the demo nodes are doing.

Edit: it not only adds to the PATH but also to various other environment variables, e.g. PYTHONPATH, CMAKE_PREFIX_PATH. For a complete let you might want to compare the environment before and after.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-06-20 07:59:31 -0500

Seen: 228 times

Last updated: Jun 21 '18