相对于树莓派的1G内存来讲,NanoPC T4的4G内存,性能提升了不止一倍,树莓派内存不足,容易编译失败,还要添加swap来凑,NanoPC T4的内存足够完成编译过程
1.首先说第一个坑,我安装的系统是rk3399-eflasher-friendlydesktop-bionic-4.4-arm64-20190511.img,这个系统我的感觉有点精分,从理论上来讲,他就是一个定制版本的Ubuntu 18.04,但是其内核版本很低,还是4.4,但是文件系统里面自带了一个高版本的OpenCV 4,而在安装ros时,会再安装上去一个opencv3,导致两个版本冲突,会编译失败,所以装好系统之后第一件事就是把opencv4干掉,我的方法是通过locate命令,找到所有opencv4的路径,然后删除,这个系统默认不带locate命令,可以安装
sudo apt install mlocate -y
2.安装qt4,因为编译小R 机器人附送的代码需要依赖qt4,
sudo apt install qt4-default -y
3. 正常安装melodic即可,我还是把官方的命令再粘贴一遍
http://wiki.ros.org/melodic/Installation/Ubuntu
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-ros-base
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
sudo usermod -aG dialout $USER
安装完成,退出该终端,重新打开一个终端
4. 安装一些依赖包
sudo apt-get install -y ros-melodic-rosserial
sudo apt-get install -y ros-melodic-navigation
sudo apt-get install -y ros-melodic-teleop-twist-keyboard
sudo ln -s /dev/ttyUSB0 /dev/xrbase
5. 把ros-core1903.zip 复制到 /home/pi 目录下,unzip 解压出 catkin_ws 目录,进入catkin_ws,删除build目录,然后执行catkin_make 重新编译,如果编译过程中出现缺少依赖,可以参考 https://blog.csdn.net/zhqh100/article/details/98594927,虽然这里面没有全部列举出所有的依赖包,不过也可以看出规律来,缺少什么就安装一下ros-melodic-xxxxx
6. 编译过程中会有一个报错,大致如下:
/home/pi/catkin_ws/src/xrrobot_project/riki_follower/src/follower.cpp:318:24: error: expected constructor, destructor, or type conversion before ‘(’ token
PLUGINLIB_DECLARE_CLASS(riki_follower, RikiFollower, riki_follower::RikiFollower, nodelet::Nodelet);
解决方法为把上面一行改为
PLUGINLIB_EXPORT_CLASS(riki_follower::RikiFollower, nodelet::Nodelet);
如果再遇到类似错误,也是类似修改
7. 还有一个报错是
/home/pi/catkin_ws/src/xrrobot_project/frontier_exploration/src/explore_server.cpp:44:136: error: no matching function for call to ‘costmap_2d::Costmap2DROS::Costmap2DROS(const char [16], tf::TransformListener&)’
没有解决,我直接把目录frontier_exploration干掉了
8. 编译完成后添加环境变量
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo usermod -aG dialout $USER
9.另起终端启动服务
roslaunch xrrobot bringup.launch
要键盘控制小车运行,另起一个终端,执行如下命令即可
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
10.
sudo apt install git libv4l-dev
sudo apt install ros-melodic-depth-image-proc
sudo apt install ros-melodic-camera-info-manager
sudo apt install ros-melodic-tf2-geometry-msgs
sudo apt install ros-melodic-costmap-2d
sudo apt install ros-melodic-geographic-msgs
sudo apt install ros-melodic-move-base-msgs
sudo apt install libpcl-dev
sudo apt install ros-melodic-rosserial-python
sudo apt install libusb-1.0-0-dev
sudo apt install libudev-dev
11.
roscore
rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0 _baud:=115200
rosrun teleop_twist_keyboard teleop_twist_keyboard.py