Gazebo | Ignition | Community
Ask Your Question

an's profile - activity

2015-07-01 13:48:43 -0500 received badge  Taxonomist
2015-06-22 04:30:43 -0500 received badge  Student (source)
2014-09-21 15:20:01 -0500 received badge  Famous Question (source)
2014-09-18 15:08:07 -0500 received badge  Editor (source)
2014-09-18 15:06:15 -0500 asked a question How do you subscribe to ROS topics from a gazebo plugin?

I am trying to subscribe to ROS topics from a gazebo plugin.

Currently, in the plugin's Load function, I have:

    ros::init(argc, argv, "plugInNode");
    ros::NodeHandle nh;
    sub1= nh.subscribe("myTopic1", 1000, pluginCallback1);
    sub2= nh.subscribe("myTopic2", 1000, pluginCallback2);
    sub3= nh.subscribe("myTopic3", 1000, pluginCallback3);
    sub4= nh.subscribe("myTopic4", 1000, pluginCallback4);

Those callback functions are just different functions withing the same class, but there are errors saying it couldn't resolve the address, couldn't do the substitution, etc.

I looked here: http://wiki.ros.org/roscpp/Overview/Publishers%20and%20Subscribers#Callback_Types and that shows how to create callback functions in different cases, but I don't know how to do it in my case.

Also, in the gazebo_ ros_ diffdrive.cpp code, I saw that there is a subscriber... so I tried to follow that syntax by doing:

    sub1= nh.subscribe("myTopic1", 1000, &myPlaneDemoPlugin::pluginCallback1, this);

However I still got the same errors...

Some of the errors include:

In file included from /opt/ros/indigo/include/ros/ros.h:45:0, from /home/an25328/catkinws/src/gazeborospkgs/gazeboplugins/src/myPlaneDemoPlugin.cc:17: /opt/ros/indigo/include/ros/nodehandle.h:752:14: note: template<class m,="" class="" c=""> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32t, const boost::function<void(c)&gt;&amp;, const="" voidconstptr&amp;,="" const="" ros::transporthints&amp;)="" subscriber="" subscribe(const="" std::string&amp;="" topic,="" uint32<em="">t queuesize, const boost::function<void (c)&gt;&amp;="" callback,="" ^="" opt="" ros="" indigo="" include="" ros="" node<em="">handle.h:752:14: note: template argument deduction/substitution failed: /home/an25328/catkinws/src/gazeborospkgs/gazeboplugins/src/myPlaneDemoPlugin.cc:93:87: note: ‘void (gazebo::myPlaneDemoPlugin::*)(...)’ is not derived from ‘const boost::function<void(c)&gt;’ sub4="nh.subscribe("elevator&lt;/em">joint", 1000, &myPlaneDemoPlugin::pluginCallback4, this);

                                                                                   ^

In file included from /opt/ros/indigo/include/ros/ros.h:45:0, from /home/an25328/catkinws/src/gazeborospkgs/gazeboplugins/src/myPlaneDemoPlugin.cc:17: /opt/ros/indigo/include/ros/nodehandle.h:785:14: note: ros::Subscriber ros::NodeHandle::subscribe(ros::SubscribeOptions&) Subscriber subscribe(SubscribeOptions& ops); /opt/ros/indigo/include/ros/nodehandle.h:785:14: note:
candidate expects 1 argument, 4 provided

Any help would be appreciated!

2014-09-18 14:57:21 -0500 commented question why ros_enabled model plugin not working with a ros subscriber that recieves laser scans?

Hi, can you tell me how you subscribed to ROS topics from your plugins?? I am unable to get mine to work because I don't know how to initialize the subscriber in this situation. I did "sub= nh.subscribe("myTopic", 1000, pluginCallback);" but there are errors saying it cannot locate that plugin... although it definitely exists. It's in the same class as the function with this line of code.

2014-09-17 11:15:51 -0500 received badge  Notable Question (source)
2014-09-17 11:08:17 -0500 received badge  Scholar (source)
2014-09-17 10:39:10 -0500 received badge  Popular Question (source)
2014-09-16 09:18:06 -0500 asked a question How can you fly the plane provided in plane_demo.world?

I have created a ros node that takes inputs from the keyboard, to distinguish between going forward/backward, turning left/right, and going up/down.

I can control the forward/backward easily (I just publish a twist message with the linear x component set to either a positive or negative number).

I cannot figure out how to control the other things, though. To turn the plane, I allow wing 5 (vertical stabilizer, which controls yaw) to revolve around the z axis, and I publish twist messages to that link. This "works," in that I can clearly see wing5 rotating around the z axis. Now, logically, this should affect the direction that the plane travel but I dont understand how to implement that. For example, I tried setting wing5 to rotate, and then setting the plane's linear x velocity... however, this just moves the entire model in the +x direction, instead of moving in a direction that makes sense with the way wing5 is positioned.

How do I control the plane's pitch and yaw?

I see videos on youtube by John Hsu, flying this model around, so I know it has been done. Any help would be appreciated.