当前位置:网站首页>ROS Bridge 笔记(05)— carla_ackermann_control 功能包(将Ackermann messages 转化为 CarlaEgoVehicleControl 消息)
ROS Bridge 笔记(05)— carla_ackermann_control 功能包(将Ackermann messages 转化为 CarlaEgoVehicleControl 消息)
2022-07-07 04:58:00 【wohu1104】
官网:https://carla.readthedocs.io/projects/ros-bridge/en/latest/carla_ackermann_control/
参考:https://blog.csdn.net/dfman1978/article/details/125077551
carla_ackermann_control 包使用 Ackermann messages 控制 CARLA 车辆。该包将 Ackermann messages 转换为CarlaEgoVehicleControl 消息。
它从 CARLA 读取车辆信息,并将该信息传递给一个基于 Python 的PID 控制器,称为 simple-pid ,以控制加速度和速度。
在 ros_bridge中,除了使用 manual_control包来直接使用键盘来控制仿真小车,还可以通过ackermann(阿克曼)来控制。在 carla和 autoware联合仿真的过程中,autoware最终的控制信息是要转换为 ackermann控制指令,最后控制仿真车。
1. 配置参数
在使用 ROS 1和 ROS 2时,可以在 配置文件 中初始设置参数,在运行时通过 ROS 1 动态重新配置参数 dynamic_reconfigure。
2. 测试控制消息
通过 topic /carla/<ROLE NAME>/ackermann_cmd 向小车发送命令来测试设置。例如,运行如下命令,将角色名为 ego_vehicle 的自我车辆以10米/秒的速度向前移动:
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
或者让车辆以1.22弧度的角度转弯时向前移动:
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
上面的命令执行后,通过 rostopic 命令查看,该 topic 在没有订阅者的情况下车辆是不会运动的。
[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$
其中 /carla/ego_vehicle/ackermann_cmd就是发过来的 ackermann命令,节点对这个命令进行解析,然后转换成 ros_bridge节点可以识别的消息格式:/carla/ego_vehicle/vehicle_conttrol_cmd,发给 /carla_ros_bridge节点。
可以在 carla-ros-bridge/catkin_ws/src/ros-bridge/carla_ros_bridge/src/carla_ros_bridge/ego_vehicle.py代码里看到
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)
真正的执行函数是 control_command_updated,其内容如下:
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())
注释很清楚的说明了 接收 CarlaEgoVehicleControl消息,发送给 CARLA。
self.carla_actor.apply_control(vehicle_control)
这个函数就是来控制仿真车辆。
3. 总结
该包将 Ackermann messages 转换为CarlaEgoVehicleControl 消息的,实际在 ROS Bridge 中使用的是 CarlaEgoVehicleControl 消息发送给 CARLA 的,所以如果是 ROS 与 Autoware 对接那么就应该使用这个包,如果是和其它系统对接,比如 Apollo,那么只需要将 Apollo 的相应消息转化为 CarlaEgoVehicleControl 格式即可。
4. ROS API
4.1 Subscriptions
| Topic | Type | Description |
|---|---|---|
| /carla//ackermann_cmd | ackermann_msgs.AckermannDrive | Subscriber for steering commands |
4.2 Publications
| Topic | Type | Description |
|---|---|---|
| /carla//ackermann_control/control_info | carla_ackermann_control.EgoVehicleControlInfo | The current values used within the controller (useful for debugging) |
边栏推荐
- Sign up now | oar hacker marathon phase III, waiting for your challenge
- Ansible
- Quickly use Jacobo code coverage statistics
- [VHDL parallel statement execution]
- Explore Cassandra's decentralized distributed architecture
- Avatary的LiveDriver试用体验
- 力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
- Lattice coloring - matrix fast power optimized shape pressure DP
- 2022焊工(初级)判断题及在线模拟考试
- QT learning 26 integrated example of layout management
猜你喜欢

uniapp 移动端强制更新功能

game攻防世界逆向

You Li takes you to talk about C language 6 (common keywords)

Who has docker to install MySQL locally?

MySQL multi column index (composite index) features and usage scenarios

Jmeter 的使用
![[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)](/img/e1/9a047ef13299b94b5314ee6865ba26.png)
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)

json 数据展平pd.json_normalize

Main window in QT learning 27 application

3D reconstruction - stereo correction
随机推荐
Linux server development, SQL statements, indexes, views, stored procedures, triggers
Redis technology leak detection and filling (II) - expired deletion strategy
芯片 设计资料下载
JS quick start (I)
这5个摸鱼神器太火了!程序员:知道了快删!
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
buureservewp(2)
You Li takes you to talk about C language 6 (common keywords)
OpenJudge NOI 2.1 1752:鸡兔同笼
青龙面板-今日头条
[UVM foundation] what is transaction
Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
Paddlepaddle 29 dynamically modify the network structure without model definition code (relu changes to prelu, conv2d changes to conv3d, 2D semantic segmentation model changes to 3D semantic segmentat
LeetCode简单题之判断一个数的数字计数是否等于数位的值
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
2022年茶艺师(中级)考试试题及模拟考试
Leetcode 40: combined sum II
Zsh shell adds automatic completion and syntax highlighting
【无标题】
pytest+allure+jenkins環境--填坑完畢