-
Notifications
You must be signed in to change notification settings - Fork 10
Gazebo GEMstack Integration #164
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
Merged
Merged
Changes from all commits
Commits
Show all changes
190 commits
Select commit
Hold shift + click to select a range
cffde30
Added homework description and starter code
krishauser efc06c9
Merged with s2025
97a3de8
Merge branch 'main' into s2025_teamB
krishauser be692a1
Fix setup issues and add user to the docker image
harishkumarbalaji 9206116
Dummy commit to trigger sonarqube
harishkumarbalaji 0fcdff4
Fix the requrements.txt to take from the current repo
harishkumarbalaji cff1e29
Update the docker compose service name
harishkumarbalaji 753e5ba
Update missing depedencies and ultralytics python packagein requirements
harishkumarbalaji a7a2e8c
Add. Instructions to check if the container toolkit is working as exp…
harishkumarbalaji 1f6fb93
Update. Readme with latest depedencies
harishkumarbalaji 6618e8f
Update. Readme with post install steps
harishkumarbalaji a871397
Fixed launch file to work with standard perception pipeline
krishauser 7a66dc1
Merge branch 's2025' into s2025_teamB
krishauser 38deb79
Merge pull request #98 from krishauser/infra-b/fix_setup_issues
krishauser 6f18feb
Update volume mounting to access the files
harishkumarbalaji ca430be
Merge pull request #101 from krishauser/infra-b/update_missing_depede…
krishauser 9e67bac
implement perception part 1
9a9acff
merge incoming change from teamB
6bcab9f
change prompt
KenC1014 995409b
gather data for rosbag
KenC1014 30be879
Fix setup machine script and add volume mounts for dbus
harishkumarbalaji dde23bc
Fixed fake_fake simulation calls and rename from YIELD -> YIELDING
krishauser ab28abf
Merge pull request #103 from krishauser/infra-b/fix_setup_machine_scrpt
krishauser 9c13eca
Added rosbag sub, visualization and comments
nvikramraj 055e13c
ignores models
nvikramraj 48fe475
ignores models
nvikramraj aca3247
add vis publisher and error handling
KenC1014 8aed8c7
switch back to GEM e4 topic
KenC1014 0cd147d
remove person_detector
KenC1014 e818a1c
Merge branch 'PerceptionB_main' into perception_b_vikram
LucasEby be27708
Merge pull request #104 from krishauser/perception_b_vikram
LucasEby 6978bb1
Merge branch 's2025_teamB' into PerceptionB_main so we can share perc…
LucasEby abe73fc
added instructions for mac installation
pravshot faa0396
test fusion
KenC1014 3040e56
Update Dockerfile.cuda11.8
RuimingShen ca9ca3e
fixSDK
RuimingShen 14407a7
remove-c
RuimingShen 093e155
Merge pull request #105 from krishauser/PerceptionB_main
LucasEby 97b6dc6
Lidar to Base frame transformation
nvikramraj b087f8d
added few comments
nvikramraj 475b8c9
align lidar pc2 to camera frame
KenC1014 1355d5f
extract clouds in 2d
KenC1014 8316a20
converted lidar to cam frame
nvikramraj dc69933
add od3 dialect
KenC1014 2872618
add o3d import
KenC1014 bf69981
downsample pc2
KenC1014 ced4804
rename variables
KenC1014 4b93f5f
Merge pull request #106 from krishauser/fix-dockerfile
RuimingShen d319eaa
extract 3D pc2 and visualize
KenC1014 49f45ee
segregate points by pedestrains
KenC1014 d3c9e4c
update comments
KenC1014 c23b36c
rename variables
KenC1014 5aa571b
remove empty line
KenC1014 9008a9a
add ground and max dist filter
KenC1014 c31546d
add comments
KenC1014 006b555
update comments
KenC1014 b35252b
Finalize fusion.py with pedestrian centers, vel, dims, AgentStates. M…
lukasdumasius eeeeb54
Port fusion.py to pedestrian_detection.py
lukasdumasius 19ad11e
Add transform.py instructions
lukasdumasius 0a21424
pedestrian_detection.py type hints
lukasdumasius c7246ed
pedestrian_detection.py add time for velocity
lukasdumasius b62c6fc
integrate updated depth filter and 3D bboxes vis
KenC1014 6cd1d4f
apply lidar to vehicle transform to centers
KenC1014 6fd3702
Merge branch 's2025' into s2025_teamB
krishauser 7ad05fd
Check len(0) ouster points pedestrian_detection.py
lukasdumasius 68d0a75
fix lidar frame mapping
KenC1014 c596eda
Merge branch 'PerceptionB_ped_fusion_done' of https://github.com/kris…
KenC1014 0857f0c
reslove conflicts
KenC1014 fcca8c0
toggle vehicle frame
KenC1014 d820c3c
toggle vehicle frame
KenC1014 248911c
add comments for bug fixes
KenC1014 5700e09
handle empty list
KenC1014 bf4f433
Found some frame problems in parent branch
LucasEby 8a7ceb6
Wrote in logic to finish part 3. Still need to implement 1-2 transfor…
LucasEby 2aa0ba6
Fixed find_vels_and_ids logic bugs, AgentState bugs, timing bugs, etc
LucasEby f080070
I think I updated a comment
LucasEby db6d689
Cleaned up code a bit. Will add Vikram's suggestions in Slack next
LucasEby bf80bbe
Accidentally moved a few lines of code. Fixed the error that resulted
LucasEby 6addddb
In the process of converting to start frame. Pushing current WORKING …
LucasEby 7c48e56
initial plot metrics
pravshot 3fcd14a
added safety factor scale
pravshot a18d187
Took absolutely forever to find the secret sauce. Please excuse the mess
LucasEby 0b5d88b
finally think I figured out start frame transform. In the process of …
LucasEby 1d6f1ad
Merge branch 'perception_b_vikram' into G8_velocity_and_ids
nvikramraj 96b9885
Pushing code so Lukas can try to replicate error message
LucasEby f7dcffc
Merge branch 'G8_velocity_and_ids' of github.com:krishauser/GEMstack …
LucasEby a936d3d
Fixed logic for gate which tosses out points
LucasEby 98f445f
Update pedestrian_detection.py
lukasdumasius dad7cc1
Update pedestrian_detection.py
lukasdumasius 502f3a8
Sending untransformed version to planning team
LucasEby cd42261
Merge branch 'PerceptionB_ped_fusion_done' into G8_velocity_and_ids
LucasEby 873f531
Merge pull request #122 from krishauser/G8_velocity_and_ids
LucasEby 4fd89ff
Merge pull request #123 from krishauser/PerceptionB_ped_fusion_done
LucasEby a469876
Merge branch 's2025_teamB' into PerceptionB_main
LucasEby 57811aa
integrated t vehicle to start
nvikramraj 7e0a49f
syntax error fix
nvikramraj 57c54b9
code refactor for start_frame
nvikramraj f2b1778
Updated velocity and id code to work off of data that's already in st…
LucasEby 04bb209
Merge pull request #126 from krishauser/G8_find_vels_and_ids_sf
nvikramraj bc16a40
Putting this here for now not sure what the issue is
LucasEby 0de5980
Simplified velocity and id function
LucasEby 410e13e
Simplified and fixed agent state dimensions
LucasEby ed5db78
Fixed a dict clearing issue
LucasEby 163e0a1
Merge pull request #128 from krishauser/G8_simplified_velocity_and_ids
LucasEby de29fb1
Merge pull request #124 from krishauser/PerceptionB_main
LucasEby a2ff9f6
pedestrian_detection.py Convert obj_dims to start frame aligned bbox
lukasdumasius 9601d8e
gnss integration
nvikramraj ac16563
added viz and edge case fix
nvikramraj c849544
remove viz
nvikramraj 98b3d99
Merge branch 'perceptionb_working_gnss' into s2025_teamB
nvikramraj 4e7b3c1
Merged update
krishauser b4ba3bb
Merge branch 's2025' into s2025_teamB
krishauser e0cd0a8
Merge pull request #131 from krishauser/s2025_teamB
lukasdumasius d3f6190
Merge branch 'PerceptionB_main' into perceptionb_start_frame
lukasdumasius 32f0025
Merge pull request #132 from krishauser/perceptionb_start_frame
lukasdumasius 2545b85
cleaned up code and fixed obj_centers issue in agent creation
LucasEby 331e40a
added cross track error
pravshot 46f569f
adding state estimation part
muralikarteek7 23abe25
pedestrian_detection.py fix pedestrian centers, dims in start. Rviz w…
lukasdumasius 630933a
added position graph
pravshot a1fae81
Create plot.py
Jugthegreat f4d7e2d
Related start frame agents to vehicle frame agents. Fixed time
LucasEby 6e2dc41
Related start frame agents to vehicle frame agents. Fixed time
LucasEby dbd87be
Merge branch 'G8_adding_current_frame_to_Pmain' of github.com:krishau…
LucasEby 89d8daf
Removed unnecessary print statement
LucasEby 9919c39
Merge pull request #134 from krishauser/G8_adding_current_frame_to_Pmain
LucasEby 326f585
Merge pull request #135 from krishauser/PerceptionB_main
LucasEby 5c6af6a
edge case fix
nvikramraj 74acb15
Added exception to edge case and fixed return values for similar exce…
LucasEby 3ab83e9
Merge pull request #136 from krishauser/PerceptionB_main
LucasEby e416888
Fix zed sdk version for cuda11.8
harishkumarbalaji 97799bc
remove other changes
harishkumarbalaji d1c9ca9
Fix indent
harishkumarbalaji 49d1bc6
updated graphs with comfort/safety scale
pravshot 576e051
Merge remote-tracking branch 'refs/remotes/origin/infraBComfortSafety…
pravshot 176817f
removed plot.py file
pravshot c14d7af
added pedestrian distance metric and cleaned code
pravshot ec44350
check for 0 pedestrians in log
pravshot 534436f
added documentation
pravshot 8574545
Gazebo Gem Integration
nvikramraj 3f183be
yaml change
nvikramraj 086f7ad
added send_command
danielzhuang11 454bc7e
small fixes
danielzhuang11 b5a2f39
IT MOVES
danielzhuang11 bc6ee35
steering is reversed for some reason
danielzhuang11 2e71f76
added some TODO messages
danielzhuang11 2975c91
incorporated vehicle switching from sys args
nvikramraj c2ad121
Merge branch 's2025_Simulation_vikram' into s2025_Simulation_input
nvikramraj 8db2b6f
Merge pull request #156 from krishauser/s2025_Simulation_input
nvikramraj 5533213
Fixed GNSS
nvikramraj 1459022
GEM e4 integrated
nvikramraj 0b90bc5
Attached read me
nvikramraj cd4c649
updated readme
nvikramraj 65df967
updated readme
nvikramraj 62c18b8
Calibration integration
nvikramraj 6d6dffb
updated readme
nvikramraj 2e78a1c
add gem_gazebo interface with control commands to gazebo
harishkumarbalaji cd9257e
fix gem_gazebo and update readme
harishkumarbalaji 074a196
Merge branch 'infra-b/docker_setup' into simulation integration
harishkumarbalaji f6df3db
Merge remote-tracking branch 'origin/infraBComfortSafetyMetrics' into…
harishkumarbalaji 7863bd5
add mpl viz
harishkumarbalaji 33d5455
now using ros sensor topics defined in yaml file
pravshot a5cb7e4
removed type check
pravshot a052e29
documentation (praveen) + longitudinal control (daniel)
danielzhuang11 2caf27c
Delete GEMstack/knowledge/routes/gazebo.csv
danielzhuang11 1c6263f
updated metric script to show acceleration and remove dot plots
pravshot 601d37d
test_comfort get latest log
danielzhuang11 3d7bdb1
tune controller
harishkumarbalaji 893eed2
Merge pull request #157 from krishauser/s2025_Simulation_vikram
harishkumarbalaji 55ba9a8
add install ackermann-msgs in docker
harishkumarbalaji ff6b765
update documentation
harishkumarbalaji cfcd03b
revert current yaml, fix accel/heading states
danielzhuang11 1e9c506
flipped lat and long
danielzhuang11 6dc31d2
subscribes to combined gnss data
pravshot ac5f11a
updates self.last_reading.speed in gnss_callback and removed unused i…
pravshot ea7594b
Merge pull request #176 from krishauser/s2025
nvikramraj c7a0e25
Merge pull request #177 from krishauser/s2025_Simulation
nvikramraj c773ff2
PR fixes
nvikramraj d7f0f52
Reverted settings override changes
nvikramraj 86637c4
Merge pull request #178 from krishauser/s2025_Simulation_vikram
harishkumarbalaji 8eeb5bf
PR changes
nvikramraj 11c2536
Merge pull request #182 from krishauser/s2025_Simulation_vikram
nvikramraj 496b018
Update README.md
harishkumarbalaji 35fdbf5
Update main.py
harishkumarbalaji 2d6c7f0
Revert yaml files
nvikramraj 3f9a74e
Merge pull request #185 from krishauser/s2025_Simulation_vikram
nvikramraj 45105e5
Merge branch 's2025_Simulation' into s2025_Simulation_gnss_sub
pravshot ec43ea2
Merge pull request #184 from krishauser/s2025_Simulation_gnss_sub
harishkumarbalaji 8c475fa
Removed yaml changes
nvikramraj 4e24ae8
Merge pull request #186 from krishauser/s2025_Simulation_vikram
nvikramraj 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,34 @@ | ||
| # ********* Main settings entry point for behavior stack *********** | ||
|
|
||
| # Configure settings for the vehicle / vehicle model | ||
| vehicle: !include ../vehicle/gem_e2.yaml | ||
|
|
||
| #arguments for algorithm components here | ||
| model_predictive_controller: | ||
| dt: 0.1 | ||
| lookahead: 20 | ||
| control: | ||
| recovery: | ||
| brake_amount : 0.5 | ||
| brake_speed : 2.0 | ||
| pure_pursuit: | ||
| lookahead: 2.0 | ||
| lookahead_scale: 3.0 | ||
| crosstrack_gain: 1.0 | ||
| desired_speed: trajectory | ||
| longitudinal_control: | ||
| pid_p: 1.0 | ||
| pid_i: 0.1 | ||
| pid_d: 0.0 | ||
|
|
||
| #configure the simulator, if using | ||
| simulator: | ||
| dt: 0.01 | ||
| real_time_multiplier: 1.0 # make the simulator run faster than real time by making this > 1 | ||
| gnss_emulator: | ||
| dt: 0.1 #10Hz | ||
| #position_noise: 0.1 #10cm noise | ||
| #orientation_noise: 0.04 #2.3 degrees noise | ||
| #velocity_noise: | ||
| # constant: 0.04 #4cm/s noise | ||
| # linear: 0.02 #2% noise |
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,257 @@ | ||
| from .gem import * | ||
| from ...utils import settings | ||
| import math | ||
| import time | ||
|
|
||
| # ROS Headers | ||
| import rospy | ||
| from sensor_msgs.msg import Image, PointCloud2, Imu, NavSatFix | ||
| from septentrio_gnss_driver.msg import INSNavGeod | ||
| from geometry_msgs.msg import Vector3Stamped | ||
| from sensor_msgs.msg import JointState # For reading joint states from Gazebo | ||
| # Changed from AckermannDriveStamped | ||
| from ackermann_msgs.msg import AckermannDrive | ||
| from rosgraph_msgs.msg import Clock | ||
| from tf.transformations import euler_from_quaternion | ||
|
|
||
|
|
||
| from ...state import ObjectPose,ObjectFrameEnum | ||
| from ...knowledge.vehicle.geometry import steer2front | ||
| from ...knowledge.vehicle.dynamics import pedal_positions_to_acceleration | ||
|
|
||
| # OpenCV and cv2 bridge | ||
| import cv2 | ||
| import numpy as np | ||
| from ...utils import conversions | ||
| from ...mathutils import transforms | ||
|
|
||
|
|
||
| @dataclass | ||
| class GNSSReading: | ||
| pose: ObjectPose | ||
| speed: float | ||
| status: str | ||
|
|
||
|
|
||
| class GEMGazeboInterface(GEMInterface): | ||
| """Interface for connecting to the GEM e2 vehicle in Gazebo simulation.""" | ||
|
|
||
| def __init__(self): | ||
| GEMInterface.__init__(self) | ||
| self.max_send_rate = settings.get('vehicle.max_command_rate', 10.0) | ||
| self.ros_sensor_topics = settings.get('vehicle.sensors.ros_topics') | ||
| self.last_command_time = 0.0 | ||
| self.last_reading = GEMVehicleReading() | ||
| self.last_reading.speed = 0.0 | ||
| self.last_reading.steering_wheel_angle = 0.0 | ||
| self.last_reading.accelerator_pedal_position = 0.0 | ||
| self.last_reading.brake_pedal_position = 0.0 | ||
| self.last_reading.gear = 1 | ||
| self.last_reading.left_turn_signal = False | ||
| self.last_reading.right_turn_signal = False | ||
| self.last_reading.horn_on = False | ||
| self.last_reading.wiper_level = 0 | ||
| self.last_reading.headlights_on = False | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| # GNSS data subscriber | ||
| self.gnss_sub = None | ||
|
|
||
| # Other sensors | ||
| self.front_camera_sub = None | ||
| self.front_depth_sub = None | ||
| self.top_lidar_sub = None | ||
| self.front_radar_sub = None | ||
|
|
||
| self.faults = [] | ||
|
|
||
| # Gazebo vehicle control | ||
| self.ackermann_pub = rospy.Publisher( | ||
| '/ackermann_cmd', AckermannDrive, queue_size=1) | ||
| self.ackermann_cmd = AckermannDrive() | ||
| self.last_command = None # Store the last command | ||
|
|
||
| # Add clock subscription for simulation time | ||
| self.sim_time = rospy.Time(0) | ||
| self.clock_sub = rospy.Subscriber('/clock', Clock, self.clock_callback) | ||
|
|
||
| def start(self): | ||
| print("Starting GEM Gazebo Interface") | ||
|
|
||
| def clock_callback(self, msg): | ||
| self.sim_time = msg.clock | ||
|
|
||
| def time(self): | ||
| # Return Gazebo simulation time | ||
| return self.sim_time.to_sec() | ||
|
|
||
| def get_reading(self) -> GEMVehicleReading: | ||
| return self.last_reading | ||
|
|
||
|
|
||
| def subscribe_sensor(self, name, callback, type=None): | ||
| if name == 'gnss': | ||
| topic = self.ros_sensor_topics['gnss'] | ||
| def gnss_callback_wrapper(gnss_msg: INSNavGeod): | ||
| roll, pitch, yaw = gnss_msg.roll, gnss_msg.pitch, gnss_msg.heading | ||
| # Convert from degrees to radians | ||
| roll, pitch, yaw = math.radians(roll), math.radians(pitch), math.radians(yaw) | ||
|
|
||
| # Transform yaw to correct frame - Gazebo typically uses ROS standard frame (x-forward) | ||
| # while navigation uses x-east reference frame | ||
| # Need to convert from Gazebo's frame to navigation heading, then to navigation yaw | ||
|
|
||
| # Assuming Gazebo's yaw is 0 when facing east (ROS REP 103 convention) | ||
| # Convert IMU's yaw to heading (CW from North), then to navigation yaw (CCW from East) | ||
| # This handles the coordinate frame differences between Gazebo and the navigation frame | ||
| # Negate yaw to convert from ROS to heading | ||
| heading = transforms.yaw_to_heading(-yaw - np.pi/2, degrees=False) | ||
| navigation_yaw = transforms.heading_to_yaw( | ||
| heading, degrees=False) | ||
|
|
||
| # Create fused pose with transformed yaw | ||
| pose = ObjectPose( | ||
| frame=ObjectFrameEnum.GLOBAL, | ||
| t=gnss_msg.header.stamp, | ||
| x=gnss_msg.longitude, | ||
| y=gnss_msg.latitude, | ||
| z=gnss_msg.height, | ||
| roll=roll, | ||
| pitch=pitch, | ||
| yaw=navigation_yaw | ||
| ) | ||
|
|
||
| # Calculate speed from GNSS | ||
| self.last_reading.speed = np.linalg.norm([gnss_msg.ve, gnss_msg.vn]) | ||
|
|
||
| # Create GNSS reading with fused data | ||
| reading = GNSSReading( | ||
| pose=pose, | ||
| speed=self.last_reading.speed, | ||
| status='error' if gnss_msg.error else 'ok' | ||
| ) | ||
| # Added debug | ||
| print( | ||
| f"[GNSS] Raw coordinates: Lat={gnss_msg.latitude:.6f}, Lon={gnss_msg.longitude:.6f}") | ||
| # Added debug | ||
| print( | ||
| f"[GNSS-FUSED] Orientation: Roll={roll:.2f}, Pitch={pitch:.2f}, Yaw={yaw:.2f} rad") | ||
| # Added debug | ||
| print(f"[GNSS-FUSED] Speed: {self.last_reading.speed:.2f} m/s") | ||
|
|
||
| callback(reading) | ||
|
|
||
| self.gnss_sub = rospy.Subscriber(topic, INSNavGeod, gnss_callback_wrapper) | ||
|
|
||
| elif name == 'top_lidar': | ||
| topic = self.ros_sensor_topics[name] | ||
| if type is not None and (type is not PointCloud2 and type is not np.ndarray): | ||
| raise ValueError("GEMGazeboInterface only supports PointCloud2 or numpy array for top lidar") | ||
| if type is None or type is PointCloud2: | ||
| self.top_lidar_sub = rospy.Subscriber(topic, PointCloud2, callback) | ||
| else: | ||
| def callback_with_numpy(msg: PointCloud2): | ||
| points = conversions.ros_PointCloud2_to_numpy(msg, want_rgb=False) | ||
| callback(points) | ||
| self.top_lidar_sub = rospy.Subscriber(topic, PointCloud2, callback_with_numpy) | ||
|
|
||
| elif name == 'front_camera': | ||
| topic = self.ros_sensor_topics[name] | ||
| if type is not None and (type is not Image and type is not cv2.Mat): | ||
| raise ValueError("GEMGazeboInterface only supports Image or OpenCV for front camera") | ||
| if type is None or type is Image: | ||
| self.front_camera_sub = rospy.Subscriber(topic, Image, callback) | ||
| else: | ||
| def callback_with_cv2(msg: Image): | ||
| cv_image = conversions.ros_Image_to_cv2(msg, desired_encoding="bgr8") | ||
| callback(cv_image) | ||
| self.front_camera_sub = rospy.Subscriber(topic, Image, callback_with_cv2) | ||
| # Front depth sensor has not been added to gazebo yet. | ||
| # This code is placeholder until we add front depth sensor. | ||
| elif name == 'front_depth': | ||
| topic = self.ros_sensor_topics[name] | ||
| if type is not None and (type is not Image and type is not cv2.Mat): | ||
| raise ValueError("GEMGazeboInterface only supports Image or OpenCV for front depth") | ||
| if type is None or type is Image: | ||
| self.front_depth_sub = rospy.Subscriber(topic, Image, callback) | ||
| else: | ||
| def callback_with_cv2(msg: Image): | ||
| cv_image = conversions.ros_Image_to_cv2(msg, desired_encoding="passthrough") | ||
| callback(cv_image) | ||
| self.front_depth_sub = rospy.Subscriber(topic, Image, callback_with_cv2) | ||
|
|
||
| def hardware_faults(self) -> List[str]: | ||
| # In simulation, we don't have real hardware faults | ||
| return self.faults | ||
|
|
||
| def send_command(self, command : GEMVehicleCommand): | ||
| # Throttle rate at which we send commands | ||
| t = self.time() | ||
| if t < self.last_command_time + 1.0/self.max_send_rate: | ||
| # Skip command, similar to hardware interface | ||
| return | ||
| self.last_command_time = t | ||
|
|
||
| # Get current speed | ||
| v = self.last_reading.speed | ||
|
|
||
|
|
||
| #update last reading | ||
| self.last_reading.accelerator_pedal_position = command.accelerator_pedal_position | ||
| self.last_reading.brake_pedal_position = command.brake_pedal_position | ||
| self.last_reading.steering_wheel_angle = command.steering_wheel_angle | ||
|
|
||
| # Convert pedal to acceleration | ||
| accelerator_pedal_position = np.clip(command.accelerator_pedal_position, 0.0, 1.0) | ||
| brake_pedal_position = np.clip(command.brake_pedal_position, 0.0, 1.0) | ||
|
|
||
| # Zero out accelerator if brake is active (just like hardware interface) | ||
| if brake_pedal_position > 0.0: | ||
| accelerator_pedal_position = 0.0 | ||
|
|
||
| # Calculate acceleration from pedal positions | ||
| acceleration = pedal_positions_to_acceleration(accelerator_pedal_position, brake_pedal_position, v, 0, 1) | ||
|
|
||
| # Apply reasonable limits to acceleration | ||
| max_accel = settings.get('vehicle.limits.max_acceleration', 1.0) | ||
| max_decel = settings.get('vehicle.limits.max_deceleration', -2.0) | ||
| acceleration = np.clip(acceleration, max_decel, max_accel) | ||
|
|
||
| # Convert wheel angle to steering angle (front wheel angle) | ||
| phides = steer2front(command.steering_wheel_angle) | ||
|
|
||
| # Apply steering angle limits | ||
| min_wheel_angle = settings.get('vehicle.geometry.min_wheel_angle', -0.6) | ||
| max_wheel_angle = settings.get('vehicle.geometry.max_wheel_angle', 0.6) | ||
| phides = np.clip(phides, min_wheel_angle, max_wheel_angle) | ||
|
|
||
| # Calculate target speed based on acceleration | ||
| # Don't use infinite speed, instead calculate a reasonable target speed | ||
| current_speed = v | ||
| target_speed = current_speed | ||
|
|
||
| if acceleration > 0: | ||
| # Accelerating - set target speed to current speed plus some increment | ||
| # This is more realistic than infinite speed | ||
| max_speed = settings.get('vehicle.limits.max_speed', 10.0) | ||
| target_speed = min(current_speed + acceleration * 0.5, max_speed) | ||
| elif acceleration < 0: | ||
| # Braking - set target speed to zero if deceleration is significant | ||
| if brake_pedal_position > 0.1: | ||
| target_speed = 0.0 | ||
|
|
||
| # Create and publish drive message | ||
| msg = AckermannDrive() | ||
| msg.acceleration = acceleration | ||
| msg.speed = target_speed | ||
| msg.steering_angle = phides | ||
| msg.steering_angle_velocity = command.steering_wheel_speed # Respect steering velocity limit | ||
|
|
||
| # Debug output | ||
| print(f"[ACKERMANN] Speed: {msg.speed:.2f}, Accel: {msg.acceleration:.2f}, Steer: {msg.steering_angle:.2f}") | ||
|
|
||
| self.ackermann_pub.publish(msg) | ||
| self.last_command = command |
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.
Should not include homework files
Uh oh!
There was an error while loading. Please reload this page.
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.
We are using few of the homework files to test the simulation metrics and performance.
We will review and make the necessary changes.