@@ -33,11 +33,12 @@ static inline void resetAgent(Engine &ctx, Entity agent) {
3333 auto agent_iface = ctx.get <AgentInterfaceEntity>(agent).e ;
3434 auto xCoord = ctx.get <Trajectory>(agent_iface).positions [0 ].x ;
3535 auto yCoord = ctx.get <Trajectory>(agent_iface).positions [0 ].y ;
36+ auto zCoord = ctx.get <Trajectory>(agent_iface).positions [0 ].z ;
3637 auto xVelocity = ctx.get <Trajectory>(agent_iface).velocities [0 ].x ;
3738 auto yVelocity = ctx.get <Trajectory>(agent_iface).velocities [0 ].y ;
3839 auto heading = ctx.get <Trajectory>(agent_iface).headings [0 ];
3940
40- ctx.get <Position>(agent) = Vector3{.x = xCoord, .y = yCoord, .z = 1 };
41+ ctx.get <Position>(agent) = Vector3{.x = xCoord, .y = yCoord, .z = zCoord };
4142 ctx.get <Rotation>(agent) = Quat::angleAxis (heading, madrona::math::up);
4243 if (ctx.get <ResponseType>(agent) == ResponseType::Static) {
4344 ctx.get <Velocity>(agent) = Velocity{Vector3::zero (), Vector3::zero ()};
@@ -58,7 +59,11 @@ static inline void populateExpertTrajectory(Engine &ctx, const Entity &agent, co
5859 auto &trajectory = ctx.get <Trajectory>(agent_iface);
5960 for (CountT i = 0 ; i < agentInit.numPositions ; i++)
6061 {
61- trajectory.positions [i] = Vector2{.x = agentInit.position [i].x - ctx.data ().mean .x , .y = agentInit.position [i].y - ctx.data ().mean .y };
62+ trajectory.positions [i] = Vector3{
63+ .x = agentInit.position [i].x - ctx.data ().mean .x ,
64+ .y = agentInit.position [i].y - ctx.data ().mean .y ,
65+ .z = agentInit.position [i].z - ctx.data ().mean .z
66+ };
6267 trajectory.velocities [i] = Vector2{.x = agentInit.velocity [i].x , .y = agentInit.velocity [i].y };
6368 trajectory.headings [i] = toRadians (agentInit.heading [i]);
6469 trajectory.valids [i] = (float )agentInit.valid [i];
@@ -75,7 +80,7 @@ static inline void populateExpertTrajectory(Engine &ctx, const Entity &agent, co
7580 }
7681
7782 Rotation rot = Quat::angleAxis (trajectory.headings [i], madrona::math::up);
78- Position pos = Vector3{.x = trajectory.positions [i].x , .y = trajectory.positions [i].y , .z = 1 };
83+ Position pos = Vector3{.x = trajectory.positions [i].x , .y = trajectory.positions [i].y , .z = trajectory. positions [i]. z };
7984 Velocity vel = {Vector3{.x = trajectory.velocities [i].x , .y = trajectory.velocities [i].y , .z = 0 }, Vector3::zero ()};
8085 Rotation targetRot = Quat::angleAxis (trajectory.headings [i+1 ], madrona::math::up);
8186 switch (ctx.data ().params .dynamicsModel ) {
@@ -91,7 +96,7 @@ static inline void populateExpertTrajectory(Engine &ctx, const Entity &agent, co
9196 }
9297
9398 case DynamicsModel::DeltaLocal: {
94- Position targetPos = Vector3{.x = trajectory.positions [i+1 ].x , .y = trajectory.positions [i+1 ].y , .z = 1 };
99+ Position targetPos = Vector3{.x = trajectory.positions [i+1 ].x , .y = trajectory.positions [i+1 ].y , .z = trajectory. positions [i+ 1 ]. z };
95100 trajectory.inverseActions [i] = inverseDeltaModel (rot, pos, targetRot, targetPos);
96101 break ;
97102 }
@@ -126,8 +131,11 @@ static inline Entity createAgent(Engine &ctx, const MapObject &agentInit) {
126131 ctx.get <Scale>(agent) *= consts::vehicleLengthScale;
127132 ctx.get <ObjectID>(agent) = ObjectID{(int32_t )SimObject::Agent};
128133 ctx.get <EntityType>(agent) = agentInit.type ;
129- ctx.get <Goal>(agent)= Goal{.position = Vector2{.x = agentInit.goalPosition .x - ctx.data ().mean .x , .y = agentInit.goalPosition .y - ctx.data ().mean .y }};
130-
134+ ctx.get <Goal>(agent)= Goal{.position = Vector3{
135+ .x = agentInit.goalPosition .x - ctx.data ().mean .x ,
136+ .y = agentInit.goalPosition .y - ctx.data ().mean .y ,
137+ .z = agentInit.goalPosition .z - ctx.data ().mean .z }};
138+
131139 populateExpertTrajectory (ctx, agent, agentInit);
132140
133141 // Applying custom rules
@@ -146,18 +154,16 @@ static inline Entity createAgent(Engine &ctx, const MapObject &agentInit) {
146154}
147155
148156static Entity makeRoadEdge (Engine &ctx, const MapRoad &roadInit, CountT j) {
149- const MapVector2 &p1 = roadInit.geometry [j];
150- const MapVector2 &p2 = roadInit.geometry [j+1 ]; // This is guaranteed to be within bounds
151-
152- float z = 1 + (roadInit.type == EntityType::RoadEdge ? consts::lidarRoadEdgeOffset : consts::lidarRoadLineOffset);
157+ const MapVector3 &p1 = roadInit.geometry [j];
158+ const MapVector3 &p2 = roadInit.geometry [j+1 ]; // This is guaranteed to be within bounds
153159
154- Vector3 start{.x = p1.x - ctx.data ().mean .x , .y = p1.y - ctx.data ().mean .y , .z = z};
155- Vector3 end{.x = p2.x - ctx.data ().mean .x , .y = p2.y - ctx.data ().mean .y , .z = z};
160+ Vector3 start{.x = p1.x - ctx.data ().mean .x , .y = p1.y - ctx.data ().mean .y , .z = p1. z - ctx. data (). mean . z };
161+ Vector3 end{.x = p2.x - ctx.data ().mean .x , .y = p2.y - ctx.data ().mean .y , .z = p2. z - ctx. data (). mean . z };
156162
157163 auto road_edge = ctx.makeRenderableEntity <PhysicsEntity>();
158164 ctx.get <RoadInterfaceEntity>(road_edge).e = ctx.makeEntity <RoadInterface>();
159165
160- auto pos = Vector3{.x = (start.x + end.x )/2 , .y = (start.y + end.y )/2 , .z = z };
166+ auto pos = Vector3{.x = (start.x + end.x )/2 , .y = (start.y + end.y )/2 , .z = (start. z + end. z )/ 2 };
161167 auto rot = Quat::angleAxis (atan2 (end.y - start.y , end.x - start.x ), madrona::math::up);
162168 auto scale = Diag3x3{.d0 = start.distance (end)/2 , .d1 = 0.1 , .d2 = 0.1 };
163169 setRoadEntitiesProps (ctx, road_edge, pos, rot, scale, roadInit.type , ObjectID{(int32_t )SimObject::Cube}, ResponseType::Static, roadInit.id , roadInit.mapType );
0 commit comments