当前位置:网站首页>ROS bridge notes (05) - Carla_ ackermann_ Control function package (convert Ackermann messages into carlaegovehiclecontrol messages)

ROS bridge notes (05) - Carla_ ackermann_ Control function package (convert Ackermann messages into carlaegovehiclecontrol messages)

2022-07-07 08:07:00 wohu1104

Official website :https://carla.readthedocs.io/projects/ros-bridge/en/latest/carla_ackermann_control/
Reference resources :https://blog.csdn.net/dfman1978/article/details/125077551

carla_ackermann_control Package usage Ackermann messages control CARLA vehicle . The package will Ackermann messages Convert to CarlaEgoVehicleControl news .

It is from CARLA Read vehicle information , And pass this information to a person based on Python Of PID controller , be called simple-pid , To control acceleration and speed .

stay ros_bridge in , Besides using manual_control Bao Lai directly uses the keyboard to control the simulation car , You can also use ackermann( Ackerman ) To control . stay carla and autoware In the process of joint simulation ,autoware The final control information is to be converted into ackermann Control command , Finally, control the simulation vehicle .

1. Configuration parameters

In the use of ROS 1 and ROS 2 when , Can be in The configuration file Initial setting parameters in , Pass... At run time ROS 1 Dynamically reconfigure parameters dynamic_reconfigure.

2. Test control messages

adopt topic /carla/<ROLE NAME>/ackermann_cmd Send commands to the trolley to test the settings . for example , Run the following command , Name the role as ego_vehicle Self vehicle with 10 rice / Move forward at the speed of seconds :

rostopic pub /carla/ego_vehicle/ackermann_cmd ackermann_msgs/AckermannDrive \
"{steering_angle: 0.0, steering_angle_velocity: 0.0, speed: 10, acceleration: 0.0, jerk: 0.0}" -r 10

Or let the vehicle 1.22 The angle of the arc moves forward when turning :

rostopic pub /carla/ego_vehicle/ackermann_cmd ackermann_msgs/AckermannDrive \
"{steering_angle: 1.22, steering_angle_velocity: 0.0, speed: 10, acceleration: 0.0, jerk: 0.0}" -r 10

After the above command is executed , adopt rostopic Command view , The topic The vehicle will not move without subscribers .

[email protected]:~/tool$ rostopic info /carla/ego_vehicle/ackermann_cmd
Type: ackermann_msgs/AckermannDrive

Publishers: 
 * /rostopic_16525_1657090091755 (http://wohu-pc:39319/)

Subscribers: None


[email protected]:~/tool$ 

among /carla/ego_vehicle/ackermann_cmd It was sent ackermann command , The node parses this command , And then convert to ros_bridge Message formats that nodes can recognize :/carla/ego_vehicle/vehicle_conttrol_cmd, issue /carla_ros_bridge node .


Can be in carla-ros-bridge/catkin_ws/src/ros-bridge/carla_ros_bridge/src/carla_ros_bridge/ego_vehicle.py See in the code

self.control_subscriber = node.new_subscription(
    CarlaEgoVehicleControl,
    self.get_topic_prefix() + "/vehicle_control_cmd",
    lambda data: self.control_command_updated(data, manual_override=False),
    qos_profile=10)

self.manual_control_subscriber = node.new_subscription(
    CarlaEgoVehicleControl,
    self.get_topic_prefix() + "/vehicle_control_cmd_manual",
    lambda data: self.control_command_updated(data, manual_override=True),
            qos_profile=10)

The real execution function is control_command_updated, It reads as follows :

    def control_command_updated(self, ros_vehicle_control, manual_override):
        """ Receive a CarlaEgoVehicleControl msg and send to CARLA This function gets called whenever a ROS CarlaEgoVehicleControl is received. If the mode is valid (either normal or manual), the received ROS message is converted into carla.VehicleControl command and sent to CARLA. This bridge is not responsible for any restrictions on velocity or steering. It's just forwarding the ROS input to CARLA :param manual_override: manually override the vehicle control command :param ros_vehicle_control: current vehicle control input received via ROS :type ros_vehicle_control: carla_msgs.msg.CarlaEgoVehicleControl :return: """
        if manual_override == self.vehicle_control_override:
            vehicle_control = VehicleControl()
            vehicle_control.hand_brake = ros_vehicle_control.hand_brake
            vehicle_control.brake = ros_vehicle_control.brake
            vehicle_control.steer = ros_vehicle_control.steer
            vehicle_control.throttle = ros_vehicle_control.throttle
            vehicle_control.reverse = ros_vehicle_control.reverse
            vehicle_control.manual_gear_shift = ros_vehicle_control.manual_gear_shift
            vehicle_control.gear = ros_vehicle_control.gear
            self.carla_actor.apply_control(vehicle_control)
            self._vehicle_control_applied_callback(self.get_id())

The notes clearly explain receive CarlaEgoVehicleControl news , Send to CARLA.

self.carla_actor.apply_control(vehicle_control)

This function is to control the simulation vehicle .

3. summary

The package will Ackermann messages Convert to CarlaEgoVehicleControl News , Actually ROS Bridge Is used in CarlaEgoVehicleControl Message sent to CARLA Of , So if it is ROS And Autoware Then you should use this package , If it is docking with other systems , such as Apollo, Then just Apollo The corresponding message of is transformed into CarlaEgoVehicleControl The format is just .

4. ROS API

4.1 Subscriptions

TopicTypeDescription
/carla//ackermann_cmdackermann_msgs.AckermannDriveSubscriber for steering commands

4.2 Publications

TopicTypeDescription
/carla//ackermann_control/control_infocarla_ackermann_control.EgoVehicleControlInfoThe current values used within the controller (useful for debugging)
原网站

版权声明
本文为[wohu1104]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070457410074.html