Skip to content

Commit f1ef086

Browse files
committed
Attempt to add component to track state in local frame
1 parent e2a689b commit f1ef086

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

GEMstack/offboard/calibration/capture_ouster_oak.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import ctypes
66
import struct
77

8+
from ...state import VehicleState, ObjectPose
9+
from ...onboard import Component
10+
811
# OpenCV and cv2 bridge
912
import cv2
1013
from cv_bridge import CvBridge
@@ -17,6 +20,7 @@
1720
camera_images = []
1821
depth_images = []
1922
gnss_locations = []
23+
frame_position = None
2024
lidar_filetype = ".npz"
2125
camera_filetype = ".png"
2226
depth_filetype = ".tif"
@@ -80,6 +84,11 @@ def save_scan(lidar_filenames, camera_filenames, depth_filenames, gnss_filenames
8084
return
8185
print("Saving scan", index)
8286

87+
if frame_position != None:
88+
np.save("state" + str(index), frame_position)
89+
else:
90+
print("No state found")
91+
8392
for i in range(len(lidar_points)):
8493
current_lidar = lidar_points[i]
8594
lidar_fn = lidar_filenames[i] + str(index) + lidar_filetype
@@ -141,6 +150,15 @@ def main(folder='data',start_index=0):
141150
clear_scan()
142151
index += 1
143152

153+
class StateTracker(Component):
154+
def rate(self):
155+
return 4.0 # Hz
156+
def state_inputs(self):
157+
return ['vehicle']
158+
def update(self, vehicle : VehicleState):
159+
global frame_position
160+
frame_position = np.array(vehicle.pose.frame, vehicle.pose.t, vehicle.pose.x, vehicle.pose.y)
161+
144162
if __name__ == '__main__':
145163
import sys
146164
folder = 'data'

0 commit comments

Comments
 (0)