Ask Your Question
0

How to read a topic last value from a Python script?

asked 2013-08-13 04:35:29 -0600

Arn-O gravatar image

updated 2014-01-28 17:17:39 -0600

ngrennan gravatar image

Hello.

I'm working on a teleop program in Python. I want to change a joint position and add an offset read from the keyboard.

So I need to read a topic value to add the offset and send the command with the target value. Of course I have read the tutorial about the subscriber in Python. My requirement is slightly different. I do not want to process a piece of code each time a value is published. I do not even need a fresh value, since I consider that the last published one is sufficient.

So is there a way to get this last published value using rospy?

Thanks for your help.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-08-13 23:43:13 -0600

dornhege gravatar image

It depends.

1) Just have a subscriber and record the last published value manually.

2) If you have access to the publisher code, make the publisher latched. This will always keep the last published value and send it to any new subscribers.

edit flag offensive delete link more

Comments

Thx for your answer. I finally used the solution 1.

Arn-O gravatar imageArn-O ( 2013-08-14 07:02:48 -0600 )edit
0

answered 2013-08-13 22:03:39 -0600

Arn-O gravatar image

I will finally use the callback function to maintain a global variable.

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: 2013-08-13 04:35:29 -0600

Seen: 897 times

Last updated: Aug 13 '13