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

ROSJava -- Parameters and knowing their types ahead of time?

asked 2013-08-24 17:48:45 -0500

mpthompson gravatar image

I'm working on updating some old ROSSerial classes to work with the latest version of ROSJava under Groovy. To add support for parameters, I'm looking at the ParameterTree interface and it appears that one must know what the parameter type is before retrieving it -- getBoolean(), getInteger(), getDouble(), getString(), etc... Unfortunately, with ROSSerial only the name is passed up from the attached client and I don't know the type of the object prior to getting it from the ParameterTree. Can anyone suggest a way around this?

Looking at the implementation of DefaultParameterTree it appears that the XML RPC interfaces get a generic Object and then cast it as needed to support the API. It would be nice if the ParameterTree api included the option of returning the generic Object and then reflection could be used to cast the object to appropriate type for serialization to the ROSSerial client.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-27 07:31:25 -0500

jubeira gravatar image

@mpthompson what you say is correct. The workaround in java is to use instanceof inside if-else statements until you hit the type that you were looking for.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-08-24 17:48:45 -0500

Seen: 226 times

Last updated: Sep 27 '17