Skip to content
Merged
Show file tree
Hide file tree
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 Jan 27, 2025
efc06c9
Merged with s2025
Jan 28, 2025
97a3de8
Merge branch 'main' into s2025_teamB
krishauser Jan 29, 2025
be692a1
Fix setup issues and add user to the docker image
harishkumarbalaji Feb 2, 2025
9206116
Dummy commit to trigger sonarqube
harishkumarbalaji Feb 2, 2025
0fcdff4
Fix the requrements.txt to take from the current repo
harishkumarbalaji Feb 2, 2025
cff1e29
Update the docker compose service name
harishkumarbalaji Feb 2, 2025
753e5ba
Update missing depedencies and ultralytics python packagein requirements
harishkumarbalaji Feb 3, 2025
a7a2e8c
Add. Instructions to check if the container toolkit is working as exp…
harishkumarbalaji Feb 3, 2025
1f6fb93
Update. Readme with latest depedencies
harishkumarbalaji Feb 3, 2025
6618e8f
Update. Readme with post install steps
harishkumarbalaji Feb 3, 2025
a871397
Fixed launch file to work with standard perception pipeline
krishauser Feb 3, 2025
7a66dc1
Merge branch 's2025' into s2025_teamB
krishauser Feb 3, 2025
38deb79
Merge pull request #98 from krishauser/infra-b/fix_setup_issues
krishauser Feb 3, 2025
6f18feb
Update volume mounting to access the files
harishkumarbalaji Feb 3, 2025
ca430be
Merge pull request #101 from krishauser/infra-b/update_missing_depede…
krishauser Feb 3, 2025
9e67bac
implement perception part 1
Feb 5, 2025
9a9acff
merge incoming change from teamB
Feb 5, 2025
6bcab9f
change prompt
KenC1014 Feb 5, 2025
995409b
gather data for rosbag
KenC1014 Feb 5, 2025
30be879
Fix setup machine script and add volume mounts for dbus
harishkumarbalaji Feb 6, 2025
dde23bc
Fixed fake_fake simulation calls and rename from YIELD -> YIELDING
krishauser Feb 6, 2025
ab28abf
Merge pull request #103 from krishauser/infra-b/fix_setup_machine_scrpt
krishauser Feb 6, 2025
9c13eca
Added rosbag sub, visualization and comments
nvikramraj Feb 7, 2025
055e13c
ignores models
nvikramraj Feb 7, 2025
48fe475
ignores models
nvikramraj Feb 7, 2025
aca3247
add vis publisher and error handling
KenC1014 Feb 8, 2025
8aed8c7
switch back to GEM e4 topic
KenC1014 Feb 8, 2025
0cd147d
remove person_detector
KenC1014 Feb 8, 2025
e818a1c
Merge branch 'PerceptionB_main' into perception_b_vikram
LucasEby Feb 8, 2025
be27708
Merge pull request #104 from krishauser/perception_b_vikram
LucasEby Feb 8, 2025
6978bb1
Merge branch 's2025_teamB' into PerceptionB_main so we can share perc…
LucasEby Feb 9, 2025
abe73fc
added instructions for mac installation
pravshot Feb 9, 2025
faa0396
test fusion
KenC1014 Feb 12, 2025
3040e56
Update Dockerfile.cuda11.8
RuimingShen Feb 12, 2025
ca9ca3e
fixSDK
RuimingShen Feb 13, 2025
14407a7
remove-c
RuimingShen Feb 13, 2025
093e155
Merge pull request #105 from krishauser/PerceptionB_main
LucasEby Feb 13, 2025
97b6dc6
Lidar to Base frame transformation
nvikramraj Feb 13, 2025
b087f8d
added few comments
nvikramraj Feb 13, 2025
475b8c9
align lidar pc2 to camera frame
KenC1014 Feb 15, 2025
1355d5f
extract clouds in 2d
KenC1014 Feb 15, 2025
8316a20
converted lidar to cam frame
nvikramraj Feb 15, 2025
dc69933
add od3 dialect
KenC1014 Feb 15, 2025
2872618
add o3d import
KenC1014 Feb 15, 2025
bf69981
downsample pc2
KenC1014 Feb 15, 2025
ced4804
rename variables
KenC1014 Feb 15, 2025
4b93f5f
Merge pull request #106 from krishauser/fix-dockerfile
RuimingShen Feb 15, 2025
d319eaa
extract 3D pc2 and visualize
KenC1014 Feb 15, 2025
49f45ee
segregate points by pedestrains
KenC1014 Feb 15, 2025
d3c9e4c
update comments
KenC1014 Feb 15, 2025
c23b36c
rename variables
KenC1014 Feb 15, 2025
5aa571b
remove empty line
KenC1014 Feb 15, 2025
9008a9a
add ground and max dist filter
KenC1014 Feb 15, 2025
c31546d
add comments
KenC1014 Feb 15, 2025
006b555
update comments
KenC1014 Feb 15, 2025
b35252b
Finalize fusion.py with pedestrian centers, vel, dims, AgentStates. M…
lukasdumasius Feb 17, 2025
eeeeb54
Port fusion.py to pedestrian_detection.py
lukasdumasius Feb 17, 2025
19ad11e
Add transform.py instructions
lukasdumasius Feb 17, 2025
0a21424
pedestrian_detection.py type hints
lukasdumasius Feb 17, 2025
c7246ed
pedestrian_detection.py add time for velocity
lukasdumasius Feb 17, 2025
b62c6fc
integrate updated depth filter and 3D bboxes vis
KenC1014 Feb 17, 2025
6cd1d4f
apply lidar to vehicle transform to centers
KenC1014 Feb 18, 2025
6fd3702
Merge branch 's2025' into s2025_teamB
krishauser Feb 18, 2025
7ad05fd
Check len(0) ouster points pedestrian_detection.py
lukasdumasius Feb 18, 2025
68d0a75
fix lidar frame mapping
KenC1014 Feb 18, 2025
c596eda
Merge branch 'PerceptionB_ped_fusion_done' of https://github.com/kris…
KenC1014 Feb 18, 2025
0857f0c
reslove conflicts
KenC1014 Feb 18, 2025
fcca8c0
toggle vehicle frame
KenC1014 Feb 18, 2025
d820c3c
toggle vehicle frame
KenC1014 Feb 18, 2025
248911c
add comments for bug fixes
KenC1014 Feb 18, 2025
5700e09
handle empty list
KenC1014 Feb 18, 2025
bf4f433
Found some frame problems in parent branch
LucasEby Feb 18, 2025
8a7ceb6
Wrote in logic to finish part 3. Still need to implement 1-2 transfor…
LucasEby Feb 18, 2025
2aa0ba6
Fixed find_vels_and_ids logic bugs, AgentState bugs, timing bugs, etc
LucasEby Feb 18, 2025
f080070
I think I updated a comment
LucasEby Feb 18, 2025
db6d689
Cleaned up code a bit. Will add Vikram's suggestions in Slack next
LucasEby Feb 18, 2025
bf80bbe
Accidentally moved a few lines of code. Fixed the error that resulted
LucasEby Feb 18, 2025
6addddb
In the process of converting to start frame. Pushing current WORKING …
LucasEby Feb 19, 2025
7c48e56
initial plot metrics
pravshot Feb 19, 2025
3fcd14a
added safety factor scale
pravshot Feb 19, 2025
a18d187
Took absolutely forever to find the secret sauce. Please excuse the mess
LucasEby Feb 19, 2025
0b5d88b
finally think I figured out start frame transform. In the process of …
LucasEby Feb 19, 2025
1d6f1ad
Merge branch 'perception_b_vikram' into G8_velocity_and_ids
nvikramraj Feb 19, 2025
96b9885
Pushing code so Lukas can try to replicate error message
LucasEby Feb 19, 2025
f7dcffc
Merge branch 'G8_velocity_and_ids' of github.com:krishauser/GEMstack …
LucasEby Feb 19, 2025
a936d3d
Fixed logic for gate which tosses out points
LucasEby Feb 19, 2025
98f445f
Update pedestrian_detection.py
lukasdumasius Feb 19, 2025
dad7cc1
Update pedestrian_detection.py
lukasdumasius Feb 19, 2025
502f3a8
Sending untransformed version to planning team
LucasEby Feb 19, 2025
cd42261
Merge branch 'PerceptionB_ped_fusion_done' into G8_velocity_and_ids
LucasEby Feb 19, 2025
873f531
Merge pull request #122 from krishauser/G8_velocity_and_ids
LucasEby Feb 19, 2025
4fd89ff
Merge pull request #123 from krishauser/PerceptionB_ped_fusion_done
LucasEby Feb 19, 2025
a469876
Merge branch 's2025_teamB' into PerceptionB_main
LucasEby Feb 19, 2025
57811aa
integrated t vehicle to start
nvikramraj Feb 20, 2025
7e0a49f
syntax error fix
nvikramraj Feb 20, 2025
57c54b9
code refactor for start_frame
nvikramraj Feb 22, 2025
f2b1778
Updated velocity and id code to work off of data that's already in st…
LucasEby Feb 22, 2025
04bb209
Merge pull request #126 from krishauser/G8_find_vels_and_ids_sf
nvikramraj Feb 22, 2025
bc16a40
Putting this here for now not sure what the issue is
LucasEby Feb 22, 2025
0de5980
Simplified velocity and id function
LucasEby Feb 22, 2025
410e13e
Simplified and fixed agent state dimensions
LucasEby Feb 23, 2025
ed5db78
Fixed a dict clearing issue
LucasEby Feb 23, 2025
163e0a1
Merge pull request #128 from krishauser/G8_simplified_velocity_and_ids
LucasEby Feb 23, 2025
de29fb1
Merge pull request #124 from krishauser/PerceptionB_main
LucasEby Feb 23, 2025
a2ff9f6
pedestrian_detection.py Convert obj_dims to start frame aligned bbox
lukasdumasius Feb 23, 2025
9601d8e
gnss integration
nvikramraj Feb 24, 2025
ac16563
added viz and edge case fix
nvikramraj Feb 24, 2025
c849544
remove viz
nvikramraj Feb 24, 2025
98b3d99
Merge branch 'perceptionb_working_gnss' into s2025_teamB
nvikramraj Feb 24, 2025
4e7b3c1
Merged update
krishauser Feb 24, 2025
b4ba3bb
Merge branch 's2025' into s2025_teamB
krishauser Feb 24, 2025
e0cd0a8
Merge pull request #131 from krishauser/s2025_teamB
lukasdumasius Feb 24, 2025
d3f6190
Merge branch 'PerceptionB_main' into perceptionb_start_frame
lukasdumasius Feb 24, 2025
32f0025
Merge pull request #132 from krishauser/perceptionb_start_frame
lukasdumasius Feb 24, 2025
2545b85
cleaned up code and fixed obj_centers issue in agent creation
LucasEby Feb 24, 2025
331e40a
added cross track error
pravshot Feb 24, 2025
46f569f
adding state estimation part
muralikarteek7 Feb 24, 2025
23abe25
pedestrian_detection.py fix pedestrian centers, dims in start. Rviz w…
lukasdumasius Feb 24, 2025
630933a
added position graph
pravshot Feb 24, 2025
a1fae81
Create plot.py
Jugthegreat Feb 24, 2025
f4d7e2d
Related start frame agents to vehicle frame agents. Fixed time
LucasEby Feb 24, 2025
6e2dc41
Related start frame agents to vehicle frame agents. Fixed time
LucasEby Feb 24, 2025
dbd87be
Merge branch 'G8_adding_current_frame_to_Pmain' of github.com:krishau…
LucasEby Feb 24, 2025
89d8daf
Removed unnecessary print statement
LucasEby Feb 24, 2025
9919c39
Merge pull request #134 from krishauser/G8_adding_current_frame_to_Pmain
LucasEby Feb 25, 2025
326f585
Merge pull request #135 from krishauser/PerceptionB_main
LucasEby Feb 25, 2025
5c6af6a
edge case fix
nvikramraj Feb 25, 2025
74acb15
Added exception to edge case and fixed return values for similar exce…
LucasEby Feb 25, 2025
3ab83e9
Merge pull request #136 from krishauser/PerceptionB_main
LucasEby Feb 25, 2025
e416888
Fix zed sdk version for cuda11.8
harishkumarbalaji Feb 25, 2025
97799bc
remove other changes
harishkumarbalaji Feb 25, 2025
d1c9ca9
Fix indent
harishkumarbalaji Feb 25, 2025
49d1bc6
updated graphs with comfort/safety scale
pravshot Feb 25, 2025
576e051
Merge remote-tracking branch 'refs/remotes/origin/infraBComfortSafety…
pravshot Feb 25, 2025
176817f
removed plot.py file
pravshot Feb 25, 2025
c14d7af
added pedestrian distance metric and cleaned code
pravshot Feb 25, 2025
ec44350
check for 0 pedestrians in log
pravshot Feb 26, 2025
534436f
added documentation
pravshot Feb 26, 2025
8574545
Gazebo Gem Integration
nvikramraj Apr 3, 2025
3f183be
yaml change
nvikramraj Apr 3, 2025
086f7ad
added send_command
danielzhuang11 Apr 6, 2025
454bc7e
small fixes
danielzhuang11 Apr 6, 2025
b5a2f39
IT MOVES
danielzhuang11 Apr 6, 2025
bc6ee35
steering is reversed for some reason
danielzhuang11 Apr 7, 2025
2e71f76
added some TODO messages
danielzhuang11 Apr 7, 2025
2975c91
incorporated vehicle switching from sys args
nvikramraj Apr 8, 2025
c2ad121
Merge branch 's2025_Simulation_vikram' into s2025_Simulation_input
nvikramraj Apr 8, 2025
8db2b6f
Merge pull request #156 from krishauser/s2025_Simulation_input
nvikramraj Apr 8, 2025
5533213
Fixed GNSS
nvikramraj Apr 8, 2025
1459022
GEM e4 integrated
nvikramraj Apr 8, 2025
0b90bc5
Attached read me
nvikramraj Apr 8, 2025
cd4c649
updated readme
nvikramraj Apr 8, 2025
65df967
updated readme
nvikramraj Apr 8, 2025
62c18b8
Calibration integration
nvikramraj Apr 14, 2025
6d6dffb
updated readme
nvikramraj Apr 15, 2025
2e78a1c
add gem_gazebo interface with control commands to gazebo
harishkumarbalaji Apr 15, 2025
cd9257e
fix gem_gazebo and update readme
harishkumarbalaji Apr 15, 2025
074a196
Merge branch 'infra-b/docker_setup' into simulation integration
harishkumarbalaji Apr 15, 2025
f6df3db
Merge remote-tracking branch 'origin/infraBComfortSafetyMetrics' into…
harishkumarbalaji Apr 15, 2025
7863bd5
add mpl viz
harishkumarbalaji Apr 15, 2025
33d5455
now using ros sensor topics defined in yaml file
pravshot Apr 15, 2025
a5cb7e4
removed type check
pravshot Apr 15, 2025
a052e29
documentation (praveen) + longitudinal control (daniel)
danielzhuang11 Apr 21, 2025
2caf27c
Delete GEMstack/knowledge/routes/gazebo.csv
danielzhuang11 Apr 21, 2025
1c6263f
updated metric script to show acceleration and remove dot plots
pravshot Apr 22, 2025
601d37d
test_comfort get latest log
danielzhuang11 Apr 23, 2025
3d7bdb1
tune controller
harishkumarbalaji Apr 23, 2025
893eed2
Merge pull request #157 from krishauser/s2025_Simulation_vikram
harishkumarbalaji Apr 23, 2025
55ba9a8
add install ackermann-msgs in docker
harishkumarbalaji Apr 23, 2025
ff6b765
update documentation
harishkumarbalaji Apr 23, 2025
cfcd03b
revert current yaml, fix accel/heading states
danielzhuang11 Apr 24, 2025
1e9c506
flipped lat and long
danielzhuang11 Apr 28, 2025
6dc31d2
subscribes to combined gnss data
pravshot May 2, 2025
ac5f11a
updates self.last_reading.speed in gnss_callback and removed unused i…
pravshot May 2, 2025
ea7594b
Merge pull request #176 from krishauser/s2025
nvikramraj May 2, 2025
c7a0e25
Merge pull request #177 from krishauser/s2025_Simulation
nvikramraj May 2, 2025
c773ff2
PR fixes
nvikramraj May 3, 2025
d7f0f52
Reverted settings override changes
nvikramraj May 3, 2025
86637c4
Merge pull request #178 from krishauser/s2025_Simulation_vikram
harishkumarbalaji May 5, 2025
8eeb5bf
PR changes
nvikramraj May 5, 2025
11c2536
Merge pull request #182 from krishauser/s2025_Simulation_vikram
nvikramraj May 5, 2025
496b018
Update README.md
harishkumarbalaji May 5, 2025
35fdbf5
Update main.py
harishkumarbalaji May 5, 2025
2d6c7f0
Revert yaml files
nvikramraj May 6, 2025
3f9a74e
Merge pull request #185 from krishauser/s2025_Simulation_vikram
nvikramraj May 6, 2025
45105e5
Merge branch 's2025_Simulation' into s2025_Simulation_gnss_sub
pravshot May 7, 2025
ec43ea2
Merge pull request #184 from krishauser/s2025_Simulation_gnss_sub
harishkumarbalaji May 7, 2025
8c475fa
Removed yaml changes
nvikramraj May 7, 2025
4e24ae8
Merge pull request #186 from krishauser/s2025_Simulation_vikram
nvikramraj May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Copy link
Owner

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

Copy link
Collaborator

@nvikramraj nvikramraj Apr 30, 2025

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.

Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,13 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# ZED run files
**/*.run
.vscode/
setup/zed_sdk.run
cuda/
GEMstack/knowledge/detection/yolov8n.pt
GEMstack/knowledge/detection/yolo11n.pt
yolov8n.pt
yolo11n.pt
34 changes: 34 additions & 0 deletions GEMstack/knowledge/defaults/e2.yaml
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
257 changes: 257 additions & 0 deletions GEMstack/onboard/interface/gem_gazebo.py
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
Loading
Loading