前言
根据LGSVL的官方快速上手教程安装运行simulator后,发现在模拟器内无法通过键盘控制车辆的运动。经学习了解后发现是需要在虚拟车辆中添加“keyboard control”的传感器,才可以通过键盘或罗技控制器控制车辆在虚拟环境中的运动。下面将会介绍如何设置“keyboard contorl”传感器以控制车辆,以及其它传感器的设置方式。
传感器添加方法
如下图所示,在模拟器的web GUI界面找到所使用的车辆,并点击设置按钮:
在打开后的界面中的sensor窗口中写入相应的传感器代码及其设置即可:
添加“keyboard contorl”传感器的代码如下:
[
{
"type": "Keyboard Control",
"name": "Keyboard Car Control"
}
]
将其粘贴到上图的传感器脚本框里面点击提交即可,然后再在场景中运行车辆即可。
TIPS
-
需要在仿真里面打开交互模式仿真选项,如下图:
- 在场景中运行车辆时需要先敲击
右shift
键,来关闭手刹才能通过上下左右键控制车辆运行。 -
PageUp
键控制车辆加档,PageDown
键控制车辆为倒挡。
其它传感器的添加方法
多传感器的json代码格式如下:
[
SENSOR,
SENSOR,
SENSOR
]
单个SENSOR
的格式如下:
{
"type": STRING,
"name": STRING,
"params": {PARAMS},
"parent": STRING,
"transform": {
"x": FLOAT,
"y": FLOAT,
"z": FLOAT,
"pitch": FLOAT,
"yaw": FLOAT,
"roll": FLOAT,
}
}
-
type
为传感器的类型 -
name
为传感器的名字,这决定了传感器将会如何定义 -
params
为显示特定参数,如果没有设置的话是默认使用默认的值 -
parent
为传感器连接至的上级传感器的transform
, - “transform”里的参数为其位置姿态转换信息。
具体地,某一搭载多传感器的车辆传感器代码示例如下:
[
{
"type": "CAN-Bus",
"name": "CAN Bus",
"params": {
"Frequency": 10,
"Topic": "/apollo/canbus/chassis"
},
"transform": {
"x": 0,
"y": 0,
"z": 0,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "GPS Device",
"name": "GPS",
"params": {
"Frequency": 12.5,
"Topic": "/apollo/sensor/gnss/best_pose",
"Frame": "gps"
},
"transform": {
"x": 0,
"y": 0,
"z": -1.348649,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "GPS Odometry",
"name": "GPS Odometry",
"params": {
"Frequency": 12.5,
"Topic": "/apollo/sensor/gnss/odometry",
"Frame": "gps"
},
"transform": {
"x": 0,
"y": 0,
"z": -1.348649,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "IMU",
"name": "IMU",
"params": {
"Topic": "/apollo/sensor/gnss/imu",
"Frame": "imu",
"CorrectedTopic": "/apollo/sensor/gnss/corrected_imu",
"CorrectedFrame": "imu"
},
"transform": {
"x": 0,
"y": 0,
"z": -1.348649,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "Radar",
"name": "Radar",
"params": {
"Frequency": 13.4,
"Topic": "/apollo/sensor/conti_radar"
},
"transform": {
"x": 0,
"y": 0.689,
"z": 2.272,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "Lidar",
"name": "Lidar",
"params": {
"LaserCount": 32,
"MinDistance": 0.5,
"MaxDistance": 100,
"RotationFrequency": 10,
"MeasurementsPerRotation": 360,
"FieldOfView": 41.33,
"CenterAngle": 10,
"Compensated": true,
"PointColor": "#ff000000",
"Topic": "/apollo/sensor/velodyne64/compensator/PointCloud2",
"Frame": "velodyne"
},
"transform": {
"x": 0,
"y": 2.312,
"z": -0.3679201,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "Color Camera",
"name": "Main Camera",
"params": {
"Width": 1920,
"Height": 1080,
"Frequency": 15,
"JpegQuality": 75,
"FieldOfView": 50,
"MinDistance": 0.1,
"MaxDistance": 1000,
"Topic": "/apollo/sensor/camera/traffic/image_short/compressed"
},
"transform": {
"x": 0,
"y": 1.7,
"z": -0.2,
"pitch": 0,
"yaw": 0,
"roll": 0
}
},
{
"type": "Color Camera",
"name": "Telephoto Camera",
"params": {
"Width": 1920,
"Height": 1080,
"Frequency": 15,
"JpegQuality": 75,
"FieldOfView": 10,
"MinDistance": 0.1,
"MaxDistance": 1000,
"Topic": "/apollo/sensor/camera/traffic/image_long/compressed"
},
"transform": {
"x": 0,
"y": 1.7,
"z": -0.2,
"pitch": -4,
"yaw": 0,
"roll": 0
}
},
{
"type": "Manual Control",
"name": "Manual Car Control"
},
{
"type": "Vehicle Control",
"name": "Apollo Car Control",
"params": {
"Topic": "/apollo/control"
}
}
]
更多的传感器参数详解请看这里
https://www.lgsvlsimulator.com/docs/sensor-json-options/
https://github.com/lgsvl/simulator/issues/519
网友评论