失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Gazebo仿真UUV水下机器人

Gazebo仿真UUV水下机器人

时间:2023-09-30 06:11:36

相关推荐

Gazebo仿真UUV水下机器人

最近准备学习一下ros,gazebo和一个水下rov模拟器。

uuv_simulator(/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 /uuvsimulator/uuv_simulator.git

git clone /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:/api/math/4.0/namespaceignition_1_1math.html

V6:/api/math/6.7/namespaceignition_1_1math.html

还是在uuv_gazebo_plugins的package中,中计算bounding box调用的类发生了改动,原代码为ignition::math::Box ,新版本更名为 ignition::math::AxisAlignedBox,而新版本的ignition::math::Box是新的实现。需要在BuoyantObject.hh,,中做出相应修正。

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;

2、对于:

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、对于:

// FIXME(mam0box) This is a work around the problem of the invalid bounding// box returned by Gazeboif (_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 dimensionsthis->SetBoundingBox(boundingBox);}}

修改为:

// FIXME(mam0box) This is a work around the problem of the invalid bounding// box returned by Gazeboif (_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 dimensionsthis->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版权协议,转载请附上原文出处链接及本声明。

原文链接:/xiekaikaibing/article/details/114984613

启动湖泊

roslaunch uuv_gazebo_worlds auv_underwater_world.launch

启动环境和水下机器人pid控制

执行命令:

roslaunch uuv_gazebo start_pid_demo_with_teleop.launch

(未完待续)

如果觉得《Gazebo仿真UUV水下机器人》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。