Skip to content

Commit 3697293

Browse files
authored
Merge pull request #10 from openMSL/9-object-id-missing-in-trafficupdate-output
* Add object ID and timestamps to outputs
2 parents 1b8e2f3 + 40b221a commit 3697293

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/MyTrafficParticipantModel.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ void MyTrafficParticipantModel::Step(const osi3::SensorView& sensor_view_in,
3535
double delta_time = time - last_time_step_;
3636
osi3::Identifier ego_id = sensor_view_in.global_ground_truth().host_vehicle_id();
3737
traffic_command_update_out.mutable_traffic_participant_id()->set_value(ego_id.value());
38+
traffic_command_update_out.mutable_timestamp()->set_nanos(sensor_view_in.timestamp().nanos());
39+
traffic_command_update_out.mutable_timestamp()->set_seconds(sensor_view_in.timestamp().seconds());
3840

3941
if (traffic_command_in.action_size() > 0)
4042
{
@@ -112,12 +114,15 @@ void MyTrafficParticipantModel::Step(const osi3::SensorView& sensor_view_in,
112114
}
113115
}
114116

117+
traffic_update_out.mutable_timestamp()->set_nanos(sensor_view_in.timestamp().nanos());
118+
traffic_update_out.mutable_timestamp()->set_seconds(sensor_view_in.timestamp().seconds());
115119
for (const osi3::MovingObject& obj : sensor_view_in.global_ground_truth().moving_object())
116120
{
117121
if (obj.id().value() == ego_id.value())
118122
{
119123
// Simple constant acceleration model
120124
auto* update = traffic_update_out.add_update();
125+
update->mutable_id()->set_value(obj.id().value());
121126
double velocity = obj.base().velocity().x();
122127
double new_velocity = velocity + acceleration_m_s_ * delta_time;
123128
if (new_velocity <= target_velocity_) // check if new velocity is lower than the set maximum

0 commit comments

Comments
 (0)