Apollo开发避坑指南--

本文用于本人在开发Apollo代码过程中遇到的坑,不定时更新.

第一坑:不同版本的代码之间都有细微的更新,不能拿老版本的代码直接放入新版本

最近在为apollo新增车辆驱动,看了can协议之后发现与ch(酷黑)也就是kit的协议比较相近,因此直接将整个ch目录拷贝进行更改.最早的时候用的r5.0.0的ch代码.最近成功下载了r5.5.0的代码,想在新的分支上进行开发学习,因此将之前的代码直接拷贝进新的版本.错误频出,让人怀疑人生.举个最简单的例子.
5.0的版本中计时函数的调用方式是:

start = ::apollo::common::time::AsInt64<::apollo::common::time::micros>(
        ::apollo::common::time::Clock::Now());
        ..........
end = ::apollo::common::time::AsInt64<::apollo::common::time::micros>(
        ::apollo::common::time::Clock::Now());    
std::chrono::duration<double, std::micro> elapsed{end - start};   

而在5.5中计时函数则是这样的:

 start = absl::ToUnixMicros(::apollo::common::time::Clock::Now());
 ...........
 end = absl::ToUnixMicros(::apollo::common::time::Clock::Now());
 std::chrono::duration<double, std::micro> elapsed{end - start};

重点是新版本下会报错.

./modules/drivers/canbus/can_comm/message_manager.h:47:41: note:   'apollo::drivers::canbus::micros'
 using micros = std::chrono::microseconds;
                                         ^
modules/canbus/vehicle/ls/ls_controller.cc:478:11: error: 'AsInt64' is not a member of 'apollo::common::time'
     end = ::apollo::common::time::AsInt64<::apollo::common::time::micros>(
           ^
modules/canbus/vehicle/ls/ls_controller.cc:478:43: error: 'micros' is not a member of 'apollo::common::time'
     end = ::apollo::common::time::AsInt64<::apollo::common::time::micros>(
                                           ^
modules/canbus/vehicle/ls/ls_controller.cc:478:43: note: suggested alternative:
In file included from ./modules/canbus/vehicle/vehicle_controller.h:34:0,
                 from ./modules/canbus/vehicle/ls/ls_controller.h:25,
                 from modules/canbus/vehicle/ls/ls_controller.cc:18:
./modules/drivers/canbus/can_comm/message_manager.h:47:41: note:   'apollo::drivers::canbus::micros'
 using micros = std::chrono::microseconds;

因此,想在那个版本下开发就直接clone最新的代码,否则极容易出错.就算是某些可能很成熟的代码不太可能更新的代码也是会被更新的.

你可能感兴趣的:(百度APollo)