Skip to content

Commit 3b269a9

Browse files
authored
fix(autoware_carla_interface): improve lateral control tracking (#10312)
Convert steer angle to actuator command, model steering with first order dynamics, and update the steer_map.csv Signed-off-by: Steven Brills <stevenbrills@hotmail.com>
1 parent 69c0a32 commit 3b269a9

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
default,-10,0,10
2-
-1,-0.9,-0.9,-0.9
3-
0,0,0,0
4-
1,0.9,0.9,0.9
1+
default,-1,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1
2+
-1,0,-0.404,-0.808,-1.212,-1.616,-2.02,-2.346,-2.672,-2.998,-3.324,-3.65
3+
-0.8,0.4,-0.00599999999999995,-0.412,-0.818,-1.224,-1.63,-2.024,-2.418,-2.812,-3.206,-3.6
4+
-0.6,0.805,0.394,-0.017,-0.428,-0.839,-1.25,-1.6466,-2.0432,-2.4398,-2.8364,-3.233
5+
-0.4,1.11,0.7164,0.3228,-0.0707999999999998,-0.4644,-0.858,-1.3164,-1.7748,-2.2332,-2.6916,-3.15
6+
-0.2,1.68,1.256,0.832,0.408,-0.0160000000000002,-0.44,-0.836,-1.232,-1.628,-2.024,-2.42
7+
0,2.2,1.76,1.32,0.88,0.44,0,-0.44,-0.88,-1.32,-1.76,-2.2
8+
0.2,2.42,2.024,1.628,1.232,0.836,0.44,0.016,-0.408,-0.832,-1.256,-1.68
9+
0.4,3.15,2.6916,2.2332,1.7748,1.3164,0.858,0.4644,0.0708,-0.3228,-0.7164,-1.11
10+
0.6,3.233,2.8364,2.4398,2.0432,1.6466,1.25,0.839,0.428,0.0169999999999999,-0.394,-0.805
11+
0.8,3.6,3.208,2.816,2.424,2.032,1.64,1.232,0.824,0.416,0.00799999999999979,-0.4
12+
1,3.66,3.332,3.004,2.676,2.348,2.02,1.616,1.212,0.808,0.404,0

simulator/autoware_carla_interface/src/autoware_carla_interface/carla_ros.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
class carla_ros2_interface(object):
5151
def __init__(self):
5252
self.sensor_interface = SensorInterface()
53+
self.prev_timestamp = None
54+
self.prev_steer_output = 0.0
55+
self.tau = 0.2
5356
self.timestamp = None
5457
self.ego_actor = None
5558
self.physics_control = None
@@ -382,6 +385,21 @@ def imu(self, carla_imu_measurement):
382385

383386
self.pub_imu.publish(imu_msg)
384387

388+
def first_order_steering(self, steer_input):
389+
"""First order steering model."""
390+
steer_output = 0.0
391+
if self.prev_timestamp is None:
392+
self.prev_timestamp = self.timestamp
393+
394+
dt = self.timestamp - self.prev_timestamp
395+
if dt > 0.0:
396+
steer_output = self.prev_steer_output + (steer_input - self.prev_steer_output) * (
397+
dt / (self.tau + dt)
398+
)
399+
self.prev_steer_output = steer_output
400+
self.prev_timestamp = self.timestamp
401+
return steer_output
402+
385403
def control_callback(self, in_cmd):
386404
"""Convert and publish CARLA Ego Vehicle Control to AUTOWARE."""
387405
out_cmd = carla.VehicleControl()
@@ -392,11 +410,7 @@ def control_callback(self, in_cmd):
392410
max_steer_ratio = numpy.interp(
393411
abs(current_vel.x), [v.x for v in steer_curve], [v.y for v in steer_curve]
394412
)
395-
out_cmd.steer = (
396-
-in_cmd.actuation.steer_cmd
397-
* max_steer_ratio
398-
* math.radians(self.physics_control.wheels[0].max_steer_angle)
399-
)
413+
out_cmd.steer = self.first_order_steering(-in_cmd.actuation.steer_cmd) * max_steer_ratio
400414
out_cmd.brake = in_cmd.actuation.brake_cmd
401415
self.current_control = out_cmd
402416

0 commit comments

Comments
 (0)