forked from PufferAI/PufferLib
-
Notifications
You must be signed in to change notification settings - Fork 15
Puffer Scenario v0 #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vcharraut
wants to merge
35
commits into
main
Choose a base branch
from
vcha/new_puffer_data
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,207
−855
Open
Puffer Scenario v0 #107
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
e442fe3
Add comments to Entity struct
vcharraut 41d5f80
Add DynamicAgent, RoadMapElement, and TrafficControlElement structs w…
vcharraut 168138f
Refactor code structure for improved readability and maintainability
vcharraut 7c14bd7
Fix memory management for dynamic agents and update loading function
vcharraut 600f6c3
Add road and traffic control type definitions and utility functions
vcharraut 12c6196
Refactor agent initialization and metrics handling in Drive struct
vcharraut 8e4c085
Add test data
vcharraut 6433bea
Enhance DynamicAgent structure with additional logging and simulation…
vcharraut 6577a9f
Refactor drawing logic for dynamic agents and improve road edge checks
vcharraut 8f44bf4
Add unnormalize_road_type function to map normalized types to road types
vcharraut e6295dd
Add simulation dimensions to agent state in set_start_position function
vcharraut 9434b83
Fix condition checks for agent type in set_start_position and compute…
vcharraut d38827b
Improve grid map initialization and observation computation by adding…
vcharraut d257ffa
Remove goal_radius from DynamicAgent struct to streamline goal positi…
vcharraut 91710e7
Update RoadMapElement and TrafficControlElement structures for clarit…
vcharraut b678599
Update traffic control type definitions for consistency
vcharraut 96d5521
Add bounds check to skip out-of-bounds entities in grid map initializ…
vcharraut d770388
Merge branch 'main' into vcha/new_puffer_data
vcharraut 8f9f0b4
Delete test_data
vcharraut f5dcb8f
Refactor DynamicAgent structure and enhance Drive metadata handling
vcharraut 4d290df
Add changes from main
vcharraut c91e910
Merge main
vcharraut 53daa76
Merge remote-tracking branch 'emergelab/main' into vcha/new_puffer_data
vcharraut ce2682f
Refactor road type definitions and update Drive struct for log length
vcharraut 1516af3
Add temporary skip for traffic_lights
vcharraut dfca469
Add misc changes
vcharraut ad386ea
Add freeing in c_reset
vcharraut 4e7a60d
Comment out agent dimension assignments in move_expert function
vcharraut b4255c6
Add map_index to Drive struct and update load_map_binary function
vcharraut 5c9e178
Merge branch 'main' into vcha/new_puffer_data
vcharraut fe425c1
Format commit
vcharraut d43ae55
Fix DRIVEWAY definition and add is_road function for road type checks
vcharraut aebb422
Remove unused classes from road encoder (CROSSWALK, SPEED_BUMP, DRIVE…
vcharraut 50cb68c
Refactor DynamicAgent to Agent and update related functions for consi…
vcharraut e9e83a4
Fix one-hot encoding for road categories in Drive class
vcharraut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| #define UNKNOWN 0 | ||
|
|
||
| // -- AGENT TYPE | ||
| #define VEHICLE 1 | ||
| #define PEDESTRIAN 2 | ||
| #define CYCLIST 3 | ||
| #define OTHER 4 | ||
|
|
||
| // -- ROAD TYPE | ||
| #define LANE_FREEWAY 1 | ||
| #define LANE_SURFACE_STREET 2 | ||
| #define LANE_BIKE_LANE 3 | ||
|
|
||
| #define ROAD_LINE_UNKNOWN 10 | ||
| #define ROAD_LINE_BROKEN_SINGLE_WHITE 11 | ||
| #define ROAD_LINE_SOLID_SINGLE_WHITE 12 | ||
| #define ROAD_LINE_SOLID_DOUBLE_WHITE 13 | ||
| #define ROAD_LINE_BROKEN_SINGLE_YELLOW 14 | ||
| #define ROAD_LINE_BROKEN_DOUBLE_YELLOW 15 | ||
| #define ROAD_LINE_SOLID_SINGLE_YELLOW 16 | ||
| #define ROAD_LINE_SOLID_DOUBLE_YELLOW 17 | ||
| #define ROAD_LINE_PASSING_DOUBLE_YELLOW 18 | ||
|
|
||
| #define ROAD_EDGE_UNKNOWN 20 | ||
| #define ROAD_EDGE_BOUNDARY 21 | ||
| #define ROAD_EDGE_MEDIAN 22 | ||
| #define ROAD_EDGE_SIDEWALK 23 | ||
|
|
||
| #define CROSSWALK 31 | ||
| #define SPEED_BUMP 32 | ||
| #define DRIVEWAY 33 | ||
|
|
||
| // -- TRAFFIC CONTROL TYPE | ||
| #define TRAFFIC_LIGHT 1 | ||
| #define STOP_SIGN 2 | ||
| #define YIELD_SIGN 3 | ||
| #define SPEED_LIMIT_SIGN 4 | ||
|
|
||
|
|
||
| int is_road_lane(int type){ | ||
| return (type >= 0 && type <= 9); | ||
| } | ||
|
|
||
| int is_drivable_road_lane(int type){ | ||
| return (type == LANE_FREEWAY || type == LANE_SURFACE_STREET); | ||
| } | ||
|
|
||
| int is_road_line(int type){ | ||
| return (type >= 10 && type <= 19); | ||
| } | ||
|
|
||
| int is_road_edge(int type){ | ||
| return (type >= 20 && type <= 29); | ||
| } | ||
|
|
||
| int is_road(int type){ | ||
| return is_road_lane(type) || is_road_line(type) || is_road_edge(type); | ||
| } | ||
|
|
||
| int is_controllable_agent(int type){ | ||
| return (type == VEHICLE || type == PEDESTRIAN || type == CYCLIST); | ||
| } | ||
|
|
||
| int normalize_road_type(int type){ | ||
| if(is_road_lane(type)){ | ||
| return 0; | ||
| } else if(is_road_line(type)){ | ||
| return 1; | ||
| } else if(is_road_edge(type)){ | ||
| return 2; | ||
| } else { | ||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| int unnormalize_road_type(int norm_type){ | ||
| if(norm_type == 0){ | ||
| return LANE_SURFACE_STREET; | ||
| } else if(norm_type == 1){ | ||
| return ROAD_LINE_BROKEN_SINGLE_WHITE; | ||
| } else if(norm_type == 2){ | ||
| return ROAD_EDGE_BOUNDARY; | ||
| } else { | ||
| return -1; // Invalid | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| struct Agent { | ||
| int id; | ||
| int type; | ||
|
|
||
| // Log trajectory | ||
| int trajectory_length; | ||
| float* log_trajectory_x; | ||
| float* log_trajectory_y; | ||
| float* log_trajectory_z; | ||
| float* log_heading; | ||
| float* log_velocity_x; | ||
| float* log_velocity_y; | ||
| float* log_length; | ||
| float* log_width; | ||
| float* log_height; | ||
| int* log_valid; | ||
|
|
||
| // Simulation state | ||
| float sim_x; | ||
| float sim_y; | ||
| float sim_z; | ||
| float sim_heading; | ||
| float sim_vx; | ||
| float sim_vy; | ||
| float sim_length; | ||
| float sim_width; | ||
| float sim_height; | ||
| int sim_valid; | ||
|
|
||
| // Route information | ||
| int route_length; | ||
| int* route; | ||
|
|
||
| // Metrics and status tracking | ||
| int collision_state; | ||
| float metrics_array[5]; // [collision, offroad, reached_goal, lane_aligned, avg_displacement_error] | ||
| int current_lane_idx; | ||
| int collided_before_goal; | ||
| int sampled_new_goal; | ||
| int reached_goal_this_episode; | ||
| int num_goals_reached; | ||
| int active_agent; | ||
| int mark_as_expert; | ||
| float cumulative_displacement; | ||
| int displacement_sample_count; | ||
|
|
||
| // Goal positions | ||
| float goal_position_x; | ||
| float goal_position_y; | ||
| float goal_position_z; | ||
| float init_goal_x; // Initialized from goal_position | ||
| float init_goal_y; // Initialized from goal_position | ||
|
|
||
| // Respawn tracking | ||
| int respawn_timestep; | ||
| int respawn_count; | ||
|
|
||
| int stopped; // 0/1 -> freeze if set | ||
| int removed; //0/1 -> remove from sim if set | ||
|
|
||
| // Jerk dynamics | ||
| float a_long; | ||
| float a_lat; | ||
| float jerk_long; | ||
| float jerk_lat; | ||
| float steering_angle; | ||
| float wheelbase; | ||
| }; | ||
|
|
||
| struct RoadMapElement { | ||
| int id; | ||
| int type; | ||
|
|
||
| int segment_length; | ||
| float* x; | ||
| float* y; | ||
| float* z; | ||
|
|
||
| // Lane specific info | ||
| int num_entries; | ||
| int* entry_lanes; | ||
| int num_exits; | ||
| int* exit_lanes; | ||
| float speed_limit; | ||
| }; | ||
|
|
||
| struct TrafficControlElement { | ||
| int id; | ||
| int type; | ||
|
|
||
| int state_length; | ||
| int* states; | ||
| float x; | ||
| float y; | ||
| float z; | ||
| int controlled_lane; | ||
| }; | ||
|
|
||
| void free_agent(struct Agent* agent){ | ||
| free(agent->log_trajectory_x); | ||
| free(agent->log_trajectory_y); | ||
| free(agent->log_trajectory_z); | ||
| free(agent->log_heading); | ||
| free(agent->log_velocity_x); | ||
| free(agent->log_velocity_y); | ||
| free(agent->log_length); | ||
| free(agent->log_width); | ||
| free(agent->log_height); | ||
| free(agent->log_valid); | ||
| free(agent->route); | ||
| } | ||
|
|
||
| void free_road_element(struct RoadMapElement* element){ | ||
| free(element->x); | ||
| free(element->y); | ||
| free(element->z); | ||
| free(element->entry_lanes); | ||
| free(element->exit_lanes); | ||
| } | ||
|
|
||
| void free_traffic_element(struct TrafficControlElement* element){ | ||
| free(element->states); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK if daphne's PR was already merged on the no active agent condition. But it would be good to also address that here because there is now additional freeing logic.