Skip to content

Commit fe6201e

Browse files
taehyung1.kimhadiTab
authored andcommitted
AUTO-4369: Updated coordinates after rotation
1 parent 3868b93 commit fe6201e

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

tests/test_EGO.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_different_spawns(self): # Check if EGO is spawned in the spawn position
3434
cmEqual(self, agent2.state.rotation, spawns[1].rotation, "Spawn Rotation 1")
3535

3636
def test_agent_velocity(self): # Check EGO velocity
37-
with SimConnection() as sim:
37+
with SimConnection(60) as sim:
3838
state = spawnState(sim)
3939
agent = self.create_EGO(sim)
4040
cmEqual(self, agent.state.velocity, state.velocity, "0 Velocity")
@@ -47,7 +47,7 @@ def test_agent_velocity(self): # Check EGO velocity
4747
cmEqual(self, agent.state.velocity, state.velocity, "50 Velocity")
4848

4949
def test_ego_different_directions(self): # Check that the xyz velocities equate to xyz changes in position
50-
with SimConnection(40) as sim:
50+
with SimConnection(60) as sim:
5151
state = spawnState(sim)
5252
forward = lgsvl.utils.transform_to_forward(state.transform)
5353
up = lgsvl.utils.transform_to_up(state.transform)
@@ -87,7 +87,7 @@ def test_speed(self): # check that speed returns a reasonable number
8787
def test_rotation_on_highway_ramp(self): # Check that vehicle is rotated when spawned on the highway ramp
8888
with SimConnection() as sim:
8989
state = spawnState(sim)
90-
state.transform.position = lgsvl.Vector(100.4229, 15.67488, -469.6401)
90+
state.transform.position = lgsvl.Vector(469.6401, 15.67488, 100.4229)
9191
ego = sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
9292
self.assertAlmostEqual(ego.state.rotation.z, state.rotation.z)
9393
sim.run(0.5)
@@ -204,7 +204,7 @@ def test_not_sticky_control(self): # Check that the a non sticky control is remo
204204
self.assertGreater(stickySpeed, finalSpeed)
205205

206206
def test_vary_throttle(self): # Check that different throttle values accelerate differently
207-
with SimConnection() as sim:
207+
with SimConnection(40) as sim:
208208
ego = sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, spawnState(sim))
209209
control = lgsvl.VehicleControl()
210210
control.throttle = 0.5
@@ -221,7 +221,7 @@ def test_vary_throttle(self): # Check that different throttle values accelerate
221221
self.assertLess(ego.state.speed, initialSpeed)
222222

223223
def test_vary_steering(self): # Check that different steering values turn the car differently
224-
with SimConnection() as sim:
224+
with SimConnection(40) as sim:
225225
ego = sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, spawnState(sim))
226226
control = lgsvl.VehicleControl()
227227
control.throttle = 0.5

tests/test_NPC.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_NPC_follow_lane(self): #Check if NPC can follow lane
6969
agentState = agent.state
7070
self.assertGreater(agentState.speed, 0)
7171
# self.assertAlmostEqual(agent.state.speed, 5.6, delta=1)
72-
self.assertLess(agent.state.position.x - sim.get_spawn()[0].position.x, 5.6)
72+
self.assertLess(agent.state.position.x - sim.get_spawn()[0].position.x, 5.6*2)
7373

7474
def test_rotate_NPC(self): # Check if NPC can be rotated
7575
with SimConnection() as sim:
@@ -78,11 +78,11 @@ def test_rotate_NPC(self): # Check if NPC can be rotated
7878
state.transform.position = state.position - 5 * right
7979
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
8080
agent = self.create_NPC(sim, "SUV")
81-
self.assertAlmostEqual(agent.state.transform.rotation.y, 194.823394, places=3)
81+
self.assertAlmostEqual(agent.state.transform.rotation.y, 104.823394, places=3)
8282
x = agent.state
83-
x.transform.rotation.y = 100
83+
x.transform.rotation.y = 10
8484
agent.state = x
85-
self.assertAlmostEqual(agent.state.transform.rotation.y, 100, delta=0.1)
85+
self.assertAlmostEqual(agent.state.transform.rotation.y, 10, delta=0.1)
8686

8787
def test_blank_agent(self): # Check that an exception is raised if a blank name is given
8888
with SimConnection() as sim:
@@ -299,10 +299,10 @@ def test_spawn_speed(self): # Checks that a spawned agent keeps the correct spee
299299
def test_lane_change_right(self):
300300
with SimConnection(40) as sim:
301301
state = lgsvl.AgentState()
302-
state.transform = sim.map_point_on_lane(lgsvl.Vector(40.85, -1.57, -4.49))
302+
state.transform = sim.map_point_on_lane(lgsvl.Vector(4.49, -1.57, 40.85))
303303
npc = sim.add_agent("SUV", lgsvl.AgentType.NPC, state)
304304

305-
state.transform = sim.map_point_on_lane(lgsvl.Vector(42.73, -1.57, -0.63))
305+
state.transform = sim.map_point_on_lane(lgsvl.Vector(0.63, -1.57, 42.73))
306306
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
307307
forward = lgsvl.utils.transform_to_forward(state.transform)
308308
target = state.position + 31 * forward
@@ -324,12 +324,12 @@ def on_lane_change(agent):
324324
def test_lane_change_right_missing_lane(self):
325325
with SimConnection(40) as sim:
326326
state = lgsvl.AgentState()
327-
state.transform = sim.map_point_on_lane(lgsvl.Vector(42.73, -1.57, -0.63))
327+
state.transform = sim.map_point_on_lane(lgsvl.Vector(0.63, -1.57, 42.73))
328328
npc = sim.add_agent("Hatchback", lgsvl.AgentType.NPC, state)
329329
forward = lgsvl.utils.transform_to_forward(state.transform)
330330
target = state.position + 42.75 * forward
331331

332-
state.transform = sim.map_point_on_lane(lgsvl.Vector(40.85, -1.57, -4.49))
332+
state.transform = sim.map_point_on_lane(lgsvl.Vector(4.49, -1.57, 40.85))
333333
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
334334

335335
npc.follow_closest_lane(True, 10)
@@ -349,10 +349,10 @@ def on_lane_change(agent):
349349
def test_lane_change_left(self):
350350
with SimConnection(40) as sim:
351351
state = lgsvl.AgentState()
352-
state.transform = sim.map_point_on_lane(lgsvl.Vector(40.85, -1.57, -4.49))
352+
state.transform = sim.map_point_on_lane(lgsvl.Vector(4.49, -1.57, 40.85))
353353
npc = sim.add_agent("SUV", lgsvl.AgentType.NPC, state)
354354

355-
state.transform = sim.map_point_on_lane(lgsvl.Vector(42.02, -1.79, -9.82))
355+
state.transform = sim.map_point_on_lane(lgsvl.Vector(9.82, -1.79, 42.02))
356356
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
357357
forward = lgsvl.utils.transform_to_forward(state.transform)
358358
target = state.position + 31 * forward
@@ -374,7 +374,7 @@ def on_lane_change(agent):
374374
def test_lane_change_left_opposing_traffic(self):
375375
with SimConnection(40) as sim:
376376
state = lgsvl.AgentState()
377-
state.transform = sim.map_point_on_lane(lgsvl.Vector(-40.292, -3.363, -78.962))
377+
state.transform = sim.map_point_on_lane(lgsvl.Vector(78.962, -3.363, -40.292))
378378
npc = sim.add_agent("SUV", lgsvl.AgentType.NPC, state)
379379
forward = lgsvl.utils.transform_to_forward(state.transform)
380380
target = state.position + 42.75 * forward
@@ -400,13 +400,13 @@ def on_lane_change(agent):
400400
def test_multiple_lane_changes(self):
401401
with SimConnection(120) as sim:
402402
state = lgsvl.AgentState()
403-
state.transform.position = lgsvl.Vector(239,10,180)
404-
state.transform.rotation = lgsvl.Vector(0,180,0)
403+
state.transform.position = lgsvl.Vector(-180,10,239)
404+
state.transform.rotation = lgsvl.Vector(0,90,0)
405405
sim.add_agent("XE_Rigged-apollo", lgsvl.AgentType.EGO, state)
406406

407407
state = lgsvl.AgentState()
408-
state.transform.position = lgsvl.Vector(234.5, 10, 175)
409-
state.transform.rotation = lgsvl.Vector(0.016, 180, 0)
408+
state.transform.position = lgsvl.Vector(-175, 10, 234.5)
409+
state.transform.rotation = lgsvl.Vector(0, 90, 0.016)
410410
npc = sim.add_agent("Sedan", lgsvl.AgentType.NPC, state)
411411

412412
npc.follow_closest_lane(True, 10)
@@ -455,9 +455,9 @@ def test_npc_control_exceptions(self):
455455
npc.apply_control(control)
456456

457457
def test_e_stop(self):
458-
with SimConnection() as sim:
458+
with SimConnection(60) as sim:
459459
state = lgsvl.AgentState()
460-
state.transform = sim.map_point_on_lane(lgsvl.Vector(-40.292, -3.363, -78.962))
460+
state.transform = sim.map_point_on_lane(lgsvl.Vector(78.962, -3.363, -40.292))
461461
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
462462
forward = lgsvl.utils.transform_to_forward(state.transform)
463463
state.transform.position = state.position + 10 * forward
@@ -478,7 +478,7 @@ def test_e_stop(self):
478478
def test_waypoint_speed(self):
479479
with SimConnection(60) as sim:
480480
state = lgsvl.AgentState()
481-
state.transform = sim.map_point_on_lane(lgsvl.Vector(-40.292, -3.363, -78.962))
481+
state.transform = sim.map_point_on_lane(lgsvl.Vector(78.962, -3.363, -40.292))
482482
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
483483
forward = lgsvl.utils.transform_to_forward(state.transform)
484484
up = lgsvl.utils.transform_to_up(state.transform)

tests/test_peds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def test_ped_creation(self): # Check if the different types of Peds can be creat
1919
state.transform.position = state.position - 4 * forward
2020
sim.add_agent("Jaguar2015XE (Apollo 3.0)", lgsvl.AgentType.EGO, state)
2121
for name in ["Bob", "EntrepreneurFemale", "Howard", "Johny", \
22-
"Pamela", "Presley", "Red", "Robin", "Stephen", "Zoe"]:
22+
"Pamela", "Presley", "Robin", "Stephen", "Zoe"]:
2323
agent = self.create_ped(sim, name, spawnState(sim))
2424
cmEqual(self, agent.state.position, sim.get_spawn()[0].position, name)
2525
self.assertEqual(agent.name, name)
2626

2727
def test_ped_random_walk(self): # Check if pedestrians can walk randomly
28-
with SimConnection() as sim:
28+
with SimConnection(40) as sim:
2929
state = spawnState(sim)
3030
forward = lgsvl.utils.transform_to_forward(state.transform)
3131
state.transform.position = state.position - 4 * forward

tests/test_simulator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ def test_raycast(self): # Check if raycasting works
7474
# Right
7575
hit = sim.raycast(p, right, layer_mask)
7676
self.assertTrue(hit)
77-
self.assertAlmostEqual(hit.distance, 15.0892992019653)
77+
self.assertAlmostEqual(hit.distance, 15.089282989502, places=3)
7878

7979
#Left
8080
hit = sim.raycast(p, -right, layer_mask)
8181
self.assertTrue(hit)
82-
self.assertAlmostEqual(hit.distance, 19.72922706604)
82+
self.assertAlmostEqual(hit.distance, 19.7292556762695, places=3)
8383

8484
#Back
8585
hit = sim.raycast(p, -forward, layer_mask)
@@ -96,7 +96,7 @@ def test_raycast(self): # Check if raycasting works
9696
# Down
9797
hit = sim.raycast(p, -up, layer_mask)
9898
self.assertTrue(hit)
99-
self.assertAlmostEqual(hit.distance, 1.08376359939575)
99+
self.assertAlmostEqual(hit.distance, 1.0837641954422, places=3)
100100

101101
def test_weather(self): # Check that the weather state can be read properly and changed
102102
with SimConnection() as sim:
@@ -217,7 +217,7 @@ def test_get_gps(self): # Checks that GPS reports the correct values
217217
self.assertAlmostEqual(gps.northing, 4141627.34000015)
218218
self.assertAlmostEqual(gps.easting, 587060.970000267)
219219
self.assertAlmostEqual(gps.altitude, -1.03600001335144)
220-
self.assertAlmostEqual(gps.orientation, -194.823394775391)
220+
self.assertAlmostEqual(gps.orientation, -104.823394775391)
221221

222222
def test_from_northing(self): # Check that position vectors are correctly generated given northing and easting
223223
with SimConnection() as sim:
@@ -236,7 +236,7 @@ def test_from_latlong(self): # Check that position vectors are correctly generat
236236
def test_from_alt_orient(self): # Check that position vectors are correctly generated with altitude and orientation
237237
with SimConnection() as sim:
238238
spawn = sim.get_spawn()[0]
239-
location = sim.map_from_gps(northing=4141627.34000015, easting=587060.970000267, altitude=-1.03600001335144, orientation=-194.823394775391)
239+
location = sim.map_from_gps(northing=4141627.34000015, easting=587060.970000267, altitude=-1.03600001335144, orientation=-104.823371887207)
240240
self.assertAlmostEqual(spawn.position.y, location.position.y, places=1)
241241
self.assertAlmostEqual(spawn.rotation.y, location.rotation.y, places=1)
242242

0 commit comments

Comments
 (0)