Ubuntu搭建 TORCS无人驾驶训练 开发环境

环境:ubuntu 16.04。
提前安装好python环境,我用的是python3,keras=2.0.0,tensorflow/tensorflow-gpu=1.15.0

Gym-TORCS是一个模仿Open-AI接口的TORCS的python封装,用于在TORCS上测试增强学习算法。
一、安装xautomation:
sudo apt-get install xautomation
二、安装OpenAI-Gym:https://github.com/openai/gym
Step1:将gym克隆到计算机上:
git clone https://github.com/openai/gym.git
如果你的电脑没有安装git和make,那么键入
sudo apt install git
sudo apt install make

Step2:安装一些依赖项
apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
**注意:**上述这些依赖要一个一个来安装,不然,可能会出现错误。
三、安装Gym-TORCS:https://github.com/ugo-nama-kun/gym_torcs
git clone https://github.com/ugo-nama-kun/gym_torcs.git
先要安装gym_torcs目录下的vtorcs-RL-color,進入到vtorcs-RL-color下打開命令窗口:
cd gym_torcs
cd vtorcs-RL-color
sudo apt-get install libglib2.0-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libplib-dev libopenal-dev libalut-dev libxi-dev libxmu-dev libxrender-dev libxrandr-dev libpng12-dev
**注意:**上述这些依赖要一个一个来安装,不然,可能会出现错误。

./configure
make
sudo make install
sudo make datainstall
然后即可开始运行了:
sudo torcs
点击Race --> Practice --> Configure Race配置参数,点击Race --> Practice --> New Race启动服务器。
另开命令窗口:
cd ~/gym_torcs

python snakeoil3_gym.py开始自动跑车,按F2切换到第一人称视角。画面中右下方有个十字,表示右转左转油门刹车。
備注:How to display the car in the video screen
鏈接:https://github.com/ugo-nama-kun/gym_torcs/issues/7
you can recover the car body by modifying 280th line of grscreen.cpp
修改的地方如下:
for (i = 0; i < s->_ncars; i++) {
grDrawCar(cars[i], curCar, dispCam->getDrawCurrent(), dispCam->getDrawDriver(), s->currentTime, dispCam);
}
也就是把上述中的i=1更改为i=0如下:
You should modify i =1 to i = 0. After the compile, you will be able to see the car body.
i=0 represent the first car, that is the agent. And other numbers are opponent cars.
另外一个需要修改的地方是:
For car mirrors, you should uncomment 361-366 lines in grscreen.cpp
修改的内容:
/* MIRROR */

if (mirrorFlag && curCam->isMirrorAllowed ()) {
mirrorCam->display ();
glViewport (scrx, scry, scrw, scrh);
}
关于另外一个文件的修改地方如下:
To show the map, tachometers etc. I remember that we should uncomment appropriate methods in 841-845 lines of cGrBoard::refreshBoard in grboard.cpp.
也就是把841-845行中的注释的部分if语句去掉即可,如下
void cGrBoard::refreshBoard(tSituation *s, float Fps, int forceArcade, tCarElt *curr)
{
if (arcadeFlag || forceArcade) {
grDispArcade(curr, s);
} else {
if (debugFlag) grDispDebug(Fps, curr);
if (GFlag) grDispGGraph(curr);
if (boardFlag) grDispCarBoard(curr, s);
if (leaderFlag) grDispLeaderBoard(curr, s);
if (counterFlag) grDispCounterBoard2(curr);
}
上述全部修改完成后,需要make,才能生效,不然一样看不到车
cd gym_torcs
cd vtorcs-RL-color
make
sudo make install
sudo make datainstall
这样就会出现汽车了。
上述可以参考链接:
https://blog.csdn.net/tianciyiye/article/details/83899510

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值