环境:apollo 2.5 + ubuntu16.04 + docker
gnss module 代码所在路径/apollo/modules/drivers/gnss
编译方式:ubuntu@in_dev_docker:/apollo$ ./apollo.sh build_gnss
注意事项:
apollo.sh
里面的build选项并不是编译所有的组件,只是用bazel编译所有bazel的targe /apollo/bazel-out
下面,而是在/home/tmp/ros
里面,即gnss module编译没有使用bazel,还是用catkin_make编译的。message ComNavSerial {}
{
optional bytes device = 1; // Something like "/dev/ttyXXX".
optional int32 baud_rate = 2 [default = 9600];
// In general, we assumes no parity, 8 data bits, 1 stop bit, no
// handshaking, break detection enabled. If not, add more fields here.
}
就发现在raw_stream.cpp
中找不到config::Stream::kComNavSerial
经过多方尝试,最后将名字改成Comnav
后就可以了.应该是protoBuf的语法问题.
运行gnss driver可以通过dreamview里面的modules control ->modules ->gps,如下图
[libprotobuf ERROR google/protobuf/text_format.cc:287] Error parsing text-format apollo.drivers.gnss.config.Config: 13:15: Expected integer, got: x
[ERROR] [1527064646.633720142]: Init stream nodelet failed.
[ERROR] [1527064646.633736056]: Init stream nodelet failed.
[libprotobuf ERROR google/protobuf/text_format.cc:287] Error parsing text-format apollo.drivers.gnss.config.Config: 13:15: Expected integer, got: x
[FATAL] [1527064646.976518327]: Failed to load config file: /home/tmp/ros/share/gnss_driver/conf/gnss_conf_mkz.txt
[ERROR] [1527064646.976596669]: Init parser nodelet failed.
[ERROR] [1527064646.976669424]: Init parser nodelet failed.
执行./apollo.sh build
命令会将原始的gnss_conf_mkz.txt拷贝到/home/tmp/ros/share/gnss_driver/conf/
目录下.这时执行./apollo.sh build_gnss
也不会将/modules/drivers/gnss/conf/gnss_conf_mkz.txt
替换掉原始的配置文件的拷贝版,因为新拷贝文件的修改时间最新,需要手动修改下/modules/drivers/gnss/conf/gnss_conf_mkz.txt
加个空格什么的,让这个文件的日期大于新拷贝文件.再执行./apollo.sh build_gnss
就替换掉了.
stream nodelete无法退出
在dreamview页面无法关闭GPS,然后查看rosnode list
发现stream进程无法退出,就用sudo kill -9
手动给干掉了.
不论输入的gps是什么,总是显示美国的地点
参考docs/howto/how_to_use_apollo_2.5_navigation_mode_cn.md
里面的4.3,在
/modules/common/data/global_flagfile.txt
添加上--local_utm_zone_id=50
(北京).修改完后不需要重新编译,因为在输出目录中的txt文件都是软链接原始文件
然后参考docs/quickstart/apollo_software_installation_guide_cn.md
里面的步骤3 修改zone. 修改完后需要重新编译
gnss driver有4个nodelete,stream_nodelet,parser_nodelet,rtcm_parser_nodelet,tf_broadcaster_nodelet。
/apollo/sensor/gnss/raw_data //data stream data
/apollo/sensor/gnss/rtcm_data //rtk_from stream data
/apollo/sensor/gnss/stream_status
/apollo/sensor/gnss/raw_data
发送出来的数据并进行解析。 /apollo/sensor/gnss/best_pose
/apollo/sensor/gnss/corrected_imu
/apollo/sensor/gnss/gnss_status
/apollo/sensor/gnss/imu
/apollo/sensor/gnss/ins_stat
/apollo/sensor/gnss/ins_status
/apollo/sensor/gnss/odometry
/apollo/sensor/gnss/rtk_eph
/apollo/sensor/gnss/rtk_obs
此nodelet解析协议可扩展,扩展方式:
1. 在gnss_conf_mkz.txt
中修改data的format属性
2. 在data_parser.cpp
中添加代码,例如RTCM_V3
3. 在CMakeLists.txt
中新增parser_nodelet target的源文件
4. 其余的就需要实现类似rtcm3_parser.cpp
文件里面的内容
Parser *create_parser(config::Stream::Format format, bool is_base_station = false) {
switch (format) {
case config::Stream::NOVATEL_BINARY:
return Parser::create_novatel();
case config::Stream::RTCM_V3:
return Parser::create_rtcm_v3();
default:
return nullptr;
}
}
/apollo/sensor/gnss/rtcm_data
发送出来的数据并进行解析。 /apollo/sensor/gnss/rtk_eph
/apollo/sensor/gnss/rtk_obs
/apollo/sensor/gnss/odometry
数据并将转化成tf数据发出来。gnss_conf_mkz.txt分成两部分,一部分是数据来源,发送;另一部分是需要下发的设置gps设备命令。如下:
#/apollo/sensor/gnss/raw_data 数据来源
data {
format: NOVATEL_BINARY
serial {
device: "/dev/ttyUSB0"
baud_rate: 115200
}
}
#/apollo/sensor/gnss/rtcm_data 数据来源
rtk_from {
format: RTCM_V3
ntrip {
address: "x.x.x.x"
port: x
mount_point: "x"
user: "x"
password: "x"
timeout_s: x
}
}
#将rtk数据再次转发
rtk_to {
format: NOVATEL_BINARY
serial {
device: "/dev/ttyUSB1"
baud_rate: 115200
}
}
#需不需要将数据再次转发,和rtk_to相关
rtk_solution_type: RTK_RECEIVER_SOLUTION
###下发gps设备的控制命令
login_commands: "UNLOGALL THISPORT\r\n"
login_commands: "SETIMUTOANTOFFSET 0.00 1.10866 1.14165 0.05 0.05 0.08\r\n"
login_commands: "SETINSOFFSET 0 0 0\r\n"
login_commands: "LOG COM2 GPRMC ONTIME 1.0 0.25\r\n"
login_commands: "EVENTOUTCONTROL MARK2 ENABLE POSITIVE 999999990 10\r\n"
login_commands: "EVENTOUTCONTROL MARK1 ENABLE POSITIVE 500000000 500000000\r\n"
login_commands: "LOG NCOM1 GPGGA ONTIME 1.0\r\n"
login_commands: "log bestgnssposb ontime 0.5\r\n"
login_commands: "log bestgnssvelb ontime 0.5\r\n"
login_commands: "log bestposb ontime 0.5\r\n"
login_commands: "log INSPVAXB ontime 0.5\r\n"
login_commands: "log INSPVASB ontime 0.01\r\n"
login_commands: "log CORRIMUDATASB ontime 0.01\r\n"
login_commands: "log INSCOVSB ontime 1\r\n"
login_commands: "log mark1pvab onnew\r\n"
login_commands: "log imutoantoffsetsb once\r\n"
login_commands: "log vehiclebodyrotationb onchanged\r\n"
logout_commands: "EVENTOUTCONTROL MARK2 DISABLE\r\n"
logout_commands: "EVENTOUTCONTROL MARK1 DISABLE\r\n"
详细内容可以参考文件:
docs/quickstart/apollo_software_installation_guide_cn.md
modules/drivers/gnss/proto/config.proto
非常好理解
以下三个msg都只在MSF Localization算法中使用
msg | 位置 | 格式 | topic | 提供 |
---|---|---|---|---|
GnssBestPose | gnss_best_pose.proto | GPS中的BESTPOSA | /apollo/sensor/gnss/best_pose | 司南 novetal |
EpochObservation | gnss_raw_observation.proto | 未知 | /apollo/sensor/gnss/rtk_obs | novetal |
GnssEphemeris | gnss_raw_observation.proto | 未知 | /apollo/sensor/gnss/rtk_eph | novetal |