赞
踩
最近准备学习一下ros,gazebo和一个水下rov模拟器。
uuv_simulator(https://github.com/uuvsimulator/uuv_simulator)是一个非常优秀的基于ROS&GAZEBO开源水下机器人仿真项目,能为水下机器人的应用与算法提供一个较为理想的仿真环境进行测试。更详细的内容请仔细研读项目的wiki资料。
项目的机器人模型有两款ROV:desistek_saga与rexrov2,两款AUV:eca_a9与lauv_gazebo。项目内都提供了链接。同时在RexROV2的项目中《Development and Commissioning of a DP system for ROV SF 30k》一文详细介绍了如何构建水下机器人模型,值得了解一下。
在这里要说明的是仿真环境毕竟是虚拟的,水下使用光学相机不可能有这么好的能见度。实际上uuv_simulator里是有水雾设定以模拟水下光的衰减的情况,具体可以阅读其论文。不过此次仿真测试没有使用。
最后简要说一下怎么安装和测试。
首先根据网上资料安装好ros noetic和gazebo,下面是针对uuv的导入:
安装:
mkdir -p xxx/src
cd xxx/src
git clone https://github.com/uuvsimulator/uuv_simulator.git
git clone https://github.com/cabinx/cabin_auv_simulation.git
cd ..
catkin_make
注意:我个人的系统为ubutu20.04,ROS版本为neotic,Gazebo版本为11.0。所以编译uuv_simulator时出现了一些问题,具体如下:
一、gazebo11与sdformat-9.2问题
sdformat版本升级后,编译器的版本支持也需要做出相应改动。大致会出现如下报错:
/usr/include/sdformat-9.2/sdf/Param.hh:72:57: error: expected constructor, destructor, or type conversion before ‘;’ token template<class T> ParamStreamer(T) -> ParamStreamer<T>; /usr/include/sdformat-9.2/sdf/Param.hh:83:47: error: ‘variant’ is not a member of ‘std’ ParamStreamer<std::variant<Ts...>> sv)
根据error的log定位到uuv_gazebo_plugins的package,在其目录下的CMakeLists.txt中添加对c++17的支持:
- set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
二、gazebo11与Ignition Math库问题
Ignition Math库相应升级到了v6版本,库内一些类的命名也有所变动,导致编译时出现错误。在此给出v4版本和v6版本的API链接:
V4:https://ignitionrobotics.org/api/math/4.0/namespaceignition_1_1math.html
V6:https://ignitionrobotics.org/api/math/6.7/namespaceignition_1_1math.html
还是在uuv_gazebo_plugins的package中,http://HydrodynamicModel.cc中计算bounding box调用的类发生了改动,原代码为ignition::math::Box ,新版本更名为 ignition::math::AxisAlignedBox,而新版本的ignition::math::Box是新的实现。需要在BuoyantObject.hh,http://BuoyantObject.cc,http://HydrodynamicModel.cc中做出相应修正。
1、对于BuoyantObject.hh:
- public: void SetBoundingBox(const ignition::math::Box &_bBox);
-
- ...
-
- protected: ignition::math::Box boundingBox;
修改为:
- public: void SetBoundingBox(const ignition::math::AxisAlignedBox &_bBox);
-
- ...
-
- protected: ignition::math::AxisAlignedBox boundingBox;
- void BuoyantObject::SetBoundingBox(const ignition::math::Box &_bBox)
- {
- this->boundingBox = ignition::math::Box(_bBox);
-
- gzmsg << "New bounding box for " << this->link->GetName() << "::"
- << this->boundingBox << std::endl;
- }
修改为:
- void BuoyantObject::SetBoundingBox(const ignition::math::AxisAlignedBox &_bBox)
- {
- this->boundingBox = ignition::math::AxisAlignedBox(_bBox);
-
- gzmsg << "New bounding box for " << this->link->GetName() << "::"
- << this->boundingBox << std::endl;
- }
3、对于http://HydrodynamicModel.cc:
- // FIXME(mam0box) This is a work around the problem of the invalid bounding
- // box returned by Gazebo
- if (_sdf->HasElement("box"))
- {
- sdf::ElementPtr sdfModel = _sdf->GetElement("box");
- if (sdfModel->HasElement("width") && sdfModel->HasElement("length") &&
- sdfModel->HasElement("height"))
- {
- double width = sdfModel->Get<double>("width");
- double length = sdfModel->Get<double>("length");
- double height = sdfModel->Get<double>("height");
- ignition::math::Box boundingBox = ignition::math::Box(
- ignition::math::Vector3d(-width / 2, -length / 2, -height / 2),
- ignition::math::Vector3d(width / 2, length / 2, height / 2));
- // Setting the the bounding box from the given dimensions
- this->SetBoundingBox(boundingBox);
- }
- }

修改为:
- // FIXME(mam0box) This is a work around the problem of the invalid bounding
- // box returned by Gazebo
- if (_sdf->HasElement("box"))
- {
- sdf::ElementPtr sdfModel = _sdf->GetElement("box");
- if (sdfModel->HasElement("width") && sdfModel->HasElement("length") &&
- sdfModel->HasElement("height"))
- {
- double width = sdfModel->Get<double>("width");
- double length = sdfModel->Get<double>("length");
- double height = sdfModel->Get<double>("height");
- ignition::math::AxisAlignedBox boundingBox = ignition::math::AxisAlignedBox(
- ignition::math::Vector3d(-width / 2, -length / 2, -height / 2),
- ignition::math::Vector3d(width / 2, length / 2, height / 2));
- // Setting the the bounding box from the given dimensions
- this->SetBoundingBox(boundingBox);
- }
- }

三 .错误:
[ 97%] Linking CXX shared library /home/wmc/space/gazebo/uuv/devel/lib/libuuv_gazebo_ros_base_sensor_plugin.so
/home/wmc/space/gazebo/uuv/src/uuv_simulator/uuv_sensor_plugins/uuv_sensor_ros_plugins/src/gazebo_ros_image_sonar.cpp: In member function ‘cv::Mat gazebo::GazeboRosImageSonar::ConstructVisualScanImage(cv::Mat&)’:
/home/wmc/space/gazebo/uuv/src/uuv_simulator/uuv_sensor_plugins/uuv_sensor_ros_plugins/src/gazebo_ros_image_sonar.cpp:945:71: error: ‘CV_AA’ was not declared in this scope; did you mean ‘CV_AVX’?
945 | cv::ellipse(scan, center, axes, -90, -fov/2.-0.5, fov/2., white, 1, CV_AA); //, int lineType=LINE_8, 0);
| ^~~~~
| CV_AVX
定位gazebo_ros_image_sonar.cpp,加入头文件
#include <opencv2/imgproc/imgproc_c.h>
至此,编译顺利通过,仿真运行也没有问题。
(以上是引用的其他博主的文章和一些自己的问题,在此表示感谢!)
————————————————
版权声明:本文为CSDN博主「cabinx」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiekaikaibing/article/details/114984613
启动湖泊
roslaunch uuv_gazebo_worlds auv_underwater_world.launch
执行命令:
roslaunch uuv_gazebo start_pid_demo_with_teleop.launch
(未完待续)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。