草莓干 发表于 2020-12-14 11:32:16

利用 Roboschool 和Gym控制 Atlas 机器人

本帖最后由 草莓干 于 2020-12-14 11:32 编辑 <br /><br /><p style="text-align: center;"><br/></p><section style="padding: 15px 20px; color: rgb(102, 102, 102); border-radius:6px;margin-top:20px 0;border: 1px solid #7880c8;"><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0);"><strong><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 16px;">背景介绍</span></strong></span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">Atlas: Atlas机器人是一个双足人形机器人,由鼎鼎大名的美国波士顿动力公司为主开发,身高1.75米,体重82kg,它的出现将人形机器人的发展带到了更高的高度。目前可以完成行走、跑步和翻跟头等一系列复杂的动作。作为机器人当中的贵族,价格自然不菲 T_T (更何况还买不到...)。所以只能通过仿真软件在里面过下干瘾。</span></p><p style="text-align: center;"></p><p style="line-height: 1.75em;"><strong><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">Roboschool: </span></strong><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">Roboschool是基于OpenAI Gym 强化学习仿真包的物理仿真引擎。由于MuJuCo不开源且收费,所以OpenAI 的大佬们将Roboschool作为MuJuCo的替代品。可以在一个场景当中训练多个Agent并且完成一挑战任务。</span></p></section><p style="text-align: center;"><br/></p><section style="padding: 15px 20px; color: rgb(102, 102, 102); border-radius:6px;margin-top:20px 0;border: 1px solid #7880c8;"><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0);"><strong><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 16px;">软件环境安装</span></strong></span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">Roboschool①</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">Gym②</span></p><p><br/></p><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0);"><strong><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 16px;">示例代码</span></strong></span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">在2017年7月17号,Roboschool发布了Version 1.1版本,其中导入了Atlas机器人模型,相关新闻可见NEWS③。</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">在安装好Roboschool环境后,从RoboschoolAtlasForwardWalk_v1_2017jul.py④</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">中找到控制 Atlas 前进走路的源码。</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">RoboschoolAtlasForwardWalk_v1_2017jul.py④</span></p></section><p style="text-align: center;"><br/></p><section style="padding: 15px 20px; color: rgb(102, 102, 102); border-radius:6px;margin-top:20px 0;border: 1px solid #7880c8;"><p><span style="color: rgb(0, 0, 0);"><strong><span style="font-family: 微软雅黑, Microsoft YaHei;">仿真</span></strong></span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px; color: rgb(0, 0, 0);">Python 运行代码,由于在 Train 的时候,没有对机器人上肢运动进行约束和优化,只关注了下肢的移动,最终训练的结果有点辣眼睛,我们可以看到一段魔性嚣张的步伐。</span></p><p class="active brush" style="color: rgb(121, 121, 121); font-size: 14px; min-width: 1px; text-align: center;"></p><p class="active brush" style="color:rgb(121,121,121);font-size:14px;min-width:1px;"><br/></p><p class="active brush" style="color:rgb(121,121,121);font-size:14px;min-width:1px;">https://v.qq.com/txp/iframe/player.html?vid=r0840q1mbir <br/></p><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">摩擦摩擦,似魔鬼的步伐</span></p><p><br/></p><ul class=" list-paddingleft-2" style="list-style-type: disc;"><li><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">鼠标左键:旋转镜头</span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">鼠标右键:镜头平移</span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">按键F1: 开/关 慢动作</span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">按键F2: 隐藏/显示仿真步数和累积Rewards</span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">按键F3: 隐藏/显示Action和Observation</span></p></li></ul><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);"><br/></span></p><p style="line-height: 1.75em;"><span style="font-size: 14px; font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0);">在&nbsp; 机器人强化学习之使用 OpenAI Gym 教程与笔记⑤中介绍过使用导入 Gym模型和查看Observation和Action的相关参数,对于 Atlas也同样适用:</span></p><p style="text-align: center;"></p><p><br/></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;">输出</span></p><p style="text-align: center;"></p><p><br/></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;">从env.action_space和env.observation_space可知Action维度 为30,Observation维度为70。</span></p><ul class=" list-paddingleft-2" style="list-style-type: disc;"><li><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;">Action可以理解为机器人有30个自由度,可以通过PD控制器控制关节角度;</span></p></li><li><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;">Observation为当前环境的观测向量;</span></p></li></ul><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;">至于Atlas 机器人Action和Observation详细解释,在Roboschool的Wiki中没有相关说明, OpenAI的开发者建议用户靠猜的方式来确定,大佬就是大佬,懒得跟你解释 。。。</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;"></span></p><section style="margin: 5px auto;" class="layout"><section style="height:1em;"><section style="height: 100%; width: 1.5em; float: left; border-top-width: 0.15em; border-top-style: solid; border-color: rgb(198, 198, 199); border-left-width: 0.15em; border-left-style: solid;"></section><section style="height: 100%; width: 1.5em; float: right; border-top-width: 0.15em; border-top-style: solid; border-color: rgb(198, 198, 199); border-right-width: 0.15em; border-right-style: solid;"></section></section><section style="margin: -0.9em 0.1em; padding: 0.8em; box-sizing: border-box; color: rgb(131, 87, 87); background-color: rgb(247, 247, 248);" data-bgless="lighten" data-bglessp="15%"><section class="135brush" style="color: rgb(51, 51, 51); font-size: 1em; line-height: 1.4; word-break: break-all; word-wrap: break-word; text-align: left;"><p style="line-height: 1.75em;"><strong><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">具体的土方法:</span></strong></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">1. 修改Roboschool源码,将gym_atlas.py⑥重力Gravity修改为 0。</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">2. 按照排除法,控制变量Action,然后env.step(action),分别记下向量每个元素对应的自由度关节。</span></p></section></section><section style="height: 1em; box-sizing: border-box;"><section style="height: 100%; width: 1.5em; float: left; border-bottom-width: 0.15em; border-bottom-style: solid; border-color: rgb(198, 198, 199); border-left-width: 0.15em; border-left-style: solid; box-sizing: border-box;"></section><section style="height: 100%; width: 1.5em; float: right; border-bottom-width: 0.15em; border-bottom-style: solid; border-color: rgb(198, 198, 199); border-right-width: 0.15em; border-right-style: solid; box-sizing: border-box;"></section></section></section><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;"></span><br/><span style="font-family: 微软雅黑, Microsoft YaHei; color: rgb(0, 0, 0); font-size: 14px;"></span></p></section><p><br/></p><section style="padding: 15px 20px; color: rgb(102, 102, 102); border-radius:6px;margin-top:20px 0;border: 1px solid #7880c8;"><p style="line-height: 1.75em;"><strong><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 16px;">代码说明</span></strong><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;"><br/></span></p><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">Roboschool 开发者解释到由于强化学习训练 Atlas 走路的代码太杂乱了,所以暂时没有 Train 的代码,所以求人不如求己,后面得自己撸代码~ 总体思路是获得weight矩阵,即最佳Policy,输入当前观测向量Observation 获得下一步的Action向量来控制Atlas行走。</span></p><p><br/></p><p style="line-height: 1.75em;"><strong><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 16px;">总结</span></strong></p><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">1. Roboschool这个项目适合验证一些简单的强化学习任务,对于新引入的模型支持得还不太友好。</span></p><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">2. 基本上没有什么成体系的说明文档,所以需要靠多阅读Roboschool和Gym的Python源码来使用。</span></p><p style="line-height: 1.75em;"><span style="color: rgb(0, 0, 0); font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">3. 如果有什么问题,欢迎评论留言交流~</span></p></section><p><br/></p><p><br/></p><p style="line-height: 1.75em;"><strong><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">文中标记网址:</span></strong></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">①https://github.com/openai/roboschool</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">②https://github.com/openai/gym</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">③https://github.com/openai/roboschool#news</span><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">&nbsp;</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">④https://github.com/openai/roboschool/blob/master/agent_zoo/RoboschoolAtlasForwardWal</span><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">k_v1_2017jul.py</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">⑤https://zhuanlan.zhihu.com/p/40673328</span></p><p style="line-height: 1.75em;"><span style="font-family: 微软雅黑, Microsoft YaHei; font-size: 14px;">⑥https://github.com/openai/roboschool/blob/master/roboschool/gym_atlas.py#L21</span></p><p><br/></p><p><br/></p><link rel="stylesheet" href="//bbs.lejurobot.com/source/plugin/wcn_editor/public/wcn_editor_fit.css?v134_kKx" id="wcn_editor_css"/>
页: [1]
查看完整版本: 利用 Roboschool 和Gym控制 Atlas 机器人