1from __future__ import absolute_import
2
3from datetime import datetime
4from typing import Optional
5from uuid import uuid4
6
7import kognic.io.model.scene.aggregated_lidars_and_cameras_seq as ALCSM
8from examples.calibration.calibration import create_sensor_calibration
9from kognic.io.client import KognicIOClient
10from kognic.io.logger import setup_logging
11from kognic.io.model import CreateSceneResponse, EgoVehiclePose, Image, PointCloud, Position, RotationQuaternion
12
13
14def run(client: KognicIOClient, dryrun: bool = True, **kwargs) -> Optional[CreateSceneResponse]:
15 print("Creating Lidar and Camera Sequence Scene...")
16
17 lidar_sensor1 = "lidar"
18 cam_sensor1 = "RFC01"
19 cam_sensor2 = "RFC02"
20 metadata = {"location-lat": 27.986065, "location-long": 86.922623, "vehicle_id": "abg"}
21
22
23
24 calibration_spec = create_sensor_calibration(
25 f"Collection {datetime.now()}",
26 [lidar_sensor1],
27 [cam_sensor1, cam_sensor2],
28 )
29 created_calibration = client.calibration.create_calibration(calibration_spec)
30
31 scene = ALCSM.AggregatedLidarsAndCamerasSequence(
32 external_id=f"Aggregated-LCS-full-example-{uuid4()}",
33 frames=[
34 ALCSM.Frame(
35 frame_id="1",
36 relative_timestamp=0,
37 point_clouds=[
38 PointCloud(
39 filename="./examples/resources/point_cloud_RFL01.las",
40 sensor_name=lidar_sensor1,
41 ),
42 ],
43 images=[
44 Image(
45 filename="./examples/resources/img_RFC01.jpg",
46 sensor_name=cam_sensor1,
47 ),
48 Image(
49 filename="./examples/resources/img_RFC02.jpg",
50 sensor_name=cam_sensor2,
51 ),
52 ],
53 metadata={"dut_status": "active"},
54 ego_vehicle_pose=EgoVehiclePose(
55 position=Position(x=1.0, y=1.0, z=1.0),
56 rotation=RotationQuaternion(w=0.01, x=1.01, y=1.01, z=1.01),
57 ),
58 ),
59 ALCSM.Frame(
60 frame_id="2",
61 relative_timestamp=500,
62 point_clouds=[
63 PointCloud(
64 filename="./examples/resources/point_cloud_RFL02.las",
65 sensor_name=lidar_sensor1,
66 ),
67 ],
68 images=[
69 Image(
70 filename="./examples/resources/img_RFC11.jpg",
71 sensor_name=cam_sensor1,
72 ),
73 Image(
74 filename="./examples/resources/img_RFC12.jpg",
75 sensor_name=cam_sensor2,
76 ),
77 ],
78 ego_vehicle_pose=EgoVehiclePose(
79 position=Position(x=2.0, y=2.0, z=2.0),
80 rotation=RotationQuaternion(w=0.01, x=2.01, y=2.01, z=2.01),
81 ),
82 ),
83 ALCSM.Frame(
84 frame_id="3",
85 relative_timestamp=1000,
86 point_clouds=[
87 PointCloud(
88 filename="./examples/resources/point_cloud_RFL02.csv",
89 sensor_name=lidar_sensor1,
90 ),
91 ],
92 images=[
93 Image(
94 filename="./examples/resources/img_RFC11.jpg",
95 sensor_name=cam_sensor1,
96 ),
97 Image(
98 filename="./examples/resources/img_RFC12.jpg",
99 sensor_name=cam_sensor2,
100 ),
101 ],
102 ego_vehicle_pose=EgoVehiclePose(
103 position=Position(x=3.0, y=3.0, z=3.0),
104 rotation=RotationQuaternion(w=0.01, x=2.01, y=2.01, z=2.01),
105 ),
106 ),
107 ],
108 calibration_id=created_calibration.id,
109 metadata=metadata,
110 )
111
112 return client.aggregated_lidars_and_cameras_seq.create(scene, dryrun=dryrun, **kwargs)
113
114
115if __name__ == "__main__":
116 setup_logging(level="INFO")
117 client = KognicIOClient()
118
119
120 project = "<project-identifier>"
121
122 run(client, project=project)