Closed Berrazou closed 4 years ago
You need to do some adjustments see example below:
from osi3.osi_sensordata_pb2 import SensorData
import struct
def main():
"""Initialize SensorData"""
f = open("test_trace.osi", "ab")
sensordata = SensorData()
sensordata.version.version_major = 3
sensordata.version.version_minor = 0
sensordata.version.version_patch = 0
sensordata.timestamp.seconds = 0
sensordata.timestamp.nanos = 0
moving_object = sensordata.moving_object.add()
moving_object.header.tracking_id.value = 114
moving_object.header.ground_truth_id.add().value = 114
moving_object.header.existence_probability = 1
# Generate 10 OSI messages for 9 seconds
for i in range(10):
# Increment the time
sensordata.timestamp.seconds += 1
sensordata.timestamp.nanos += 100000
mv_obj = moving_object.candidate.add()
mv_obj.vehicle_classification.type = 2
mv_obj.probability = 1.0
moving_object.base.dimension.length = 5
moving_object.base.dimension.width = 2
moving_object.base.dimension.height = 1
moving_object.base.position.x = 0.0 + i
moving_object.base.position.y = 0.0
moving_object.base.position.z = 0.0
moving_object.base.orientation.roll = 0.0
moving_object.base.orientation.pitch = 0.0
moving_object.base.orientation.yaw = 0.0
"""Serialize"""
bytes_buffer = sensordata.SerializeToString()
f.write(struct.pack("<L", len(bytes_buffer)) + bytes_buffer)
f.close()
if __name__ == "__main__":
main()
Don't forget to change type in visualizer to SensorData
when playing the file :).
Thank you! just what I needed 👍 Now all the vehicles nearby are visualized with the host_vehicle as origin but there is no shape or drawing representing it (host_vehicle), should I add another car with the coordinates (0;0;0) all the time ?
@Berrazou yes you could since there is no representation of a host vehicle in sensordata. See example below:
from osi3.osi_sensordata_pb2 import SensorData
import struct
def main():
"""Initialize SensorData"""
f = open("test_trace.osi", "ab")
sensordata = SensorData()
sensordata.version.version_major = 3
sensordata.version.version_minor = 0
sensordata.version.version_patch = 0
sensordata.timestamp.seconds = 0
sensordata.timestamp.nanos = 0
moving_object = sensordata.moving_object.add()
moving_object.header.tracking_id.value = 114
moving_object.header.ground_truth_id.add().value = 114
moving_object.header.existence_probability = 1
host_object = sensordata.moving_object.add()
host_object.header.tracking_id.value = 0
host_object.header.ground_truth_id.add().value = 0
host_object.header.existence_probability = 1
# Generate 10 OSI messages for 9 seconds
for i in range(10):
# Increment the time
sensordata.timestamp.seconds += 1
sensordata.timestamp.nanos += 100000
hs_obj = host_object.candidate.add()
hs_obj.vehicle_classification.type = 2
hs_obj.probability = 1.0
host_object.base.dimension.length = 5
host_object.base.dimension.width = 2
host_object.base.dimension.height = 1
host_object.base.position.x = 0.0
host_object.base.position.y = 0.0
host_object.base.position.z = 0.0
host_object.base.orientation.roll = 0.0
host_object.base.orientation.pitch = 0.0
host_object.base.orientation.yaw = 0.0
mv_obj = moving_object.candidate.add()
mv_obj.vehicle_classification.type = 2
mv_obj.probability = 1.0
moving_object.base.dimension.length = 5
moving_object.base.dimension.width = 2
moving_object.base.dimension.height = 1
moving_object.base.position.x = 0.0 + i
moving_object.base.position.y = 3.0
moving_object.base.position.z = 3.0
moving_object.base.orientation.roll = 0.0
moving_object.base.orientation.pitch = 0.0
moving_object.base.orientation.yaw = 0.0
"""Serialize"""
bytes_buffer = sensordata.SerializeToString()
f.write(struct.pack("<L", len(bytes_buffer)) + bytes_buffer)
f.close()
if __name__ == "__main__":
main()
In osi-visualizer the host-vehicle is handled with the red arrow for now however :).
Exactly! thank you ! I am using the red arrow with a field of view that delimits the car edges And one last thing ^^ Could we switch or select different view angles in the visualizer ? like right now I am having an upper view or map view, could I switch it to a front view from the EGO-Vehicle ? as if I am the driver ?
@Berrazou no currently this is not possible but could be an interesting feature. One thing you can do to change the view angle is to rotate the view by holding the right mouse key that's all.
🤝 Thank you for the very valuable support Sir
I'm having a bit of trouble while creating a SensorData file that can be visualized
currently I am making a file containing the following characteristics for each timestamp i through this logic:
`osi_sensor = osi_sensordata_pb2.SensorData() osi_sensor.sensor_id.value = 1 osi_sensor.last_measurement_time.seconds = tt_secs osi_sensor.last_measurement_time.nanos = tt_nano osi_sensor.host_vehicle_location.position.x = x_ego osi_sensor.host_vehicle_location.position.y = y_ego
for each vehicle detected at that timestamp: osi_sensor.moving_object.header.tracking_id.value = id osi_sensor.moving_object.base.position.x = x osi_sensor.moving_object.base.position.y = y osi_sensor.moving_object.base.position.z = 0
outputFile.write(struct.pack("<L", len(osi_sensor.SerializeToString())) + osi_sensor.SerializeToString())`
Are there any other required fields that I am missing? is there an example for SensorData as the one available for SensorView anywhere ?
thanks for your support!