Skip to content

Commit 9e3abbb

Browse files
committed
Merge branch 'parking' of https://github.com/krishauser/GEMstack into parking
2 parents a33186e + a9980e6 commit 9e3abbb

5 files changed

Lines changed: 175 additions & 2 deletions

File tree

GEMstack/knowledge/defaults/computation_graph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ components:
5454
outputs:
5555
- signaling:
5656
inputs: [intent]
57-
outputs:
57+
outputs:

GEMstack/onboard/parking_entry_point.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def speed_callback(msg):
2121
def parking_space_callback(msg):
2222
global detected_space
2323
global endpoints
24-
detected_space = true
24+
detected_space = True
2525
endpoints = msg
2626
rospy.loginfo(f"Vehicle Speed: {msg.vehicle_speed} m/s | Valid: {msg.vehicle_speed_valid}")
2727

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from typing import List
2+
from ..component import Component
3+
from ...utils import serialization
4+
from ...state import Route,ObjectFrameEnum, AllState, PlannerEnum, MissionPlan
5+
import os
6+
import numpy as np
7+
import time
8+
9+
class ParkingSim(Component):
10+
def __init__(self):
11+
self.start_time = time.time()
12+
pass
13+
14+
def state_inputs(self):
15+
return ["all"]
16+
17+
def rate(self):
18+
return 10.0
19+
20+
def state_outputs(self)-> List[str]:
21+
return ["mission_plan"]
22+
23+
def update(self, state: AllState):
24+
# Calculate elapsed time since initialization.
25+
elapsed_time = time.time() - self.start_time
26+
27+
# After 4 seconds, change the mission plan to use PARKING.
28+
if elapsed_time >= 4.0:
29+
print("Entering parking mode")
30+
mission_plan = MissionPlan(1, 6, 0, PlannerEnum.PARKING)
31+
else:
32+
print("Entering RRT mode")
33+
mission_plan = MissionPlan(1, 6, 0, PlannerEnum.RRT_STAR)
34+
35+
print("ParkingSim update with state:",mission_plan)
36+
return mission_plan
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
from typing import Dict, List
3+
4+
import numpy as np
5+
from GEMstack.onboard.component import Component
6+
from GEMstack.state.agent import AgentState
7+
from GEMstack.state.all import AllState
8+
from GEMstack.state.physical_object import ObjectFrameEnum
9+
from GEMstack.state.route import PlannerEnum, Route
10+
11+
12+
13+
class RoutePlanningComponent(Component):
14+
"""Reads a route from disk and returns it as the desired route."""
15+
def __init__(self):
16+
print("Route Planning Component init")
17+
self.planner = None
18+
self.route = None
19+
20+
def state_inputs(self):
21+
return ["all"]
22+
23+
def state_outputs(self) -> List[str]:
24+
return ['route']
25+
26+
def rate(self):
27+
return 10.0
28+
29+
def update(self, state: AllState):
30+
# print("Route Planner's mission:", state.mission_plan.planner_type.value)
31+
# print("type of mission plan:", type(PlannerEnum.RRT_STAR))
32+
# print("Route Planner's mission:", state.mission_plan.planner_type.value == PlannerEnum.RRT_STAR.value)
33+
# print("Route Planner's mission:", state.mission_plan.planner_type.value == PlannerEnum.PARKING.value)
34+
# print("Mission plan:", state.mission_plan)
35+
# print("Vehicle x:", state.vehicle.pose.x)
36+
# print("Vehicle y:", state.vehicle.pose.y)
37+
# print("Vehicle yaw:", state.vehicle.pose.yaw)
38+
if state.mission_plan.planner_type.value == PlannerEnum.PARKING.value:
39+
print("I am in PARKING mode")
40+
# Return a route after doing some processing based on mission plan REMOVE ONCE OTHER PLANNERS ARE IMPLEMENTED
41+
base_path = os.path.dirname(__file__)
42+
file_path = os.path.join(base_path, "../../knowledge/routes/forward_15m_extra.csv")
43+
44+
waypoints = np.loadtxt(file_path, delimiter=',', dtype=float)
45+
if waypoints.shape[1] == 3:
46+
waypoints = waypoints[:,:2]
47+
print("waypoints", waypoints)
48+
self.route = Route(frame=ObjectFrameEnum.START,points=waypoints.tolist())
49+
elif state.mission_plan.planner_type.value == PlannerEnum.RRT_STAR.value:
50+
print("I am in RRT mode")
51+
52+
else:
53+
print("Unknown mode")
54+
55+
return self.route

launch/parking_route_planner.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
description: "Drive the GEM vehicle along a fixed route (currently xyhead_highbay_backlot_p.csv)"
2+
mode: hardware
3+
vehicle_interface: gem_hardware.GEMHardwareInterface
4+
mission_execution: StandardExecutor
5+
# require_engaged: False
6+
# Recovery behavior after a component failure
7+
recovery:
8+
planning:
9+
trajectory_tracking:
10+
type: recovery.StopTrajectoryTracker
11+
print: False
12+
# Driving behavior for the GEM vehicle following a fixed route
13+
drive:
14+
perception:
15+
state_estimation : GNSSStateEstimator
16+
perception_normalization : StandardPerceptionNormalizer
17+
planning:
18+
parking_component:
19+
type: ParkingSim
20+
route_planning_component:
21+
type: RoutePlanningComponent
22+
motion_planning: longitudinal_planning.YieldTrajectoryPlanner
23+
# type: RouteToTrajectoryPlanner
24+
# args: [null] #desired speed in m/s. If null, this will keep the route untimed for the trajectory tracker
25+
trajectory_tracking:
26+
type: pure_pursuit.PurePursuitTrajectoryTracker
27+
# args: [null]
28+
# args: {desired_speed: 2.5} #approximately 5mph
29+
print: False
30+
31+
log:
32+
# Specify the top-level folder to save the log files. Default is 'logs'
33+
#folder : 'logs'
34+
# If prefix is specified, then the log folder will be named with the prefix followed by the date and time. Default no prefix
35+
#prefix : 'fixed_route_'
36+
# If suffix is specified, then logs will output to folder/prefix+suffix. Default uses date and time as the suffix
37+
#suffix : 'test3'
38+
# Specify which ros topics to record to vehicle.bag. Default records nothing. This records the "standard" ROS topics.
39+
ros_topics : ['/septentrio_gnss/insnavgeod','/pacmod/parsed_tx/vehicle_speed_rpt']
40+
# Specify options to pass to rosbag record. Default is no options.
41+
#rosbag_options : '--split --size=1024'
42+
# If True, then record all readings / commands of the vehicle interface. Default False
43+
vehicle_interface : True
44+
# Specify which components to record to behavior.json. Default records nothing
45+
components : ['state_estimation','trajectory_tracking']
46+
# Specify which components of state to record to state.json. Default records nothing
47+
#state: ['all']
48+
# Specify the rate in Hz at which to record state to state.json. Default records at the pipeline's rate
49+
#state_rate: 10
50+
replay: # Add items here to set certain topics / inputs to be replayed from logs
51+
# Specify which log folder to replay from
52+
log:
53+
# For replaying sensor data, try !include "../knowledge/defaults/standard_sensor_ros_topics.yaml"
54+
ros_topics : []
55+
components : []
56+
57+
#usually can keep this constant
58+
computation_graph: !include "../GEMstack/knowledge/defaults/computation_graph.yaml"
59+
60+
after:
61+
show_log_folder: True #set to false to avoid showing the log folder
62+
63+
#on load, variants will overload the settingsNone structure
64+
variants:
65+
#sim variant doesn't execute on the real vehicle
66+
#real variant executes on the real robot
67+
sim:
68+
run:
69+
mode: simulation
70+
vehicle_interface:
71+
type: gem_simulator.GEMDoubleIntegratorSimulationInterface
72+
args:
73+
scene: !relative_path '../scenes/xyhead_demo.yaml'
74+
75+
drive:
76+
perception:
77+
state_estimation : OmniscientStateEstimator
78+
agent_detection : OmniscientAgentDetector
79+
visualization: [!include "klampt_visualization.yaml", !include "mpl_visualization.yaml"]
80+
log_ros:
81+
log:
82+
ros_topics : !include "../GEMstack/knowledge/defaults/standard_ros_topics.yaml"

0 commit comments

Comments
 (0)