强化学习实现四旋翼无人机的路径选择(Gym+Gym-Gazebo+Gazebo+Ros)

1、Gym+Gym-Gazebo+Gazebo+Ros的安装

2、环境配置:

      创建Ros工作空间,并且source devel/setup.bash

3、 编写launch文件,并将launch文件放在.../gym_gazebo/assets/目录下

<launch>
   <arg name="world_file"  default="$(find aircraft_start)/worlds/aircraft_wall.world"/>
   <include file="$(find gazebo_ros)/launch/empty_world.launch">
      <arg name="use_sim_time" value="true"/>
      <arg name="paused" value="true"/>
      <arg name="gui" value="true"/>
      <arg name="world_name" value="$(arg world_file)"/>
      <arg name="debug" value="false"/>
  </include>
  <group ns="aircraft_1">
    <arg name="model" value="$(find hector_quadrotor_description)/urdf/quadrotor_with_cam1.gazebo.xacro"/>
    <include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch">
      <arg name="name" value="aircraft_1" />
      <arg name="tf_prefix" value="aircraft_1" />
      <arg name="model" value="$(arg model)" />
      <arg name="x" value="-2.5" />
      <arg name="y" value="-2.5" />
      <arg name="z" value ="1.5" />  
    </include>
  </group>
   <node name = "aircraft_up" pkg = "aircraft_start" type="aircraft_up" output="screen"/>
</launch>

4、编写aircraft_wall(在env目录下面自建)功能包里面的__init__.py 和aircraft_wall_env.py

#aircraft_wall_env.py文件
#!/usr/bin/env python
import gym
from gym import wrappers
#from gym import wrappers
import gym_gazebo
import time
import numpy
import random
import time

import qlearn
import liveplot

def render():
    render_skip = 0 #Skip first X episodes.
    render_interval = 50 #Show render Every Y episodes.
    render_episodes = 10 #Show Z episodes every rendering.

    if (x%render_interval == 0) and (x != 0) and (x > render_skip):
        env.render()
    elif ((x-render_episodes)%render_interval == 0) and (x != 0) and (x > render_skip) and (render_episo
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值