淘优惠

淘优惠

ROS、OpenAI和Gazebo机器人与人工智能仿真与实践教研杂记(三)深度学习

热门文章 0
ros 人工智能,ros机器人编程与slam算法解析指南pdf,ros机器人项目开发11例,ros机器人建模和仿真

机器人在环境中如何自主行驶呢?不同的机器人需要配置不同参数,差速或者其他动力学模型,如何获得更好的环境参数?

关于ROS、OpenAI和Gazebo已经测试过环境包括:

  • Ubuntu 16.04 + ROS 1 Kinetic + OpenAI + Gazebo 7
  • Ubuntu 18.04 + ROS 1 Melodic + OpenAI +Gazebo 9

了解OpenAI是什么?参考链接如下:

游戏场景,OpenAI已经“独孤求败”。那么相关算法如何应用于机器人操作系统ROS中呢?

Gazebo、Webots、V-Rep等仿真场景可以直接用OpenAI训练完成指定任务,现实机器人同样可以!

ROS官网参考教程:

可以详细查阅。

之前,举过一个栗子,倒立摆,思考如下机器人,以turtlebot2为例吧:

100次训练

200次训练

机器人在环境中运动,依据运动情况进行训练,多次训练后(800次)如下:

分析规律,思考将其应用于mit-racecar:

使其自动行驶,并得到在此配置参数下速度的最大值?或求得单圈最小时间?

官方案例源码turtlebot2(Python):详细资料查看对应网址

官方案例源码erlerover(Python):详细资料查看对应网址

引用网址:?

部分机器翻译参考资料如下:

OpenAI提供了一套完整的强化学习库,可以对任务中的软件代理进行训练,因此代理可以自己学习如何最好地完成任务。主要类型的代理是软件代理,例如OpenAI团队训练智能体玩Dota 2的示例。

OpenAI集合库中最好的工具之一是Gym。Gym允许通过提供称为环境的共同点来比较强化学习算法。

不幸的是,即使Gym允许训练机器人,也不提供使用Gazebo模拟训练基于ROS的机器人的环境。

我们已经创建了openai_ros软件包以提供环境,因此我们所有的ROS机器人都有一个共同点,我们可以在训练机器人时比较我们最好的算法。该软件包是开源的,具有lGPL许可证。

openai_ros包提供了组织需要从零创建你的机器人的训练,需要很少的执行一切共同的结构。它基本上由以下元素组成。

  • 它包含将您的OpenAI程序连接到Gazebo?的GazeboEnvironment类。

  • 它为最流行的基于ROS的机器人提供了一组已经制作的RobotEnvironments。该RobotEnvironments提供机器人的Gazebo模拟和OpenAI算法环境之间的完全整合,因此从机器人传感器获取的信息或发送行动,它是ROS trasnparent到OpenAI算法和你的开发者。

  • 它提供了一组已经取得的TaskEnvironments,你可以与一起使用RobotEnvironmentsGazeboEnvironment在定义的任务训练机器人TaskEnvironment

  • 它提供了一组模板来帮助您创建自己的RobotEnvironmentsTasksEnvironments,它们直接连接到Gazebo(因为它们从GazeboEnvironment继承)

?

一般而言,图的结构可分为两大部分:

*?训练环境:培训环境将负责为您的学习算法提供所有需要的数据,以使机器人学习。他们继承了OpenAI Gym官方环境,因此他们完全兼容并使用Gym的正常训练程序。

有不同类型的训练环境:

  • 任务环境。这是允许指定机器人必须学习的任务的类。

  • 机器人环境。这是指定要在任务上使用的机器人的类。

  • Gazebo环境。这是指定与仿真模拟器连接的类。

通常,您不必触摸这些环境,只需使用提供的环境。在openai_ros包中,我们已经为机器人和任务提供了许多环境,因此您很可能只使用所需的环境并专注于学习算法。

如果您想使用未提供的机器人或不同的任务培训,您只需处理前两个类,以指定任务和/或机器人。该“?GazeboEnvironment”已经通过提供“openai_ros?”,你不必修改。

*?训练脚本:培训脚本将定义和设置您将要使用的学习算法,以便训练您的机器人。这通常是您的主要工作。

The Training Environments

训练环境是openai_ros包提供的Python类。

*?任务环境继承自Robot Environment

*?机器人环境继承自Gazebo环境

*?Gazebo Environment继承自Gym Environment。Gym Environment(gym.Env)是OpenAI提供的最基本的环境结构。

Gazebo环境

The Gazebo Environment

正如我之前所说,Gazebo环境主要用于将模拟环境连接到Gazebo模拟器。例如,它在每个步骤之后处理模拟器重置,或控制器重置(如果需要),它还负责在进行训练步骤或模拟器时需要在模拟器上完成的所有步骤。训练重置(强化学习循环中的典型步骤)。

重要信息:此类是实现OpenAI Gym基础结构所需功能的类:

  • 步进功能step?function

  • 种子功能seed?function

  • 重置功能reset?function

  • 关闭功能close?function

但是,它调用子类函数(在RobotEnvironmentTaskEnvironment类上)来获取观察结果并应用操作。

本课程还会发布关于主题/openai/reward的最后一集奖励

无论如何,您需要了解的有关此环境的最重要的事情是,它对您来说是透明的。这意味着什么?嗯,这基本上意味着你不必担心它。无论机器人或您想要执行的火车类型如何,此环境始终都是相同的。因此,您不必更改它或为它工作。好消息,对吧?

此类是机器人和任务的独立

这个类的代码里面robot_gazebo_env.py中的openai_ros包(如果要修改的话)。

如果您想将此软件包与其他模拟器一起使用,那么您必须修改该类。

机器人环境

The Robot Environment

然后,机器人环境将包含与您要训练的特定机器人相关联的所有功能。这意味着,它将包含机器人控制所需的所有ROS功能

该类还检查所需的每个ROS内容是否已在机器人上启动并运行(主题,服务...)。

openai_ros包中,我们将为所有可用的ROS机器人提供RobotEnvironment,因此用户不必担心它,只需选择机器人并使用适当的RobotEnvironment类。

您只需要关心这个类,以防您想要将该软件包与您自己的机器人一起使用,只有您知道它。

目前可用的机器人环境:

* Cartpole

* Cube robot

* Hopper robot

* ROSbot by H


pytorch深度学习入门4 python3.7支持pytorch1.11吗

动手学深度pytorch

船新UBUNTU 安装openai 从零开始 @TOC

新手上车,装了一个星期,从第一句cd命令开始,真是令人头皮发麻! 咱就从换源开始,一步步安装openai

sudo cp /etc/apt/sources.list sources_backup.list

sudo gedit /etc/apt/sources.list

#清华大学源

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

#阿里云源

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

阿里源(ubuntu18.04)

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

阿里源(ubuntu20.04)

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

阿里镜像站

https://developer.aliyun.com/mirror/ubuntu/?spm=a2c6h.25603864.0.0.47634af3iBaqpg

a.这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。我们在新立得软件包管理器里看到的软件列表,都是通过update命令更新的。

sudo apt-get update

b.解决各种缺少依赖问题

sudo apt-get -f install

c.这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。

sudo apt-get upgrade

1、卸载驱动

sudo apt-get remove nvidia-*

2、查询可用驱动

sudo ubuntu-drivers devices

会出现类似的 (每个版本 因时间推进而可能版本号不同 以自己的为准 driver : nvidia-driver-470 - distro non-free driver : nvidia-driver-460-server - distro non-free recommended driver : xserver-xorg-video-nouveau - distro free builtin 3、选取在上面列表中自己需要的列表中的驱动安装即可 一般不推荐安装test的驱动

sudo apt install nvidia-driver-470

4、检验驱动是否安装成功

sudo nvidia-smi

5、编辑内核

sudo nano /etc/modprobe.d/blacklist.conf

文件末尾加上 blacklist nouveau 然后保存

sudo update-initramfs -u

使改动生效,这句很重要 7、重启

sudo reoot

https://blog.csdn.net/sandalphon4869/article/details/100781978 https://jingyan.baidu.com/article/fec4bce28610c4f2618d8b13.html

(ubuntu18.04) https://blog.csdn.net/qq_27211927/article/details/80877684 IBus与fcitx切换的时候记得要重启

/opt/v2ray/v2ray-linux-64/v2ray /opt/v2ray/v2ray-linux-64

bash xxxxx

这个是openai官方的教程页面

官方历史版本,找到Anaconda3-5.3.0-Linux-x86_64.sh 官方教程用的是5.3.0,跟着官方推荐一步一步装准没错!

https://repo.anaconda.com/archive/

下载完成,打开终端,进行安装

bash ~/Downloads/Anaconda3-5.3.0-Linux-x86_64.sh

安装完成后需要关闭终端再次打开,Anaconda才能生效

创建一个spinningup的环境(这个名字可以随便改) 使用python3.6

conda create -n spinningup python=3.6

在之前创建好的环境中继续安装 接下来的环境依赖包

conda activate spinningup

sudo apt-get update && sudo apt-get install libopenmpi-dev

sudo apt install git

从github把Spinning Up载到本地

git clone https://github.com/openai/spinningup.git

移动到spinningup文件夹

cd spinningup

执行安装

pip install -e .

下载到99%后突然崩了

https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/tensorflow/

解决方案:

1.下载好需要的pytorch版本 pytorch各个版本的.whl文件下载地址

https://download.pytorch.org/whl/torch_stable.html

ub20 pureboost


conda介绍 conda是一个为Python而设的开源包管理系统和环境管理系统,用于安装Python及相应的包。可以这样理解:conda可以用来创建多个虚拟环境,每个环境都是相互独立不影响的,只是每个环境中包的数量和版本不同,这样就能很好的解决不同python包的兼容性问题,在不同项目中创建不同的环境,避免单一环境在不同项目中存在可能的包冲突。 安装教程 到官网:Anaconda下载官网 下载 会得到一个Anaconda3-xxxxx86_64.sh 可执行文件,只需在打开终端并通过sh命令运行该可执行文