树莓派安装MAVROS的一些坑

一.基于原生系统安装ROS

详见文章https://blog.csdn.net/qq_33662995/article/details/98645837,写的很详细了。

 

二.源码安装MAVROS

由于树莓派环境下不能直接从二进制安装,因此只能按照操作说明从源码编译。

操作说明完全参考官方教程

注意点1:

这条指令末尾的操作系统名一定要换成当前使用的操作系统。

注意点2:

模块在安装到五六十的时候会报一次错误,类似于 “logError not in the scope”,这是因为缺少logError的宏定义导致的,直接在该文件下添加宏定义即可:

文件目录: /usr/include/console_bridge/console.h

添加:

#define logWarn CONSOLE_BRIDGE_logWarn
#define logError CONSOLE_BRIDGE_logError
#define logDebug CONSOLE_BRIDGE_logDebug
#define logInform CONSOLE_BRIDGE_logInform

参考网址:https://github.com/ros/console_bridge/issues/56。

问题解决。

注意点3:

报错:

/home/pi/ros_catkin_ws/src/actionlib/src/connection_monitor.cpp:278:66: error: no matching function for call to ‘boost::date_time::subsecond_duration::subsecond_duration(double)’
       boost::posix_time::milliseconds(time_left.toSec() * 1000.0f));

<== Failed to process package 'actionlib': 
  Command '['/opt/ros/kinetic/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2 

这是因为boost 1.67版本以后不允许部分函数在传参的时候进行自动类型转换,要求一定要手动对应参数类型。从而报“no matching function”错误。

解决办法:sudo nano打开出错文件,把报错的函数的参数前面手动加一个强制类型转换即可。

本例中修改 /home/pi/ros_catkin_ws/src/actionlib/src/connection_monitor.cpp 文件第278行的语句:

boost::posix_time::milliseconds(time_left.toSec() * 1000.0f));

改为

boost::posix_time::milliseconds((long)(time_left.toSec() * 1000.0f)));

即可。参考链接 https://gitlab.com/orcus/orcus/commit/f7485813af8e50f88c77312fb29b7bb489a0a17d?view=inline。

问题解决。

注意点4:

报错:

/opt/ros/kinetic/include/actionlib/destruction_guard.h:62:80: error: no matching function for call to ‘boost::date_time::subsecond_duration::subsecond_duration(float)’ count_condition_.timed_wait(lock, boost::posix_time::milliseconds(1000.0f));

解决办法:和问题3是一回事儿。sudo nano打开出错文件,把报错的函数的参数前面手动加一个强制类型转换即可。

本例中修改 /home/pi/ros_catkin_ws/src/actionlib/include/actionlib/destruction_guard.h 文件第62行的语句:

count_condition_.timed_wait(lock, boost::posix_time::milliseconds(1000.0f));

为改

count_condition_.timed_wait(lock, boost::posix_time::milliseconds((long)1000.0f));

即可。注意到,报错文件位于/opt/目录下,但修改的文件位于home目录下,这是因为opt目录下的文件就是在编译的时候从home目录下cp过去的,home目录下的是源头。

问题解决。

 

你可能感兴趣的:(配环境)