0
$\begingroup$

Rosanswers logo

Is there a way to define a ROS message or service with arbitrary python objects? Is the only option to use a string and use json.dumps / json.loads?


Originally posted by waspinator on ROS Answers with karma: 122 on 2018-01-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Is there a way to define a ROS message or service with arbitrary python objects?

Assuming you mean: can I have fields with types of 'arbitrary Python types', then: no.

Is the only option to use a string and use json.dumps / json.loads?

Don't know whether it's the only way, but it is a way.

Can you clarify why you'd want to do this?

It's a really heavy and invasive form of coupling, which limits reusability of your components.


Originally posted by gvdhoorn with karma: 86574 on 2018-01-19

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by waspinator on 2018-01-20:
I use a python ORM to read/write to a database, and I was considering having a ROS node with services for each database operation. I could a) send the python object to the service to save, b) send just the properties and have the service create a new object, or c) use the ORM directly. not sure.

Comment by gvdhoorn on 2018-01-21:
In any case: ROS 1 msg IDL only supports primitive types or composites of those types. See wiki/msg.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.