1、此步骤默认ros已安装好
2、创建工作空间
mkdir -p ~/ros/ws_bfp/src
cd ~/ros/ws_bfp
wstool init src
wstool set -t src isri-aist/BaselineFootstepPlanner [email protected]:isri-aist/BaselineFootstepPlanner.git --git -y
wstool update -t src
3、安装相关依赖
SBPL 包会在此步骤被安装
source /opt/ros/${ROS_DISTRO}/setup.bash #${ROS_DISTRO} #改成自己的ros版本
rosdep install -y -r --from-paths src --ignore-src
4、编译
catkin build baseline_footstep_planner -DCMAKE_BUILD_TYPE=RelWithDebInfo --catkin-make-args all tests
出现 catkin:command not found
主要原因是 catkin 包默认情况下是没有安装的,安装即可
sudo apt-get update
sudo apt-get install python-catkin-tools
编译成功后如下所示:
5、使用rosluanch运行程序
这里一定要source以下,不然后面的rosluanch会找不到launch文件
#先source到工作空间
source ./devel/setup.bash
#运行roslaunch程序
roslaunch baseline_footstep_planner footstep_planner.launch
6、可能出现的错误
如果出现下面的错误
File "/home/robot/ros/ws_bfp/src/isri-aist/BaselineFootstepPlanner/scripts/FootstepPlannerRvizServer.py", line 7, in <module>
from tf import transformations
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/__init__.py", line 30, in <module>
from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
from tf2_py import *
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
from ._tf2 import *
ImportError: dynamic module does not define module export function (PyInit__tf2)
[footstep_planner_rviz_server-3] process has died [pid 4591, exit code 1, cmd /home/robot/ros/ws_bfp/src/isri-aist/BaselineFootstepPlanner/scripts/FootstepPlannerRvizServer.py __name:=footstep_planner_rviz_server __log:=/home/robot/.ros/log/599aa97a-5067-11ed-adf2-046c592c2081/footstep_planner_rviz_server-3.log].
log file: /home/robot/.ros/log/599aa97a-5067-11ed-adf2-046c592c2081/footstep_planner_rviz_server-3*.log
是由于tf2是为python2写的使用python3会报错,有3种解决方案:
- 修改
~/ros/ws_bfp/src/isri-aist/BaselineFootstepPlanner/scripts
文件夹下的FootstepPlannerRvizServer.py
文件的头为
#! /usr/bin/env python2.7
此方案验证有效
- 将tf2用python3重新编译
1)安装python3依赖
sudo apt update
sudo apt install python3-catkin-pkg-modules python3-rospkg-modules python3-empy
2)预编译工作空间
mkdir -p ~/catkin_ws/src; cd ~/catkin_ws
catkin_make
source devel/setup.bash
wstool init
wstool set -y src/geometry2 --git https://github.com/ros/geometry2 -v 0.6.5
wstool up
rosdep install --from-paths src --ignore-src -y -r
3)使用python3编译
catkin_make --cmake-args \
-DCMAKE_BUILD_TYPE=Release \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DPYTHON_INCLUDE_DIR=/usr/include/python3.6m \
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so
其中的python路径可以换成自己的python路径
编译完后需要source到该工作空间source devel/setup.bash
或者添加到.bashrc
文件中。
7、ros一般的操作步骤
#创建工作空间,src目录下方包,包中的scripts文件夹下放python文件
$ mkdir -p ~/ros/ws_bwc/src
$ cd ~/ros/ws_bwc
$ wstool init src
#安装包依赖
$ source /opt/ros/${ROS_DISTRO}/setup.bash
$ rosdep install -y -r --from-paths src --ignore-src
https://answers.ros.org/question/326226/importerror-dynamic-module-does-not-define-module-export-function-pyinit__tf2/
https://github.com/ros/geometry2/issues/259
https://github.com/isri-aist/BaselineFootstepPlanner