Skip to content

Commit d7ab7cb

Browse files
compiler error fixes
1 parent f456850 commit d7ab7cb

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/knn.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ relativeObservation(const gpudrive::MapObservation &absoluteObservation,
3939

4040
return gpudrive::MapObservation{
4141
.position = referenceRotation.inv()
42-
.rotateVec({relativePosition.x, relativePosition.y, relativePosition.z})
43-
.xyz(),
42+
.rotateVec({relativePosition.x, relativePosition.y, relativePosition.z}),
4443
.scale = absoluteObservation.scale,
4544
.heading = gpudrive::utils::quatToYaw(referenceRotation.inv() * madrona::math::Quat::angleAxis(absoluteObservation.heading,madrona::math::up)),
4645
.type = absoluteObservation.type};

src/level_gen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ static Entity makeRoadEdge(Engine &ctx, const MapRoad &roadInit, CountT j) {
174174
// Z rotation (pitch)
175175
float horizontalDist = sqrt(dx*dx + dy*dy);
176176
float pitchAngle = atan2(dz, horizontalDist);
177-
Vector3 pitchAxis = Vector3::cross(Vector3{dx/horizontalDist, dy/horizontalDist, 0}, madrona::math::up);
177+
Vector3 horizontalDir{dx/horizontalDist, dy/horizontalDist, 0};
178+
Vector3 pitchAxis = horizontalDir.cross(madrona::math::up);
178179
auto pitchRot = Quat::angleAxis(pitchAngle, pitchAxis);
179180

180181
// Combined rotation

src/sim.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ inline void collectSelfObsSystem(Engine &ctx,
163163
auto &self_obs = ctx.get<SelfObservation>(agent_iface.e);
164164
self_obs.speed = vel.linear.length();
165165
self_obs.vehicle_size = size;
166-
auto goalPos = goal.position - pos.xy();
167-
self_obs.goal.position = rot.inv().rotateVec({goalPos.x, goalPos.y, 0}).xy();
166+
auto goalPos = goal.position - pos;
167+
self_obs.goal.position = rot.inv().rotateVec({goalPos.x, goalPos.y, goalPos.z});
168168

169169
auto hasCollided = collisionEvent.hasCollided.load_relaxed();
170170
self_obs.collisionState = hasCollided ? 1.f : 0.f;
@@ -231,13 +231,13 @@ inline void collectMapObservationsSystem(Engine &ctx,
231231
const auto alg = ctx.data().params.roadObservationAlgorithm;
232232
if (alg == FindRoadObservationsWith::KNearestEntitiesWithRadiusFiltering) {
233233
selectKNearestRoadEntities<consts::kMaxAgentMapObservationsCount>(
234-
ctx, rot, pos.xy(), map_obs.obs);
234+
ctx, rot, pos, map_obs.obs);
235235
return;
236236
}
237237

238238
assert(alg == FindRoadObservationsWith::AllEntitiesWithRadiusFiltering);
239239

240-
utils::ReferenceFrame referenceFrame(pos.xy(), rot);
240+
utils::ReferenceFrame referenceFrame(pos, rot);
241241
CountT arrIndex = 0; CountT roadIdx = 0;
242242
while(roadIdx < ctx.data().numRoads && arrIndex < consts::kMaxAgentMapObservationsCount) {
243243
Entity road = ctx.data().roads[roadIdx++];
@@ -452,13 +452,13 @@ inline void rewardSystem(Engine &ctx,
452452
const auto &rewardType = ctx.data().params.rewardParams.rewardType;
453453
if(rewardType == RewardType::DistanceBased)
454454
{
455-
float dist = (position.xy() - goal.position).length();
455+
float dist = (position - goal.position).length();
456456
float reward = -dist;
457457
out_reward.v = reward;
458458
}
459459
else if(rewardType == RewardType::OnGoalAchieved)
460460
{
461-
float dist = (position.xy() - goal.position).length();
461+
float dist = (position - goal.position).length();
462462
float reward = (dist < ctx.data().params.rewardParams.distanceToGoalThreshold) ? 1.f : 0.f;
463463
out_reward.v = reward;
464464
}
@@ -502,7 +502,7 @@ inline void doneSystem(Engine &ctx,
502502
// An agent can be done early if it reaches the goal
503503
if (done.v != 1 || info.reachedGoal != 1)
504504
{
505-
float dist = (position.xy() - goal.position).length();
505+
float dist = (position - goal.position).length();
506506
if (dist < ctx.data().params.rewardParams.distanceToGoalThreshold)
507507
{
508508
done.v = 1;

src/utils.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ inline float quatToYaw(madrona::base::Rotation q) {
2626

2727
class ReferenceFrame {
2828
public:
29-
ReferenceFrame(const madrona::math::Vector2 &position,
29+
ReferenceFrame(const madrona::math::Vector3 &position,
3030
const madrona::base::Rotation &rotation)
3131
: referenceRotation(rotation), referencePosition(position) {}
3232

@@ -47,20 +47,19 @@ class ReferenceFrame {
4747
}
4848

4949
private:
50-
madrona::math::Vector2
50+
madrona::math::Vector3
5151
relative(const madrona::math::Vector3 &absolutePos) const {
52-
auto relativePosition = absolutePos.xy() - referencePosition;
52+
auto relativePosition = absolutePos - referencePosition;
5353

5454
return referenceRotation.inv()
55-
.rotateVec({relativePosition.x, relativePosition.y, 0})
56-
.xy();
55+
.rotateVec({relativePosition.x, relativePosition.y, relativePosition.z});
5756
}
5857

5958
float relative(const madrona::base::Rotation &absoluteRot) const {
6059
return gpudrive::utils::quatToYaw(referenceRotation.inv() * absoluteRot);
6160
}
6261

63-
madrona::math::Vector2 referencePosition;
62+
madrona::math::Vector3 referencePosition;
6463
madrona::base::Rotation referenceRotation;
6564
};
6665
}}

0 commit comments

Comments
 (0)