Skip to content

Commit 6dc31d2

Browse files
committed
subscribes to combined gnss data
1 parent 1e9c506 commit 6dc31d2

3 files changed

Lines changed: 16 additions & 40 deletions

File tree

GEMstack/knowledge/vehicle/gem_e2_sensor_environment_gazebo.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ ros_topics:
22
top_lidar: /velodyne_points
33
front_camera: /front_single_camera/image_raw
44
front_depth: /notopic
5-
gps: /gps/fix
6-
imu: /imu
5+
gnss: /insnavgeod
76

GEMstack/knowledge/vehicle/gem_e4_sensor_environment_gazebo.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ ros_topics:
22
top_lidar: /velodyne_points
33
front_camera: /front_single_camera/image_raw
44
front_depth: /notopic
5-
gps: /gps/fix
6-
imu: /imu
5+
gnss: /insnavgeod
76

GEMstack/onboard/interface/gem_gazebo.py

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# ROS Headers
77
import rospy
88
from sensor_msgs.msg import Image, PointCloud2, Imu, NavSatFix
9+
from septentrio_gnss_driver.msg import INSNavGeod
910
from geometry_msgs.msg import Vector3Stamped
1011
from sensor_msgs.msg import JointState # For reading joint states from Gazebo
1112
# Changed from AckermannDriveStamped
@@ -56,10 +57,6 @@ def __init__(self):
5657

5758

5859

59-
# IMU data subscriber
60-
self.imu_sub = None
61-
self.imu_data = None
62-
6360
# GNSS data subscriber
6461
self.gnss_sub = None
6562

@@ -77,12 +74,6 @@ def __init__(self):
7774
self.ackermann_cmd = AckermannDrive()
7875
self.last_command = None # Store the last command
7976

80-
# Subscribe to IMU topic by default
81-
self.imu_sub = rospy.Subscriber("/imu", Imu, self.imu_callback)
82-
83-
# Subscribe to GNSS Velocitu
84-
self.gnss_vel_sub = rospy.Subscriber("/gps/fix_velocity", Vector3Stamped, self.gnss_vel_callback)
85-
8677
# Add clock subscription for simulation time
8778
self.sim_time = rospy.Time(0)
8879
self.clock_sub = rospy.Subscriber('/clock', Clock, self.clock_callback)
@@ -97,9 +88,6 @@ def time(self):
9788
# Return Gazebo simulation time
9889
return self.sim_time.to_sec()
9990

100-
def imu_callback(self, msg: Imu):
101-
self.imu_data = msg
102-
10391
def gnss_vel_callback(self, msg):
10492
self.last_reading.speed = np.linalg.norm([msg.vector.x, msg.vector.y] )
10593

@@ -109,21 +97,11 @@ def get_reading(self) -> GEMVehicleReading:
10997

11098
def subscribe_sensor(self, name, callback, type=None):
11199
if name == 'gnss':
112-
topic = self.ros_sensor_topics['gps']
113-
# Fuse IMU orientation with GNSS position
114-
def gnss_callback_wrapper(gps_msg: NavSatFix):
115-
if self.imu_data is None:
116-
return # Wait for IMU data
117-
118-
# Get orientation from IMU
119-
quaternion = (
120-
self.imu_data.orientation.x,
121-
self.imu_data.orientation.y,
122-
self.imu_data.orientation.z,
123-
self.imu_data.orientation.w
124-
)
125-
print(f"[IMU] Orientation: {quaternion}")
126-
roll, pitch, yaw = euler_from_quaternion(quaternion)
100+
topic = self.ros_sensor_topics['gnss']
101+
def gnss_callback_wrapper(gnss_msg: INSNavGeod):
102+
roll, pitch, yaw = gnss_msg.roll, gnss_msg.pitch, gnss_msg.heading
103+
# Convert from degrees to radians
104+
roll, pitch, yaw = math.radians(roll), math.radians(pitch), math.radians(yaw)
127105

128106
# Transform yaw to correct frame - Gazebo typically uses ROS standard frame (x-forward)
129107
# while navigation uses x-east reference frame
@@ -140,10 +118,10 @@ def gnss_callback_wrapper(gps_msg: NavSatFix):
140118
# Create fused pose with transformed yaw
141119
pose = ObjectPose(
142120
frame=ObjectFrameEnum.GLOBAL,
143-
t=gps_msg.header.stamp,
144-
x=gps_msg.longitude,
145-
y=gps_msg.latitude,
146-
z=gps_msg.altitude,
121+
t=gnss_msg.header.stamp,
122+
x=gnss_msg.longitude,
123+
y=gnss_msg.latitude,
124+
z=gnss_msg.height,
147125
roll=roll,
148126
pitch=pitch,
149127
yaw=navigation_yaw
@@ -152,12 +130,12 @@ def gnss_callback_wrapper(gps_msg: NavSatFix):
152130
# Create GNSS reading with fused data
153131
reading = GNSSReading(
154132
pose=pose,
155-
speed= self.last_reading.speed,
156-
status='FIX' if gps_msg.status.status >= 0 else 'NO_FIX'
133+
speed=np.linalg.norm([gnss_msg.ve, gnss_msg.vn]),
134+
status='error' if gnss_msg.error else 'ok'
157135
)
158136
# Added debug
159137
print(
160-
f"[GNSS] Raw coordinates: Lat={gps_msg.latitude:.6f}, Lon={gps_msg.longitude:.6f}")
138+
f"[GNSS] Raw coordinates: Lat={gnss_msg.latitude:.6f}, Lon={gnss_msg.longitude:.6f}")
161139
# Added debug
162140
print(
163141
f"[GNSS-FUSED] Orientation: Roll={roll:.2f}, Pitch={pitch:.2f}, Yaw={yaw:.2f} rad")
@@ -166,7 +144,7 @@ def gnss_callback_wrapper(gps_msg: NavSatFix):
166144

167145
callback(reading)
168146

169-
self.gnss_sub = rospy.Subscriber(topic, NavSatFix, gnss_callback_wrapper)
147+
self.gnss_sub = rospy.Subscriber(topic, INSNavGeod, gnss_callback_wrapper)
170148

171149
elif name == 'top_lidar':
172150
topic = self.ros_sensor_topics[name]

0 commit comments

Comments
 (0)