Ask Your Question
1

roscpp template programming: get statically the Stamped message type

asked 2012-12-29 05:53:49 -0500

updated 2014-01-28 17:14:41 -0500

ngrennan gravatar image

I would like to know if there is some method or trait class in (roscpp or another library) which allows getting the "associated stamped type" of a Type T. For instance

StampedType<pose>::type <- should be StampedPose
StampedType<twist>::type <- should be StampedTwist

If it does not exist, IMO it should. Its a very interesting method to do generic programming in ROS.

BTW I've also missed message inheritance in ROS (but this is another issue where a lot of discussion it is possible)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2012-12-29 13:46:18 -0500

tfoote gravatar image

I don't know of any implementation of that method. It might make an interesting library to contribute. However there's no way to do it automatically as a stamped type is more of a convention, and not all messages have it.

In the tf datatypes you will find a Stamped<> templated datatype for each type of data supported.

edit flag offensive delete link more

Comments

Yep I understand. It's a pitty that Stamped<> is only for tf messages and the only allowed types are statically set. Moreover it forces you to use a tfBroadacaster instead a generic ros msg publisher.

Pablo Iñigo Blasco gravatar imagePablo Iñigo Blasco ( 2012-12-31 02:44:51 -0500 )edit

In any case it would be possible if there would be a template mechanism to generate msgs stamped datatypes. In that case Stamped<RosMsgType> would be a rosmsg type. In such case all the StampedMsgTypes would be unnecessary. The method ros::Publisher::publish might accept T or Stamped<T>

Pablo Iñigo Blasco gravatar imagePablo Iñigo Blasco ( 2012-12-31 02:47:19 -0500 )edit

The header data could be filled explicitly or implicitly by the ros::Publisher. At the same time, a subscriber could use either T or Stamped<T> . IMHO this could be possible maintaining the backwards compatibility.

Pablo Iñigo Blasco gravatar imagePablo Iñigo Blasco ( 2012-12-31 02:49:23 -0500 )edit

The header data could be filled explicitly or implicitly by the ros::Publisher... I think that this could be possible maintaining the backwards compatibility. Using rosmsg infraestructure even would be possible to make compatible StampedPose with Stamped<Pose>

Pablo Iñigo Blasco gravatar imagePablo Iñigo Blasco ( 2012-12-31 02:49:32 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-12-29 05:53:49 -0500

Seen: 150 times

Last updated: Dec 29 '12