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

writing a custom message and using it in a different package

asked 2015-07-07 05:23:44 -0500

saikrishnagv gravatar image

updated 2015-07-07 06:06:57 -0500

gvdhoorn gravatar image

first of all, I have gone through these links, so it is not a repeat question:

and i tried all of these solutions, but they did not help me.

The question is..

I have created a msg folder in package 'A'. wrote hello.msg in that 'msg' folder. I followed this tutorial: http://wiki.ros.org/ROS/Tutorials/Cre... and catkin_make worked fine here.

I now created a new package 'B' , has a node 'helpme.cpp' and in that I have written #include "A/hello.h" and I defined

A::hello left,right;
left.myheight = image.rows;
left.mywidth = image.cols;

.....in the callback function and when I do catkin_make, it says..

/home/krish/architecture_ws/src/rectifier/src/camera_timestamp_node.cpp:276:6: error: ‘const ImageConstPtr’ has no member named ‘mywidth’
/home/krish/architecture_ws/src/rectifier/src/camera_timestamp_node.cpp:277:6: error: ‘const ImageConstPtr’ has no member named ‘myheight’

pls tell me what changes should I make in CMakeLists.txt and package.xml in the packages A and B.

edit retag flag offensive close merge delete

Comments

Could you please reformat this, I just over read your message definition. The readability is quite horrible. Like use the code (0101010) Button for your message definition.

cyborg-x1 gravatar image cyborg-x1  ( 2015-07-07 05:40:25 -0500 )edit

I've fixed your formatting a bit, because as @cyborg-x1 writes, it was unintelligible before. Please take care of formatting your question properly in the future: it increases your chances of getting answers.

gvdhoorn gravatar image gvdhoorn  ( 2015-07-07 06:07:57 -0500 )edit

ok, gvdhoorn and cybord-x1, I will take care of formatting from next time

saikrishnagv gravatar image saikrishnagv  ( 2015-07-07 06:34:07 -0500 )edit

3 Answers

Sort by » oldest newest most voted
0

answered 2015-07-07 06:49:01 -0500

saikrishnagv gravatar image

I got this problem because of my programming mistake. I have given the same variable name to both ImageConstPtr and my own message type. the problem is solved now thanks gvdhoorn and cyborg-x1

edit flag offensive delete link more
1

answered 2015-07-07 06:39:06 -0500

gvdhoorn gravatar image
/home/krish/architecture_ws/src/rectifier/src/camera_timestamp_node.cpp:276:6: error: ‘const ImageConstPtr’ has no member named ‘mywidth’
/home/krish/architecture_ws/src/rectifier/src/camera_timestamp_node.cpp:277:6: error: ‘const ImageConstPtr’ has no member named ‘myheight’

This is a bit of a guess (as we don't have the actualy msg definition), but I'd say that your trying to access the mywidth member variable of an ImageConstPtr itself, not of the object it is pointing to. That probably fails, because the pointer will not have that member, only the pointed to has it.

To access the field on the pointed to, you'd probably have to dereference the ImageConstPtr, which you would do with my_ptr->mywidth (which uses the shorthand form of the dereference operator).

edit flag offensive delete link more
1

answered 2015-07-07 05:48:22 -0500

I guess there is something wrong with your topic callback rather than catkin not finding it:

/home/krish/architecture_ws/src/rectifier/src/camera_timestamp_node.cpp:276:6: error: ‘const ImageConstPtr’ has no member named ‘mywidth’

You should use const HelloConstPtr instead of ImageConstPtr. if the name is Hello...

I guess you edited a node using an Image message, right?

Regards

Christian

edit flag offensive delete link more

Comments

int8 seq_id

std_msgs/Header timestamp

int8 frame_id

float64 myheight

float64 mywidth

int16 step_value

int32[] myimage_data

is my hello.msg

I guess my call back function is fine. it is being called before I introduced my own message type.

saikrishnagv gravatar image saikrishnagv  ( 2015-07-07 06:33:24 -0500 )edit

But if you have have a message called hello.msg you will need the class helloConstPtr in your callback function currently you are using ImageConstPtr according to your compiler error. And ImageConstPointer only features width not mywidth. (sensor_msgs)

cyborg-x1 gravatar image cyborg-x1  ( 2015-07-07 06:44:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-07 05:23:44 -0500

Seen: 1,295 times

Last updated: Jul 07 '15