Skip to content

Commit ca9c879

Browse files
committed
filled parking spot
1 parent 950447a commit ca9c879

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

GEMstack/onboard/perception/visualization_utils.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,39 +132,55 @@ def create_parking_spot_marker(closest_spot, length = GEM_E4_LENGTH, width = GEM
132132
marker.header.stamp = rospy.Time.now()
133133
marker.ns = "parking_spot"
134134
marker.id = 0
135-
marker.type = Marker.LINE_STRIP
135+
marker.type = Marker.TRIANGLE_LIST
136136
marker.action = Marker.ADD
137-
marker.scale.x = 0.05 # Line width
138137

138+
# Transparency and color (green)
139139
marker.color.r = 0.0
140140
marker.color.g = 1.0
141141
marker.color.b = 0.0
142-
marker.color.a = 1.0
142+
marker.color.a = 0.5
143+
144+
marker.pose.orientation.w = 1.0
145+
146+
# Not used in TRIANGLE_LIST, but required
147+
marker.scale.x = 1.0
148+
marker.scale.y = 1.0
149+
marker.scale.z = 1.0
143150

144151
x, y, theta_deg = closest_spot
145152

146-
# Convert theta to radians
153+
# Convert orientation to radians
147154
theta = math.radians(theta_deg)
148155

149-
# Half-dimensions
156+
# Half dimensions
150157
dx = length / 2.0
151158
dy = width / 2.0
152159

153-
# Define corner offsets in the local frame
160+
# Define rectangle corners (local frame, clockwise)
154161
local_corners = [
155162
(-dx, -dy),
156163
(-dx, dy),
157164
(dx, dy),
158-
(dx, -dy),
159-
(-dx, -dy) # close the loop
165+
(dx, -dy)
160166
]
161167

162-
# Rotate and translate corners to global frame
168+
# Transform to global frame
169+
global_corners = []
163170
for lx, ly in local_corners:
164171
gx = x + lx * math.cos(theta) - ly * math.sin(theta)
165172
gy = y + lx * math.sin(theta) + ly * math.cos(theta)
166-
marker.points.append(Point(x=gx, y=gy, z=0.0))
167-
173+
global_corners.append(Point(x=gx, y=gy, z=0.0))
174+
175+
# Define two triangles to fill the rectangle
176+
marker.points.append(global_corners[0])
177+
marker.points.append(global_corners[2])
178+
marker.points.append(global_corners[1])
179+
180+
marker.points.append(global_corners[0])
181+
marker.points.append(global_corners[3])
182+
marker.points.append(global_corners[2])
183+
168184
marker_array.markers.append(marker)
169185
return marker_array
170186

0 commit comments

Comments
 (0)