0

I'm trying to publish data from the topic /mavros/global_position/compass_hdg which is a Float64 type message (std_msgs/Float64) but none of the Float64 type topics are publishing data on my Nvidia Jetson TX1.

So I figured, since Float32 types work well, I want to convert the ROS node's data type itself from Float64 to Float32. I tried modifying the C++ code and recompiling using catkin_make but had no luck.

Is there a way to change the ros node's type. And if so, do I have to re-build from source to apply the changes?

rostopic type

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
afkhero
  • 16
  • 1
  • 5

1 Answers1

1

The topic's type is determined by the type specified at definition of the publisher, so I suppose you could try changing the source line 78 to

gp_hdg_pub = gp_nh.advertise<std_msgs::Float32>("compass_hdg", 10);

and line 235 to

auto compass_heading = boost::make_shared<std_msgs::Float32>();

since it seems like that topic is not being listened to elsewhere in that package, and then recompile the code. You will have to change the types in any code that subscribes to that topic, even if it's in a different package. You could also define a new topic that publishes the same data as Float32 (same as above but with a different name than "compass_hdg") so you don't step on any toes.

adamconkey
  • 4,104
  • 5
  • 32
  • 61