sample_2d_plot.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from jsk_recognition_msgs.msg import PlotData
4 import numpy as np
5 import rospy
6 import math
7 from random import random
8 
9 if __name__ == "__main__":
10  rospy.init_node("sample_2d_plot")
11  pub = rospy.Publisher("~output", PlotData, queue_size=1)
12  r = rospy.Rate(10)
13  offset = 0
14  while not rospy.is_shutdown():
15  msg = PlotData()
16  msg.xs = np.arange(0, 5, 0.1)
17  msg.ys = [math.sin(x + offset) for x in msg.xs]
18  msg.label = "sample data"
19  if random() < 0.5:
20  msg.type = PlotData.LINE
21  else:
22  msg.type = PlotData.SCATTER
23  msg.fit_line = random() < 0.5
24  msg.fit_line_ransac = random() < 0.5
25  pub.publish(msg)
26  offset = offset + 0.1
27  r.sleep()


jsk_rqt_plugins
Author(s):
autogenerated on Sat Mar 20 2021 03:03:13