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

How to use .msg in source code as a variable?

asked 2013-11-21 06:24:17 -0500

updated 2013-11-27 05:39:19 -0500

tfoote gravatar image

I want to use nav_msg/GridCells.msg and OccupancyGrid in my package,How to use it in the source code. It is not a member of nav_msgs and it is only a .msg and I am unable find documentation for using GridCells as a member variable i.e. I want to initialize occupancy grid and add data to it and publish it as a topic. I want to do in cpp.

edit retag flag offensive close merge delete

Comments

@balakumar-s please accept the question by using the checkbox at the left of the answer instead of closing it. (the checkbox will implicitly close it, and reward the answerer with karma.

tfoote gravatar image tfoote  ( 2013-11-27 05:39:03 -0500 )edit

@tfoote Thanks I did that now.

balakumar-s gravatar image balakumar-s  ( 2013-11-27 05:47:05 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2013-11-21 06:51:50 -0500

lindzey gravatar image

What have you tried so far? What isn't working?

The c++ publisher/subscriber tutorial shows how to create a ros message, add data to it, and then publish it.

edit flag offensive delete link more

Comments

I just initialized as : nav_msgs::OccupancyGrid og; og.data=temp_data; but the error while compiling is OccupancyGrid is not a member of nav_msgs Is this how you initialize? Is OccupancyGrid not a member and cant it be used like a class?

balakumar-s gravatar image balakumar-s  ( 2013-11-21 06:59:20 -0500 )edit

If you want help debugging why your code won't compile, you need to edit your original question to include a small and complete example, as well as the exact error message.

lindzey gravatar image lindzey  ( 2013-11-21 07:26:01 -0500 )edit

Sounds like you might forgot to put a #include <nav_msgs occupancygrid.h=""> into your source file. Still, lindzey´s comment applies: Post code, then people can make informed comments.

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2013-11-21 19:57:35 -0500 )edit

It was a simple mistake, OccupancyGrid was typed as OccupacyGrid. Thanks for your help. :)

balakumar-s gravatar image balakumar-s  ( 2013-11-21 22:34:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-21 06:24:17 -0500

Seen: 495 times

Last updated: Nov 21 '13