日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

安装gazebo_手把手教你用Gazebo仿真UUV水下机器人

發布時間:2025/3/20 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 安装gazebo_手把手教你用Gazebo仿真UUV水下机器人 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

本節教程演示UUV的一些玩法,基于開源項目UUV,官方介紹文檔uuvsimulator??https://uuvsimulator.github.io/packages/uuv_simulator/intro/

仿真環境

系統:ubuntu16.04
軟件:ROS – kinetic
仿真:gazebo7

安裝仿真軟件

官網介紹目前支持的版本有三個:kunetic、lunar、melodic

安裝命令:

kinetic版本:sudo apt install ros-kinetic-uuv-simulatorlunar版本:sudo apt install ros-lunar-uuv-simulatormelodic版本:sudo apt install ros-melodic-uuv-simulator

如果希望從源碼安裝的朋友參考這里:

源碼安裝教程 ? https://uuvsimulator.github.io/installation/

這里不推薦源碼安裝,因為看了下github項目的issue中很多人顯示安裝報錯,所以emmm省的折騰。

啟動AUV海底世界

啟動帶海底的世界執行命令:

roslaunch uuv_gazebo_worlds auv_underwater_world.launch水世界效果圖如下(還是很帥的天空的云和海水都是在動的):

啟動赫爾庫勒斯沉船的世界執行命令:roslaunch uuv_gazebo_worlds herkules_ship_wreck.launch啟動湖泊

roslaunch uuv_gazebo_worlds lake.launch

其他的一些場景roslaunch uuv_gazebo_worlds mangalia.launchroslaunch uuv_gazebo_worlds munkholmen.launchroslaunch uuv_gazebo_worlds ocean_waves.launch

!注意這里的海浪都只是視覺效果不會將波浪的載荷加載在水下機器人上

水下機器人運動控制

啟動環境和水下機器人pid控制

執行命令:roslaunch uuv_gazebo start_pid_demo_with_teleop.launch這里機器人的速度控制還是經典的cmd_vel話題,我們可以自己創建速度控制腳本teletop.py:#!/usr/bin/env pythonimport rospyfrom geometry_msgs.msg import Twistimport sys, select, osif os.name == 'nt': import msvcrtelse: import tty, termiosFETCH_MAX_LIN_VEL = 5FETCH_MAX_ANG_VEL = 2.84LIN_VEL_STEP_SIZE = 0.01ANG_VEL_STEP_SIZE = 0.1msg = """Control Your Robot!---------------------------Moving around: w a s d x"""e = """Communications Failed"""def getKey(): if os.name == 'nt': return msvcrt.getch() tty.setraw(sys.stdin.fileno()) rlist, _, _ = select.select([sys.stdin], [], [], 0.1) if rlist: key = sys.stdin.read(1) else: key = '' termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings) return keydef vels(target_linear_vel, target_angular_vel): return "currently:\tlinear vel %s\t angular vel %s " % (target_linear_vel,target_angular_vel)def makeSimpleProfile(output, input, slop): if input > output: output = min( input, output + slop ) elif input < output: output = max( input, output - slop ) else: output = input return outputdef constrain(input, low, high): if input < low: input = low elif input > high: input = high else: input = input return inputdef checkLinearLimitVelocity(vel): vel = constrain(vel, -FETCH_MAX_LIN_VEL, FETCH_MAX_LIN_VEL) return veldef checkAngularLimitVelocity(vel): vel = constrain(vel, -FETCH_MAX_ANG_VEL, FETCH_MAX_ANG_VEL) return velif __name__=="__main__": if os.name != 'nt': settings = termios.tcgetattr(sys.stdin) rospy.init_node('fetch_teleop') pub = rospy.Publisher('/rexrov/cmd_vel', Twist, queue_size=10) status = 0 target_linear_vel = 0.0 target_angular_vel = 0.0 control_linear_vel = 0.0 control_angular_vel = 0.0 try: print(msg) while(1): key = getKey() if key == 'w' : target_linear_vel = checkLinearLimitVelocity(target_linear_vel + LIN_VEL_STEP_SIZE) status = status + 1 print(vels(target_linear_vel,target_angular_vel)) elif key == 'x' : target_linear_vel = checkLinearLimitVelocity(target_linear_vel - LIN_VEL_STEP_SIZE) status = status + 1 print(vels(target_linear_vel,target_angular_vel)) elif key == 'a' : target_angular_vel = checkAngularLimitVelocity(target_angular_vel + ANG_VEL_STEP_SIZE) status = status + 1 print(vels(target_linear_vel,target_angular_vel)) elif key == 'd' : target_angular_vel = checkAngularLimitVelocity(target_angular_vel - ANG_VEL_STEP_SIZE) status = status + 1 print(vels(target_linear_vel,target_angular_vel)) elif key == ' ' or key == 's' : target_linear_vel = 0.0 control_linear_vel = 0.0 target_angular_vel = 0.0 control_angular_vel = 0.0 print(vels(target_linear_vel, target_angular_vel)) else: if (key == '\x03'): break if status == 20 : print(msg) status = 0 twist = Twist() control_linear_vel = makeSimpleProfile(control_linear_vel, target_linear_vel, (LIN_VEL_STEP_SIZE/2.0)) twist.linear.x = control_linear_vel; twist.linear.y = 0.0; twist.linear.z = 0.0 control_angular_vel = makeSimpleProfile(control_angular_vel, target_angular_vel, (ANG_VEL_STEP_SIZE/2.0)) twist.angular.x = 0.0; twist.angular.y = 0.0; twist.angular.z = control_angular_vel pub.publish(twist) except: print(e) finally: twist = Twist() twist.linear.x = 0.0; twist.linear.y = 0.0; twist.linear.z = 0.0 twist.angular.x = 0.0; twist.angular.y = 0.0; twist.angular.z = 0.0 pub.publish(twist) if os.name != 'nt': termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)運行腳本就可以控制船運動了:python teletop.py生成螺旋線控制水下機器人運動執行命令啟動pid控制和環境:roslaunch uuv_gazebo start_pid_demo_with_teleop.launch生成螺旋線并巡線(這里我生成的是2股螺旋線):roslaunch uuv_control_utils start_helical_trajectory.launch uuv_name:=rexrov n_turns:=2

發布一組導航點導航執行命令啟動pid控制和環境:roslaunch uuv_gazebo start_pid_demo_with_teleop.launch執行命令生成直線路徑:roslaunch uuv_control_utils send_waypoints_file.launch uuv_name:=rexrov interpolator:=linear

機器人路徑根據貝塞爾曲線原理生成,可以保證軌跡上的點速度方向是連續的,并且規定路徑點生成的整條路徑是必過路徑點的。

小編這里寫了個二維三階貝賽爾曲線的路徑生成的代碼:https://github.com/xmy0916/bezier大家可以參考參考!

執行命令生成三維貝賽爾曲線路徑:

roslaunch uuv_control_utils send_waypoints_file.launch uuv_name:=rexrov interpolator:=cubic更多操作參考:項目官方文檔??https://uuvsimulator.github.io/packages/uuv_simulator/intro/項目github地址https://github.com/uuvsimulator/

古月居原創作者簽約計劃已開啟,網站(guyuehome.com)已上線【投稿】功能,歡迎大家積極投稿,原創優質文章作者將有機會成為古月居簽約作者。

總結

以上是生活随笔為你收集整理的安装gazebo_手把手教你用Gazebo仿真UUV水下机器人的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。