Skip to content

Commit e6ec341

Browse files
authored
Merge pull request #127 from krishauser/A4_planning
A4 planning merge request into teamA branch
2 parents d777ab6 + 91632e2 commit e6ec341

9 files changed

Lines changed: 649 additions & 170 deletions

File tree

GEMstack/knowledge/vehicle/gem_e4_sensor_environment.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ ros_topics:
22
top_lidar: /ouster/points
33
front_camera: /oak/rgb/image_raw
44
front_depth: /oak/stereo/image_raw
5-
gnss: /novatel/inspva
5+
gnss: /septentrio_gnss/insnavgeod
6+

GEMstack/onboard/interface/gem_hardware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .gem import *
22
from ...utils import settings
33
import math
4-
4+
import time
55
# ROS Headers
66
import rospy
77
from std_msgs.msg import String, Bool, Float32, Float64
@@ -178,13 +178,15 @@ def callback_with_gnss_reading(inspva_msg: Inspva):
178178
else:
179179
def callback_with_gnss_reading(msg: INSNavGeod):
180180
pose = ObjectPose(ObjectFrameEnum.GLOBAL,
181+
t = time.time(),
181182
x=msg.longitude,
182183
y=msg.latitude,
183184
z=msg.height,
184185
yaw=math.radians(msg.heading), #heading from north in degrees (TODO: maybe?? check this)
185186
roll=math.radians(msg.roll),
186187
pitch=math.radians(msg.pitch),
187188
)
189+
# print("@@@@@, POSE", pose.x, pose.y)
188190
speed = np.sqrt(msg.ve**2 + msg.vn**2)
189191
callback(GNSSReading(pose,speed,('error' if msg.error else 'ok')))
190192
self.gnss_sub = rospy.Subscriber(topic, INSNavGeod, callback_with_gnss_reading)

GEMstack/onboard/perception/state_estimation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def state_outputs(self) -> List[str]:
3737
return ['vehicle']
3838

3939
def healthy(self):
40-
return True
41-
# return self.gnss_pose is not None TODO: fix
40+
# return True
41+
return self.gnss_pose is not None
4242

4343
def update(self) -> VehicleState:
4444
if self.gnss_pose is None:

GEMstack/onboard/planning/longitudinal_planning.py

Lines changed: 590 additions & 79 deletions
Large diffs are not rendered by default.

launch/pedestrian_detection.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ drive:
1919
route_planning:
2020
type: StaticRoutePlanner
2121
args: [!relative_path '../GEMstack/knowledge/routes/forward_15m.csv','start']
22-
motion_planning: longitudinal_planning.YieldTrajectoryPlanner
22+
motion_planning:
23+
type: longitudinal_planning.YieldTrajectoryPlanner
24+
args:
25+
mode: 'real'
26+
planner: 'dt' # 'milestone', 'dt', or 'dx'
2327
trajectory_tracking:
2428
type: pure_pursuit.PurePursuitTrajectoryTracker
2529
print: False
@@ -97,3 +101,8 @@ variants:
97101
# agent_detection : pedestrian_detection.FakePedestrianDetector2D
98102
agent_detection : OmniscientAgentDetector #this option reads agents from the simulator
99103
state_estimation : OmniscientStateEstimator
104+
planning:
105+
motion_planning:
106+
type: longitudinal_planning.YieldTrajectoryPlanner
107+
args:
108+
mode: 'simulation'

scenes/xyhead_demo.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ agents:
33
ped1:
44
type: pedestrian
55
position: [15.0, 2.0]
6+
# position: [10.0, 2.0]
67
nominal_velocity: 0.5
78
target: [15.0,10.0]
9+
# target: [10.0,10.0]
810
behavior: loop
911

test_longitudinal_plan.py

Lines changed: 0 additions & 80 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#needed to import GEMstack from top level directory
2+
import sys
3+
import os
4+
sys.path.append(os.getcwd())
5+
6+
from GEMstack.onboard.planning.longitudinal_planning import CollisionDetector
7+
import time
8+
9+
if __name__ == "__main__":
10+
# Vehicle parameters. x, y, theta (angle in radians)
11+
x1, y1, t1 = 4.0, 5.0, 0
12+
# Pedestrian parameters. x, y, theta (angle in radians)
13+
x2, y2, t2 = 15.0, 2.1, 0
14+
# Velocity vectors: [vx, vy]
15+
v1 = [0.1, 0] # Vehicle speed vector
16+
v2 = [0, 0.5] # Pedestrian speed vector
17+
# Total simulation time
18+
total_time = 10.0
19+
20+
desired_speed = 0.5
21+
acceleration = -0.5
22+
23+
# Create and run the simulation.
24+
start_time = time.time()
25+
# Simulate with the above parameters: Whether to hit without decelerating
26+
sim = CollisionDetector(x1, y1, t1, x2, y2, t2, v1, v2, total_time, desired_speed, acceleration)
27+
28+
collision_distance = sim.run(is_displayed=True)
29+
print(f"Collision distance: {collision_distance}")
30+
# print(f"Simulation took {time.time() - start_time:.3f} seconds.")

testing/test_longitudinal_plan.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
from GEMstack.state import Path, ObjectFrameEnum
77
from GEMstack.onboard.planning.longitudinal_planning import longitudinal_plan,longitudinal_brake
88
import matplotlib.pyplot as plt
9-
9+
10+
11+
mode = "milestone" # milestone, dt, dx
12+
13+
1014
def test_longitudinal_planning():
1115
test_path = Path(ObjectFrameEnum.START,[(0,0),(1,0),(2,0),(3,0),(4,0),(5,0),(6,0)])
1216
test_path2 = Path(ObjectFrameEnum.START,[(5,0),(6,1),(7,2),(9,4)])
@@ -39,7 +43,7 @@ def test_longitudinal_planning():
3943
plt.ylabel('velocity')
4044
plt.show()
4145

42-
test_traj = longitudinal_plan(test_path, 1.1, 2.0, 3.0, 0.0)
46+
test_traj = longitudinal_plan(test_path, 1.1, 2.0, 3.0, 0.0, mode)
4347
assert (t1 < t2 for (t1,t2) in zip(test_traj.times[:-1],test_traj.times[1:]) )
4448
plt.plot(test_traj.times,[p[0] for p in test_traj.points])
4549
plt.title("Accelerating from 0 m/s")
@@ -54,7 +58,7 @@ def test_longitudinal_planning():
5458
plt.show()
5559

5660

57-
test_traj = longitudinal_plan(test_path, 1.0, 2.0, 3.0, 2.0)
61+
test_traj = longitudinal_plan(test_path, 1.0, 2.0, 3.0, 2.0, mode)
5862
assert (t1 < t2 for (t1,t2) in zip(test_traj.times[:-1],test_traj.times[1:]) )
5963
plt.plot(test_traj.times,[p[0] for p in test_traj.points])
6064
plt.title("Accelerating from 2 m/s")
@@ -69,7 +73,7 @@ def test_longitudinal_planning():
6973
plt.show()
7074

7175

72-
test_traj = longitudinal_plan(test_path, 0.0, 2.0, 3.0, 3.1)
76+
test_traj = longitudinal_plan(test_path, 0.0, 2.0, 3.0, 3.1, mode)
7377
assert (t1 < t2 for (t1,t2) in zip(test_traj.times[:-1],test_traj.times[1:]) )
7478
plt.plot(test_traj.times,[p[0] for p in test_traj.points])
7579
plt.title("Keeping constant velocity at 3.1 m/s")
@@ -83,7 +87,7 @@ def test_longitudinal_planning():
8387
plt.ylabel('velocity')
8488
plt.show()
8589

86-
test_traj = longitudinal_plan(test_path, 2.0, 2.0, 20.0, 10.0)
90+
test_traj = longitudinal_plan(test_path, 2.0, 2.0, 20.0, 10.0, mode)
8791
assert (t1 < t2 for (t1,t2) in zip(test_traj.times[:-1],test_traj.times[1:]) )
8892
plt.plot(test_traj.times,[p[0] for p in test_traj.points])
8993
plt.title("Too little time to stop, starting at 10 m/s")
@@ -110,7 +114,7 @@ def test_longitudinal_planning():
110114
plt.ylabel('velocity')
111115
plt.show()
112116

113-
test_traj = longitudinal_plan(test_path2, 1.0, 2.0, 3.0, 0.0)
117+
test_traj = longitudinal_plan(test_path2, 1.0, 2.0, 3.0, 0.0, mode)
114118
plt.plot(test_traj.times,[p[0] for p in test_traj.points])
115119
plt.title("Nonuniform planning")
116120
plt.xlabel('time')

0 commit comments

Comments
 (0)