官网流程安装:
https://github.com/erlerobot/gym-gazebo
一、环境与依赖
- 基本环境:
- ROS Melodic: Desktop-Full Install recommended, includes Gazebo 9.0.0 (http://wiki.ros.org/melodic/Installation/Ubuntu).
- Gazebo 9.0.0
- ROS相关依赖:
sudo apt-get install \
python-pip python3-vcstool python3-pyqt4 \
pyqt5-dev-tools \
libbluetooth-dev libspnav-dev \
pyqt4-dev-tools libcwiid-dev \
cmake gcc g++ qt4-qmake libqt4-dev \
libusb-dev libftdi-dev \
python3-defusedxml python3-vcstool \
ros-melodic-octomap-msgs \
ros-melodic-joy \
ros-melodic-geodesy \
ros-melodic-octomap-ros \
ros-melodic-control-toolbox \
ros-melodic-pluginlib \
ros-melodic-trajectory-msgs \
ros-melodic-control-msgs \
ros-melodic-std-srvs \
ros-melodic-nodelet \
ros-melodic-urdf \
ros-melodic-rviz \
ros-melodic-kdl-conversions \
ros-melodic-eigen-conversions \
ros-melodic-tf2-sensor-msgs \
ros-melodic-pcl-ros \
ros-melodic-navigation \
ros-melodic-sophus
- python相关依赖
sudo pip install gym
sudo apt-get install python-skimage
sudo pip install h5py
pip install tensorflow-gpu (if you have a gpu if not then just pip install tensorflow)
sudo pip install keras
二、安装
- 安装gym-gazebo
cd ~
git clone https://github.com/erlerobot/gym-gazebo
cd gym-gazebo
sudo pip install -e .
- 建立ros工作空间
cd gym-gazebo/gym_gazebo/envs/installation
bash setup_melodic.bash
三、测试
终端1
cd gym-gazebo/gym_gazebo/envs/installation/
bash turtlebot_setup.bash
终端2
cd gym-gazebo/examples/turtlebot
python circuit_turtlebot_lidar_qlearn.py
目前运行情况
- 由于自己有在用PX4,一开始直接按照官网的教程进行了bash, 但gym-gazebo的相关内容在bashrc中都在PX4的下面,在运行.py的时候似乎造成了一些影响;建议把PX4相关的内容一直放在bashrc的最下方。
- 官网代码给出了多体共同运行的方法,如果只需要运行单个,则需要把以下代码注释掉:
os.environ["ROS_MASTER_URI"] = "http://localhost:"+self.port
os.environ["GAZEBO_MASTER_URI"] = "http://localhost:"+self.port_gazebo
#print("ROS_MASTER_URI=http://localhost:"+self.port + "\n")
#print("GAZEBO_MASTER_URI=http://localhost:"+self.port_gazebo + "\n")
先开:
roscore
再运行:
cd gym-gazebo/gym-gazebo/examples/turtlebot/
python circuit_turtlebot_lidar_qlearn.py
另外开一个终端,运行:
gzclient
可以得到:
但此时终端有报错:
并且没有打印出 RL 相关的参数和图;
- 当不对多体的四行进行注释的时候:
先开终端运行:
gzclient
再开终端运行:
cd gym-gazebo/gym-gazebo/examples/turtlebot/
python circuit_turtlebot_lidar_qlearn.py
此时打印处理RL相关参数和图,但gzclient开启之后过会就自动关闭了,没有开启gazebo
有进展再更新