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

How to modify a model plugin to publish data to a rostopic or ros node?

asked 2019-10-07 04:55:48 -0500

zaccer gravatar image

I am trying to work with gazebo_motor_model.cpp. I need to visual some data that is calculated inside the plugin such as force, drag_torque etc. Is there a way i can publish this data to a topic or node so that i can visualize it using rqt.

P.S. - I am working on ROS kinetic with gazebo 7

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-07 05:01:41 -0500

gvdhoorn gravatar image

If the plugin doesn't provide the necessary Publishers yet, and the data you're after is internal to the plugin, you'll probably have to add ros::Publishers yourself. Basically extend the plugin to create additional publishers for the data you're interested in.

A quick look shows that apart from this single Publisher that publishes motor velocity, there are no others.

You could follow a similar pattern to add your own (and if you want to be nice, add some configuration settings for them as well).

edit flag offensive delete link more

Comments

thanks for the answer, I am fairly new to ROS, is there any example I can reference from to understand the method in depth?

zaccer gravatar image zaccer  ( 2019-10-07 05:20:09 -0500 )edit

is there any example I can reference from to understand the method in depth?

which "method" exactly? Could you clarify?

The code of the plugin you reference could already be thought of as an example. If you consider the "motor velocity" publisher, you could duplicate that for every bit of information you want out of the plugin.

You could debate whether "internal state" is something that could be published as a single message or whether multiple different publishers (each carrying only a single piece of information) would make sense. The former may make it easier to time-sync plots, but not necessarily (if you timestamp everything correctly).

gvdhoorn gravatar image gvdhoorn  ( 2019-10-07 05:32:13 -0500 )edit

I tried creating a publisher following the example,i created a variable force_pub_topic_ to publish the data but while compiling the code, error occurs that 'force_pub_topic_ is not declared in the scope.'

on further search i found that motorspeed_pub_topic_ is declared in motor_model.hlink text file,which has referenced for other . h files for motor speed.

what is a possible solution to solve above error?

zaccer gravatar image zaccer  ( 2019-10-07 05:43:30 -0500 )edit

This would appear to be more a C++ issue than a ROS one: you'll have to properly declare and define the variables that you need/want to use, as well as any other resources.

You already found the correct place to do that. The class definition is in the header. The implementation is (mostly) in the .cpp.

By carefully studying how the current publisher is created and used, you should be able to add the one for your data.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-07 06:17:31 -0500 )edit

Thanks for the help.I will look into the header file.

zaccer gravatar image zaccer  ( 2019-10-07 06:23:57 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-10-07 04:55:48 -0500

Seen: 982 times

Last updated: Oct 07 '19