gazebo安装_⼿把⼿教你⽤Gazebo仿真UUV⽔下机器⼈
前⾔
仿真环境
系统: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 如果希望从源码安装的朋友参考这⾥:
这⾥不推荐源码安装,因为看了下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.launch
roslaunch uuv_gazebo_worlds munkholmen.launch
roslaunch uuv_gazebo_worlds ocean_waves.launch
!注意这⾥的海浪都只是视觉效果不会将波浪的载荷加载在⽔下机器⼈上
⽔下机器⼈运动控制
启动环境和⽔下机器⼈pid控制
执⾏命令:
roslaunch uuv_gazebo start_pid_demo_with_teleop.launch
这⾥机器⼈的速度控制还是经典的cmd_vel话题,我们可以⾃⼰创建速度控制脚本teletop.py:
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
import sys, select, os
if os.name == 'nt':
import msvcrt
else:
import tty, termios
FETCH_MAX_LIN_VEL = 5
FETCH_MAX_ANG_VEL = 2.84
LIN_VEL_STEP_SIZE = 0.01
ANG_VEL_STEP_SIZE = 0.1
msg = """
Control Your Robot!
---------------------------
Moving around:
w
a s d
x
"""
e = """
Communications Failed
"""
"""
def getKey():
if os.name == 'nt':
h()
tty.setraw(sys.stdin.fileno())
rlist, _, _ = select.select([sys.stdin], [], [], 0.1)
if rlist:
key = ad(1)
else:
key = ''
return key
def 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 output
def constrain(input, low, high):
if input < low:
input = low
elif input > high:
angular安装
input = high
else:
input = input
return input
def checkLinearLimitVelocity(vel):
vel = constrain(vel, -FETCH_MAX_LIN_VEL, FETCH_MAX_LIN_VEL)
return vel
def checkAngularLimitVelocity(vel):
vel = constrain(vel, -FETCH_MAX_ANG_VEL, FETCH_MAX_ANG_VEL)
return vel
if __name__=="__main__":
if os.name != 'nt':
settings = attr(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
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论