Robotics StackExchange | Archived questions

Including ros in shared object library file

I'm trying to make a plugin (.so file) for other programs that is not built with ROS but can publish to nodes that are made by ROS. Below is my plan:

static ros::NodeHandle nh;
ros::Publisher ros_publisher;

ROSPLUGIN_API void init(){
    ros::init();
    ros_publisher = nh.advertise<ros_tutorials_topic::MsgTutorial>("ros_tutorial_msg", 100);
}

ROSPLUGIN_API void publish(){
    msg = makeMsg();
    ros_tutorial_pub.publish(msg); 
}

But there are following problems:

  1. I can't figure out how to write a CMakeLists.txt in this case.
  2. The argc, and argv for the init function.
  3. Not even sure this will work.

Have anyone challenged something similar like me??

Asked by ftatp on 2022-09-28 03:58:15 UTC

Comments

Answers

What you are proposing is not going to be feasible. It sounds like you are asking how to allow a non-ros app to publish messages to ros topics? People have created many projects to implement this kind of thing, so I'll point to two you should look into before you go re-invent the wheel:

rosserial - http://wiki.ros.org/rosserial

rosbridge_suite - http://wiki.ros.org/rosbridge_suite

Asked by Mike Scheutzow on 2022-10-01 08:54:44 UTC

Comments