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

Creating pointers in rosmsg

asked 2018-02-19 03:53:32 -0500

Gringoos gravatar image

updated 2018-02-19 04:30:28 -0500

gvdhoorn gravatar image

Hey, I want to know that, can I create pointers in ros messages as we do in simple c++. I want to create a structure for a property of a node.

struct proper_int{
    string title;
    int value;
    **proper_int *next;**
};

can i do this in a rosmsg or any way to do this?

edit retag flag offensive close merge delete

Comments

Your example structure looks like it models a linked list. Would using a simple unbounded array in your msg not work?

gvdhoorn gravatar image gvdhoorn  ( 2018-02-19 04:30:10 -0500 )edit

I am creating a graph structure in which node has unlimited properties, for I am trying to connect each property in a chain. Question is can I establish a link between two messages that a message calls itself to create another property. if we can then how?

Gringoos gravatar image Gringoos  ( 2018-02-19 04:50:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-19 04:28:45 -0500

gvdhoorn gravatar image

updated 2018-02-19 04:31:37 -0500

Syntactically, the answer would be yes.

A pointer is either a 32bit or 64bit (un)signed value, so a field of type (u)int32 or (u)int64 would be able to store that and the ROS IDL supports those types (wiki/msg).

However, all the same restrictions wrt exchanging pointers between different processes apply: pointers only point to valid addresses inside a single process. If you are planning to exchange these messages with other nodes, you'll have to use something like a shared memory segment accessible to all those nodes (and the pointers will have to point to memory inside that shared segment), or the pointers will be unusable anywhere outside the publishing process.

If you can tell us why you want to do this, we might be able to propose some alternative (wiki/nodelets fi exchange pointers already, which has many benefits, but comes with some drawbacks as well).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-02-19 03:53:32 -0500

Seen: 723 times

Last updated: Feb 19 '18