33

阿木币

4

精华

32 小时

在线时间

技术大V

Rank: 4

发表于 2019-9-30 14:55:03 12150 浏览 10 回复

[入门教程] px4激光雷达避障仿真

px4激光雷达避障仿真

  • 环境搭建
  • 避障实现

废话不多说,直接上教程。

环境搭建

需要如下环境:

若进行激光雷达的仿真,先要把px4的软件仿真gazebo环境搭建好,教程传送门

先确保gazebo仿真没问题

make px4_sitl_default gazebo

然后确保运行px4源码中launch文件夹下posix_sitl.launch没问题

roslaunch posix_sitl.launch

这里根据ROS的版本分两种情况:

  • ROS Melodic Morenia版本

如果你是这个版本,那么恭喜你,只需要一个地方的改动。

打开posix_sitl.launch, 把iris模型,修改为iris_rplidar模型

![image]() gazebo 将会加载激光雷达的仿真

效果如下

![iamge]()

重新打开一个终端,查看雷达的点云数据

rostopic echo /laser/scan

![image]()

  • ROS Kinetic Kame版本

1: 打开posix_sitl.launch, 把iris模型,修改为iris_rplidar模型

![image]() 2:进入如下目录,修改iris_rplidar文件夹下的iris_rplidar.sdf模型文件

~/yourProject/Firmware/Tools/sitl_gazebo/models/iris_rplidar

![image]()

3:进入如下目录,修改rplidar文件夹下的model.sdf模型文件

~/yourProject/Firmware/Tools/sitl_gazebo/models/rplidar

![image]()

搞定,返回运行

roslaunch posix_sitl.launch

gazebo仿真中就会有激光雷达了。

避障实现

下载PX4_command

搭建好px4_command仿真环境教程传送门

运行如下的的脚本

amov@amov:~/AMOV_WorkSpace/px4_ws/src/px4_command/sh/sh_for_simulation$ ./sitl_gazebo_laserCollAvo.sh

这里我们提供不那么智能的避障策略,如果你有实现了更好避障算法,非常欢迎你的分享。[backcolor=rgb(247, 247, 247)]<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>[/backcolor] ![image]()


扫一扫浏览分享
回复

使用道具 举报

176

阿木币

0

精华

349 小时

在线时间

版主

Rank: 7Rank: 7Rank: 7

发表于 2019-9-30 15:05:08
{:4_88:}{:4_88:}{:4_88:}
回复

使用道具 举报

0

阿木币

0

精华

0 小时

在线时间

应届白菜

Rank: 1

发表于 2019-10-15 22:03:52
双击6666
回复

使用道具 举报

2

阿木币

0

精华

1 小时

在线时间

应届白菜

Rank: 1

发表于 2019-11-6 21:15:41
您好,按照这个走下来之后,catkin_make编译不通过是什么原因?报错如下:

[ 81%] Building CXX object px4_command/CMakeFiles/eigen_test.dir/src/Utilities/eigen_test.cpp.o
[ 82%] Building CXX object px4_command/CMakeFiles/px4_pos_controller.dir/src/px4_pos_controller.cpp.o
[ 83%] Building CXX object px4_command/CMakeFiles/ground_station.dir/src/ground_station.cpp.o
In file included from /usr/include/c++/5/array:35:0,
                 from /opt/ros/kinetic/include/mavros/frame_tf.h:22,
                 from /media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:27:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
  ^
In file included from /media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:27:0:
/opt/ros/kinetic/include/mavros/frame_tf.h:37:7: error: expected nested-name-specifier before ‘Covariance3d’
using Covariance3d = sensor_msgs::Imu::_angular_velocity_covariance_type;
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:40:7: error: expected nested-name-specifier before ‘Covariance6d’
using Covariance6d = geometry_msgs::PoseWithCovariance::_covariance_type;
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:43:7: error: expected nested-name-specifier before ‘Covariance9d’
using Covariance9d = boost::array<double, 81>;
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:46:7: error: expected nested-name-specifier before ‘EigenMapCovariance3d’
using EigenMapCovariance3d = Eigen::Map<Eigen::Matrix<double, 3, 3, Eigen::RowM
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:47:7: error: expected nested-name-specifier before ‘EigenMapConstCovariance3d’
using EigenMapConstCovariance3d = Eigen::Map<const Eigen::Matrix<double, 3, 3,
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:50:7: error: expected nested-name-specifier before ‘EigenMapCovariance6d’
using EigenMapCovariance6d = Eigen::Map<Eigen::Matrix<double, 6, 6, Eigen::RowM
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:51:7: error: expected nested-name-specifier before ‘EigenMapConstCovariance6d’
using EigenMapConstCovariance6d = Eigen::Map<const Eigen::Matrix<double, 6, 6,
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:54:7: error: expected nested-name-specifier before ‘EigenMapCovariance9d’
using EigenMapCovariance9d = Eigen::Map<Eigen::Matrix<double, 9, 9, Eigen::RowM
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:55:7: error: expected nested-name-specifier before ‘EigenMapConstCovariance9d’
using EigenMapConstCovariance9d = Eigen::Map<const Eigen::Matrix<double, 9, 9,
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:60:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11
enum class StaticTF {
^
/opt/ros/kinetic/include/mavros/frame_tf.h:91:1: error: ‘Covariance3d’ does not name a type
Covariance3d transform_frame(const Covariance3d &cov, const Eigen::Quaterniond
^
/opt/ros/kinetic/include/mavros/frame_tf.h:98:1: error: ‘Covariance6d’ does not name a type
Covariance6d transform_frame(const Covariance6d &cov, const Eigen::Quaterniond
^
/opt/ros/kinetic/include/mavros/frame_tf.h:105:1: error: ‘Covariance9d’ does not name a type
Covariance9d transform_frame(const Covariance9d &cov, const Eigen::Quaterniond
^
/opt/ros/kinetic/include/mavros/frame_tf.h:119:1: error: ‘Covariance3d’ does not name a type
Covariance3d transform_static_frame(const Covariance3d &cov, const StaticTF tra
^
/opt/ros/kinetic/include/mavros/frame_tf.h:126:1: error: ‘Covariance6d’ does not name a type
Covariance6d transform_static_frame(const Covariance6d &cov, const StaticTF tra
^
/opt/ros/kinetic/include/mavros/frame_tf.h:133:1: error: ‘Covariance9d’ does not name a type
Covariance9d transform_static_frame(const Covariance9d &cov, const StaticTF tra
^
In file included from /media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:27:0:
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_orientation_ned_enu(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:153:43: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_orientation(in, StaticTF::NED_TO_ENU);
                                           ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_orientation_enu_ned(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:162:43: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_orientation(in, StaticTF::ENU_TO_NED);
                                           ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_orientation_aircraft_baselink(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:171:43: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_orientation(in, StaticTF::AIRCRAFT_TO_BASELINK);
                                           ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_orientation_baselink_aircraft(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:180:43: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_orientation(in, StaticTF::BASELINK_TO_AIRCRAFT);
                                           ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_frame_ned_enu(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:188:44: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_static_frame(in, StaticTF::NED_TO_ENU);
                                            ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_frame_enu_ned(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:197:44: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_static_frame(in, StaticTF::ENU_TO_NED);
                                            ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_frame_aircraft_baselink(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:206:44: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_static_frame(in, StaticTF::AIRCRAFT_TO_BASELINK);
                                            ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_frame_baselink_aircraft(const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:215:44: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_static_frame(in, StaticTF::BASELINK_TO_AIRCRAFT);
                                            ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_frame_ecef_enu(const T&, const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:227:56: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_static_frame(in, map_origin, StaticTF::ECEF_TO_ENU);
                                                        ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘T mavros::ftf::transform_frame_enu_ecef(const T&, const T&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:239:56: error: ‘StaticTF’ is not a class or namespace
  return detail::transform_static_frame(in, map_origin, StaticTF::ENU_TO_ECEF);
                                                        ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘void mavros::ftf::quaternion_to_rpy(const Quaterniond&, double&, double&, double&)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:325:13: error: ‘rpy’ does not name a type
  const auto rpy = quaternion_to_rpy(q);
             ^
/opt/ros/kinetic/include/mavros/frame_tf.h:326:9: error: ‘rpy’ was not declared in this scope
  roll = rpy.x();
         ^
/opt/ros/kinetic/include/mavros/frame_tf.h: At global scope:
/opt/ros/kinetic/include/mavros/frame_tf.h:344:69: error: ‘std::array’ has not been declared
inline void quaternion_to_mavlink(const Eigen::Quaterniond &q, std::array<float
                                                                     ^
/opt/ros/kinetic/include/mavros/frame_tf.h:344:74: error: expected ‘,’ or ‘...’ before ‘<’ token
e void quaternion_to_mavlink(const Eigen::Quaterniond &q, std::array<float, 4>
                                                                     ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘void mavros::ftf::quaternion_to_mavlink(const Quaterniond&, int)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:346:2: error: ‘qmsg’ was not declared in this scope
  qmsg[0] = q.w();
  ^
/opt/ros/kinetic/include/mavros/frame_tf.h: At global scope:
/opt/ros/kinetic/include/mavros/frame_tf.h:355:60: error: ‘array’ in namespace ‘std’ does not name a template type
inline Eigen::Quaterniond mavlink_to_quaternion(const std::array<float, 4> &q)
                                                            ^
/opt/ros/kinetic/include/mavros/frame_tf.h:355:65: error: expected ‘,’ or ‘...’ before ‘<’ token
inline Eigen::Quaterniond mavlink_to_quaternion(const std::array<float, 4> &q)
                                                                 ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘Eigen::Quaterniond mavros::ftf::mavlink_to_quaternion(int)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:357:28: error: ‘q’ was not declared in this scope
  return Eigen::Quaterniond(q[0], q[1], q[2], q[3]);
                            ^
/opt/ros/kinetic/include/mavros/frame_tf.h: At global scope:
/opt/ros/kinetic/include/mavros/frame_tf.h:364:54: error: ‘std::array’ has not been declared
inline void covariance_to_mavlink(const T &cov, std::array<float, SIZE> &covmsg
                                                      ^
/opt/ros/kinetic/include/mavros/frame_tf.h:364:59: error: expected ‘,’ or ‘...’ before ‘<’ token
inline void covariance_to_mavlink(const T &cov, std::array<float, SIZE> &covmsg
                                                           ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘void mavros::ftf::covariance_to_mavlink(const T&, int)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:366:38: error: ‘covmsg’ was not declared in this scope
  std::copy(cov.cbegin(), cov.cend(), covmsg.begin());
                                      ^
/opt/ros/kinetic/include/mavros/frame_tf.h: At global scope:
/opt/ros/kinetic/include/mavros/frame_tf.h:373:61: error: ‘std::array’ has not been declared
inline void covariance_urt_to_mavlink(const T &covmap, std::array<float, ARR_SI
                                                             ^
/opt/ros/kinetic/include/mavros/frame_tf.h:373:66: error: expected ‘,’ or ‘...’ before ‘<’ token
inline void covariance_urt_to_mavlink(const T &covmap, std::array<float, ARR_SI
                                                                  ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘void mavros::ftf::covariance_urt_to_mavlink(const T&, int)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:375:7: error: ‘m’ does not name a type
  auto m = covmap;
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:376:25: error: ‘m’ was not declared in this scope
  std::size_t COV_SIZE = m.rows() * (m.rows() + 1) / 2;
                         ^
/opt/ros/kinetic/include/mavros/frame_tf.h:381:7: error: ‘out’ does not name a type
  auto out = covmsg.begin();
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:385:5: error: ‘out’ was not declared in this scope
    *out++ = m(y, x);
     ^
/opt/ros/kinetic/include/mavros/frame_tf.h: At global scope:
/opt/ros/kinetic/include/mavros/frame_tf.h:394:57: error: ‘array’ in namespace ‘std’ does not name a template type
inline void mavlink_urt_to_covariance_matrix(const std::array<float, ARR_SIZE>
                                                         ^
/opt/ros/kinetic/include/mavros/frame_tf.h:394:62: error: expected ‘,’ or ‘...’ before ‘<’ token
inline void mavlink_urt_to_covariance_matrix(const std::array<float, ARR_SIZE>
                                                              ^
/opt/ros/kinetic/include/mavros/frame_tf.h: In function ‘void mavros::ftf::mavlink_urt_to_covariance_matrix(int)’:
/opt/ros/kinetic/include/mavros/frame_tf.h:396:25: error: ‘covmat’ was not declared in this scope
  std::size_t COV_SIZE = covmat.rows() * (covmat.rows() + 1) / 2;
                         ^
/opt/ros/kinetic/include/mavros/frame_tf.h:401:7: error: ‘in’ does not name a type
  auto in = covmsg.begin();
       ^
/opt/ros/kinetic/include/mavros/frame_tf.h:405:40: error: ‘in’ was not declared in this scope
    covmat(x, y) = static_cast<double>(*in++);
                                        ^
/media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp: In function ‘float CalculDirection(Point2D&)’:
/media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:193:14: error: ISO C++ forbids declaration of ‘dir_ite’ with no type [-fpermissive]
   for (auto &dir_ite : cand_dir) {
              ^
/media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:193:24: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
   for (auto &dir_ite : cand_dir) {
                        ^
/media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp: In function ‘void gps_cb(const ConstPtr&)’:
/media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:264:63: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  current_gps = { msg->latitude, msg->longitude, msg->altitude };
                                                               ^
/media/zhu/software/UAV/px4_ws/src/px4_command/src/Application/collision_avoidance_vfh.cpp:264:14: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  current_gps = { msg->latitude, msg->longitude, msg->altitude };
              ^
px4_command/CMakeFiles/collision_avoidance_vfh.dir/build.make:62: recipe for target 'px4_command/CMakeFiles/collision_avoidance_vfh.dir/src/Application/collision_avoidance_vfh.cpp.o' failed
make[2]: *** [px4_command/CMakeFiles/collision_avoidance_vfh.dir/src/Application/collision_avoidance_vfh.cpp.o] Error 1
CMakeFiles/Makefile2:696: recipe for target 'px4_command/CMakeFiles/collision_avoidance_vfh.dir/all' failed
make[1]: *** [px4_command/CMakeFiles/collision_avoidance_vfh.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
[ 84%] Linking CXX executable /media/zhu/software/UAV/px4_ws/devel/lib/px4_command/eigen_test
[ 84%] Built target eigen_test
[ 85%] Linking CXX executable /media/zhu/software/UAV/px4_ws/devel/lib/px4_command/ground_station
[ 85%] Built target ground_station
[ 87%] Linking CXX executable /media/zhu/software/UAV/px4_ws/devel/lib/px4_command/px4_pos_controller
[ 87%] Built target px4_pos_controller
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

回复 点赞

使用道具 举报

106

阿木币

1

精华

397 小时

在线时间

技术大V

Rank: 4

发表于 2019-11-7 09:22:10
zwj001 发表于 2019-11-6 21:15
您好,按照这个走下来之后,catkin_make编译不通过是什么原因?报错如下:

[ 81%] Building CXX object px ...

github上面已解决
回复 点赞

使用道具 举报

30

阿木币

0

精华

50 小时

在线时间

老司机

Rank: 2

发表于 2019-12-6 11:03:22
在做激光雷达仿真时,这块出现这个问题resource  px4 not found 是什么原因啊, 求指点啊,谢谢
bingo@ubuntu:~/project/px4_src/Firmware/launch$ roslaunch posix_sitl.launch
... logging to /home/bingo/.ros/log/b37ded86-17d4-11ea-9d3b-000c29f3b76c/roslaunch-ubuntu-11360.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Resource not found: px4
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/bingo/px4_ws/src
ROS path [2]=/opt/ros/melodic/share
ROS path [3]=/home/bingo/project/px4_src/Firmware/Tools/sitl_gazebo
The traceback for the exception was written to the log file

回复 点赞

使用道具 举报

106

阿木币

1

精华

397 小时

在线时间

技术大V

Rank: 4

发表于 2019-12-10 09:08:32
你把添加到~/.bashrc里面的有关Firmware相关的路径,手动source一下,然后在运行roslaunch posix_sitl.launch

报错原因就是你的source路径之后,虚拟机中没有识别到,你需要手动自己source一下.
回复 点赞

使用道具 举报

30

阿木币

0

精华

50 小时

在线时间

老司机

Rank: 2

发表于 2019-12-16 10:19:15
eason 发表于 2019-12-10 09:08
你把添加到~/.bashrc里面的有关Firmware相关的路径,手动source一下,然后在运行roslaunch posix_sitl.launch ...

已解决,谢谢呀
回复 点赞

使用道具 举报

176

阿木币

0

精华

349 小时

在线时间

版主

Rank: 7Rank: 7Rank: 7

发表于 2019-12-16 14:33:50
lh0323 发表于 2019-12-16 10:19
已解决,谢谢呀


回复 点赞

使用道具 举报

0

阿木币

0

精华

1 小时

在线时间

应届白菜

Rank: 1

发表于 2020-2-29 11:03:54
eason 发表于 2019-11-7 09:22
github上面已解决

您好 我也遇到了这个问题 请问怎么解决
回复 点赞

使用道具 举报

下一页 »
12下一页
返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表