Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsk_topic_tools] Add topic_hz_converter for keeping the topic hz stable #1719

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tkmtnt7000
Copy link
Member

I add topic hz converter.
Unlike topic_tools/throttle, this node can increase and stabilize the frequency of a particular topic.
For example, a topic in sensor_msgs/Image that is publishing at 10 Hz can be set to 30 Hz by continuing to publish the previous image topic.

And this node support multiple topic type.

Copy link
Member

@k-okada k-okada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add test code

by the way, why we need this?

  1. if we use approximate sync, increasing time window
    http://wiki.ros.org/message_filters#ApproximateTime_Policy

  2. if we ros node that expecting to run 30hz, but it run main code based on topic call back.

(defmethod intelligent-action
 (:init () (ros::subscribe "image" #'send self :cb))
 (:cb (msg) (setq cb-msg msg) (do-intelligent-job)) ;; expecting to run 30hz
)

Then you should write 30hz, loop and use latest sensor topics somethign like

(defmethod intelligent-action
 (:init () (ros::subscribe "image" #'send self :cb))
 (:cb (msg) (setq cb-msg msg))
(setq r (ros::rate 30))
(whille (ros::ok)
  (do-intelligent-job (*ia* . cb-msg)) ;; call do-intelligent-job 30hz, with latest image sensor data
  (send r :sleeep)
  (ros::spin-once))

Sometime peope uses one-shot-subscriber for this purpose

(whille (ros::ok)
  (setq cb-msg (one-short-subscriber "image"))
  (do-intelligent-job cb-msg) ;; call do-intelligent-job 30hz, with latest image sensor data
  (send r :sleeep)
  (ros::spin-once))

but it is not a good practice.

@knorth55
Copy link
Member

@tkmtnt7000 can we use #1748 instead of this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants