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

Python call callback function on input change

asked 2015-06-15 17:39:45 -0500

TkrA gravatar image

updated 2015-06-16 17:36:17 -0500

lucasw gravatar image

Some basic programming question:

My node is subscribed to the /joint_states topic, more exactly /joint_states/position[5]. I am trying to publish a message, each time the joint6's state has changed. The /joint_states topic has a high rate 0.1 sec/ published messages, so right now i publish the same value, 10x a sec. I would like to call the callback function only on input change.

Does python have some special function for that?

Any ideas?

btw: i would have a much easier task if i could publish fake_gripperarm_controller using demo.launch from my MoveIt! package

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-15 22:20:40 -0500

ahendrix gravatar image

ROS doesn't have any concept of calling a callback only when the data changes; callbacks are called whenever a new message is published, and the publisher is responsible for the semantics of when new messages are published.

If you want to detect when the data changes, you'll have to implement that yourself.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-06-15 17:39:45 -0500

Seen: 406 times

Last updated: Jun 16 '15