Skip to content
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

Fill CarlaEgoVehicleControl message header #624

Open
wants to merge 6 commits into
base: 0.9.11-compat
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
6 changes: 6 additions & 0 deletions carla_ad_agent/src/carla_ad_agent/local_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self):

self.data_lock = threading.Lock()

self._current_header = None
self._current_pose = None
self._current_speed = None
self._target_speed = 0.0
Expand Down Expand Up @@ -100,6 +101,8 @@ def __init__(self):

def odometry_cb(self, odometry_msg):
with self.data_lock:
self._current_header = odometry_msg.header
self._current_header.frame_id = odometry_msg.child_frame_id
self._current_pose = odometry_msg.pose.pose
self._current_speed = math.sqrt(odometry_msg.twist.twist.linear.x ** 2 +
odometry_msg.twist.twist.linear.y ** 2 +
Expand Down Expand Up @@ -158,6 +161,7 @@ def run_step(self):
# move using PID controllers
control_msg = self._vehicle_controller.run_step(
self._target_speed, self._current_speed, self._current_pose, target_pose)
control_msg.header = self._current_header

# purge the queue of obsolete waypoints
max_index = -1
Expand All @@ -176,6 +180,8 @@ def run_step(self):

def emergency_stop(self):
control_msg = CarlaEgoVehicleControl()
if self._current_header:
control_msg.header = self._current_header
control_msg.steer = 0.0
control_msg.throttle = 0.0
control_msg.brake = 1.0
Expand Down
10 changes: 8 additions & 2 deletions carla_ad_agent/src/carla_ad_agent/vehicle_pid_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ def run_step(self, target_speed, current_speed, current_pose, waypoint):
:return: control signal (throttle and steering)
"""
control = CarlaEgoVehicleControl()
throttle = self._lon_controller.run_step(target_speed, current_speed)
steering = self._lat_controller.run_step(current_pose, waypoint)
if current_speed:
throttle = self._lon_controller.run_step(target_speed, current_speed)
else:
throttle = 0.0
if current_pose:
steering = self._lat_controller.run_step(current_pose, waypoint)
else:
sterring = 0.0
control.steer = -steering
control.throttle = throttle
control.brake = 0.0
Expand Down