Autonomous Racing  1
f1tenth Project Group of Technical University Dortmund, Germany
rviz_geometry.py
Go to the documentation of this file.
1 import rospy
2 
3 import numpy as np
4 from std_msgs.msg import ColorRGBA
5 from geometry_msgs.msg import Point as PointMessage
6 from visualization_msgs.msg import Marker
7 from circle import Point
8 
9 RVIZ_TOPIC = "/wallfollowing_visualization"
10 RVIZ_FRAME = "laser"
11 RVIZ_NAMESPACE = "wall_following"
12 
13 marker_publisher = rospy.Publisher(RVIZ_TOPIC, Marker, queue_size=1)
14 
15 
16 def show_line_in_rviz(id, points, color, line_width=0.02):
17  message = Marker()
18  message.header.frame_id = RVIZ_FRAME
19  message.header.stamp = rospy.Time.now()
20  message.ns = RVIZ_NAMESPACE
21  message.type = Marker.ADD
22  message.pose.orientation.w = 1
23 
24  message.id = id
25  message.type = Marker.LINE_STRIP
26  message.scale.x = line_width
27  message.color = color
28  if isinstance(points, np.ndarray):
29  message.points = [PointMessage(points[i, 1], -points[i, 0], 0) for i in range(points.shape[0])] # nopep8
30  elif isinstance(points, list):
31  message.points = [PointMessage(point.y, -point.x, 0) for point in points] # nopep8
32  else:
33  raise Exception("points should be a numpy array or list of points, but is " + str(type(points)) + ".") # nopep8
34 
35  marker_publisher.publish(message)
36 
37 
38 def show_circle_in_rviz(circle, wall, id):
39  start_angle = circle.get_angle(Point(wall[0, 0], wall[0, 1]))
40  end_angle = circle.get_angle(Point(wall[-1, 0], wall[-1, 1]))
41  points = circle.create_array(start_angle, end_angle)
42  show_line_in_rviz(id, points, color=ColorRGBA(0, 1, 1, 1))
def show_line_in_rviz(id, points, color, line_width=0.02)
Point
Definition: circle.py:8
def show_circle_in_rviz(circle, wall, id)