Ask Your Question
1

Python call callback function on input change

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

TkrA gravatar image

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

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
2

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

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

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: 2015-06-15 17:39:45 -0600

Seen: 153 times

Last updated: Jun 16 '15