经过【CarlaRosBridge——获取、编译、启动】中的一顿折腾,总算顺利地运行了CarlaRosBridge。但这仅仅是一个开始,下面介绍几个常用的配置,这都是比较基础的使用方法。后面的内容会迭代出一些比较高级的使用方式,大家需要点耐心!今天要分享的是【思想】比较常用的一些设置,如果有更好的使用建议,欢迎后台私信!
【CarlaRosBridge——获取、编译、启动】通过下面命令启动CarlaRosBridge
roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch
所以,先打开carla_ros_bridge_with_example_ego_vehicle.launch 看看到底运行了哪些东西。
<launch>
<!-- CARLA connection -->
<arg name='host' default='localhost'/>
<arg name='port' default='2000'/>
<arg name='timeout' default='10'/>
<!-- Ego vehicle -->
<arg name='role_name' default='ego_vehicle'/>
<arg name="vehicle_filter" default='vehicle.*'/>
<arg name="spawn_point" default='20,1,0.3,0.0,0.0,180.0'/>
<!--<arg name="spawn_point" default='0,1,0.3,0.0,0.0,180.0'/> -->
<!-- use comma separated format "x,y,z,roll,pitch,yaw" 8.7,-87.0,0.0,0.0,0.0,90.0 -->
<!-- Map to load on startup (either a predefined CARLA town (e.g. 'Town01'), or a OpenDRIVE map file) -->
<arg name="town" default='Town05'/>
<!-- Enable/disable passive mode -->
<arg name='passive' default=''/>
<!-- Synchronous mode-->
<arg name='synchronous_mode_wait_for_vehicle_control_command' default='False'/>
<arg name='fixed_delta_seconds' default='0.05'/>
<include file="$(find carla_ros_bridge)/launch/carla_ros_bridge.launch">
<arg name='host' value='$(arg host)'/>
<arg name='port' value='$(arg port)'/>
<arg name='town' value='$(arg town)'/>
<arg name='timeout' value='$(arg timeout)'/>
<arg name='passive' value='$(arg passive)'/>
<arg name='synchronous_mode_wait_for_vehicle_control_command' value='$(arg synchronous_mode_wait_for_vehicle_control_command)'/>
<arg name='fixed_delta_seconds' value='$(arg fixed_delta_seconds)'/>
</include>
<!-- the ego vehicle, that will be controlled by an agent (e.g. carla_ad_agent) -->
<include file="$(find carla_spawn_objects)/launch/carla_example_ego_vehicle.launch">
<arg name="objects_definition_file" value='$(find carla_spawn_objects)/config/objects.json'/>
<arg name='role_name' value='$(arg role_name)'/>
<arg name="spawn_point_ego_vehicle" value="$(arg spawn_point)"/>
<arg name="spawn_sensors_only" value="false"/>
</include>
<include file="$(find carla_manual_control)/launch/carla_manual_control.launch">
<arg name='role_name' value='$(arg role_name)'/>
</include>
</launch>
这是一个ROS的Lauch文件,arg标签为变量参数,include标签为链接其他lauch文件,可以看到总共include了三个launch文件,和若干个参数。
<arg name='host' default='localhost'/>
<arg name='port' default='2000'/>
<arg name='timeout' default='10'/>
设置Carla主程序的IP和端口,以及连接超时。从参数名也能能直接分辨他们。
<arg name='role_name' default='ego_vehicle'/>
role_name参数用于设置ego车辆的名称,这关系到后面RosBridge发出来的RosTopic名称
<arg name="vehicle_filter" default='vehicle.*'/>
vehicle_filter参数用于设置车辆过滤规则,方便我们在节点中释放车辆前对objects进行过滤
<arg name="spawn_point" default=''/>
<!-- use comma separated format "x,y,z,roll,pitch,yaw" 8.7,-87.0,0.0,0.0,0.0,90.0 -->
spawn_point参数用于设置ego车辆在地图中的位置与姿态,按例子中的注释,需要设置x【x,y,z,roll,pitch,yaw】六个参数。这个位置设置前需要确认,防止ego出现在建筑物中!
<arg name="town" default='Town05'/>
town参数用于切换carla地图
carla_ros_bridge_with_example_ego_vehicle.launch文件中所包含的3个launch是最基本的,后面的更新会介绍如何在这个基础上添加自己的lanuch
<include file="$(find carla_ros_bridge)/launch/carla_ros_bridge.launch">
carla_ros_bridge.launch这是RosBridge的主节点,用来连接Ros与Carla的,包括设置地图、设置天气、设置交通等。
<include file="$(find carla_spawn_objects)/launch/carla_example_ego_vehicle.launch">
carla_example_ego_vehicle.launch用创建ego vehicle,控制ego vehicle的类型,指派其在地图上的出生点等。
<include file="$(find carla_manual_control)/launch/carla_manual_control.launch">
carla_manual_control.launch启动pygame的手动控制,通过这个窗口可以控制ego是否自动驾驶,如果在手动模式,可以通过键盘与控制车辆。
知乎号| 古德曼汽车工业