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

rqt_plot: Plot bool fields #427

Merged
merged 2 commits into from
Feb 14, 2017

Conversation

DLu
Copy link
Contributor

@DLu DLu commented Feb 6, 2017

Add the capability to plot bool fields in composite messages.

@dirk-thomas
Copy link
Contributor

Can you please provide a reproducible example.

@DLu
Copy link
Contributor Author

DLu commented Feb 6, 2017

#!/usr/bin/python

import rospy
from sensor_msgs.msg import BatteryState
import random

rospy.init_node('x')
pub = rospy.Publisher('/battery', BatteryState, queue_size=1)
r = rospy.Rate(2)
while not rospy.is_shutdown():
  b = BatteryState()
  b.header.stamp = rospy.Time.now()
  b.present = random.random() > 0.5
  b.voltage = random.random()
  pub.publish(b)
  r.sleep()

Run the above script, and then run this:
! ~/ > rqt_plot /battery/voltage /battery/present

Before the pull request, only voltage will be published. After, both signals we be published.

@dirk-thomas
Copy link
Contributor

Thank you. This works well for me.

Maybe the message should be adjusted to mention that it is a boolean field rather then a numeric one. I would suggest adding topic_kind = 'boolean' if field_class == bool else 'numeric' and then use that as a placeholder for both messages.

@DLu
Copy link
Contributor Author

DLu commented Feb 14, 2017

Good thought. Updated.

@dirk-thomas
Copy link
Contributor

Thanks.

@dirk-thomas dirk-thomas merged commit 0329582 into ros-visualization:master Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants