Ask Your Question
0

pass python objects in ROS messages and services

asked 2018-01-19 14:42:38 -0600

waspinator gravatar image

updated 2018-01-19 14:45:57 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-01-19 15:05:30 -0600

gvdhoorn gravatar image

updated 2018-01-19 15:10:58 -0600

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.

edit flag offensive delete link more

Comments

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.

waspinator gravatar imagewaspinator ( 2018-01-20 08:22:09 -0600 )edit

In any case: ROS 1 msg IDL only supports primitive types or composites of those types. See wiki/msg.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-21 02:14:12 -0600 )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

1 follower

Stats

Asked: 2018-01-19 14:42:38 -0600

Seen: 262 times

Last updated: Jan 19 '18