在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示

智能车无人驾驶技术是目前人工智能和机器人技术的研究热点,有许多开源平台可以使我们零基础零成本入门无人驾驶技术。本文分享一下目前ROS官网最新推荐的一款开源汽车仿真模拟。使用的平台为Ubuntu 16.04 + ROS Kinetic + Gazebo 8。同时需要具备Docker和nvidia-docker的基础。

Gazebo:

在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示_ROS

RVIZ:

在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示_docker_02

1. Docker安装

请参考https://www.docker.com官网和CSDN相关博客。

2. nvidia-docker安装

请参考文末附录。如果出现如下错误,请按附录内容进行修正:

$ nvidia-docker run -ti --rm nvidia/cuda
nvidia-docker | 2017/07/06 13:13:17 Error: unsupported CUDA version: driver 6.5 < image 8.0.61


3. 配置和使用ROS/Gazebo中的Prius示例

$ ./build_demo.bash

----

relaybot@relaybot-desktop:~/Rob_Soft/car_demo-master$ ./build_demo.bash
[sudo] password for relaybot: 
Sending build context to Docker daemon  58.96MB
Step 1/12 : FROM osrf/ros:kinetic-desktop
 ---> fe1c52012515
Step 2/12 : LABEL com.nvidia.volumes.needed "nvidia_driver"
 ---> Using cache
 ---> c0a552983f0f
Step 3/12 : ENV PATH /usr/local/nvidia/bin:${PATH}
 ---> Using cache
 ---> b4336a6fcd17
Step 4/12 : ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
 ---> Using cache
 ---> d9f0873b5c72
Step 5/12 : RUN apt-get update  && apt-get install -y     wget     lsb-release     sudo     mesa-utils  && apt-get clean
 ---> Using cache
 ---> d1d2e996eae1
Step 6/12 : RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list  && wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add -  && apt-get update  && apt-get install -y     gazebo8     ros-kinetic-gazebo8-ros-pkgs     ros-kinetic-fake-localization     ros-kinetic-joy  && apt-get clean
 ---> Using cache
 ---> 62e82befdf92
Step 7/12 : RUN mkdir -p /tmp/workspace/src
 ---> Using cache
 ---> 3344777de771
Step 8/12 : COPY prius_description /tmp/workspace/src/prius_description
 ---> Using cache
 ---> d6c8c42918c2
Step 9/12 : COPY prius_msgs /tmp/workspace/src/prius_msgs
 ---> Using cache
 ---> ce2281718303
Step 10/12 : COPY car_demo /tmp/workspace/src/car_demo
 ---> Using cache
 ---> ca825da11474
Step 11/12 : RUN /bin/bash -c 'cd /tmp/workspace  && source /opt/ros/kinetic/setup.bash  && catkin_make'
 ---> Using cache
 ---> a78d42ed877a
Step 12/12 : CMD /bin/bash -c source /opt/ros/kinetic/setup.bash && source /tmp/workspace/devel/setup.bash && roslaunch car_demo demo.launch
 ---> Using cache
 ---> 20890ac15cee
Successfully built 20890ac15cee
Successfully tagged osrf/car_demo:latest
relaybot@relaybot-desktop:~/Rob_Soft/car_demo-master$ 


----

$ ./run_demo.bash

$ ./run_demo.bash 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
... logging to /root/.ros/log/31d9adfa-620b-11e7-a113-0242ac110002/roslaunch-a0950e425e8e-82.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://a0950e425e8e:37129/

SUMMARY
========

PARAMETERS
 * /joy_node0/dev: /dev/input/js0
 * /joy_node1/dev: /dev/input/js1
 * /robot_description: <?xml version="1....
 * /rosdistro: kinetic
 * /rosversion: 1.12.7
 * /use_sim_time: True

NODES
  /
    fake_localization (fake_localization/fake_localization)
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)
    joy_node0 (joy/joy_node)
    joy_node1 (joy/joy_node)
    joystick_translator (car_demo/joystick_translator)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    rviz (rviz/rviz)
    spawn_urdf (gazebo_ros/spawn_model)
    very_inaccurate_odom (tf2_ros/static_transform_publisher)

auto-starting new master
process[master]: started with pid [93]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 31d9adfa-620b-11e7-a113-0242ac110002
process[rosout-1]: started with pid [106]
started core service [/rosout]
process[gazebo-2]: started with pid [109]
process[gazebo_gui-3]: started with pid [113]
process[robot_state_publisher-4]: started with pid [142]
process[fake_localization-5]: started with pid [195]
process[very_inaccurate_odom-6]: started with pid [196]
process[joystick_translator-7]: started with pid [255]
process[joy_node0-8]: started with pid [299]
process[joy_node1-9]: started with pid [300]
Gazebo multi-robot simulator, version 8.1.1
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

process[spawn_urdf-10]: started with pid [328]
process[rviz-11]: started with pid [356]
[ INFO] [1499318590.218434440]: Finished loading Gazebo ROS API Plugin.
[Msg] Waiting for master.
[ INFO] [1499318590.220829714]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 172.17.0.2
[Wrn] [ColladaLoader.cc:1804] Triangle input semantic: 'TEXCOORD' is currently not supported
[Wrn] [ColladaLoader.cc:1804] Triangle input semantic: 'TEXCOORD' is currently not supported
[Wrn] [ColladaLoader.cc:1804] Triangle input semantic: 'TEXCOORD' is currently not supported
[Wrn] [ColladaLoader.cc:1804] Triangle input semantic: 'TEXCOORD' is currently not supported
[Wrn] [ColladaLoader.cc:1804] Triangle input semantic: 'TEXCOORD' is currently not supported
[spawn_urdf-10] process has finished cleanly
log file: /root/.ros/log/31d9adfa-620b-11e7-a113-0242ac110002/spawn_urdf-10*.log
[ INFO] [1499318597.020363774, 1341.708000000]: Camera Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1499318597.029090560, 1341.708000000]: Camera Plugin (ns = /)  <tf_prefix_>, set to ""
[ WARN] [1499318597.051198614, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318597.051501949, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318597.051634287, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318597.051772773, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ WARN] [1499318597.071652157, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318597.071737149, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318597.071765174, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318597.071788477, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ WARN] [1499318597.074830942, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318597.075126204, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318597.075418562, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318597.075720639, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ WARN] [1499318597.089499716, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318597.090064739, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318597.090382446, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318597.090626321, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ INFO] [1499318603.934692266, 1341.708000000]: Block laser plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318603.934773061, 1341.708000000]: Block laser plugin missing <hokuyoMinIntensity>, defaults to 101
[ INFO] [1499318603.934847668, 1341.708000000]: Block laser plugin missing <updateRate>, defaults to 0
[ INFO] [1499318604.031684097, 1341.708000000]: Camera Plugin: Using the 'robotNamespace' param: '/'
[ WARN] [1499318604.036142916, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318604.036419387, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318604.036500172, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318604.036576326, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ INFO] [1499318604.048912318, 1341.708000000]: Camera Plugin (ns = /)  <tf_prefix_>, set to ""
[ INFO] [1499318604.601344650, 1341.708000000]: Laser Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1499318604.602166296, 1341.708000000]: Starting Laser Plugin (ns = /)!
[ INFO] [1499318604.609125255, 1341.708000000]: Laser Plugin (ns = /)  <tf_prefix_>, set to ""
[ WARN] [1499318604.622696602, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318604.622786468, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318604.622838959, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318604.622875155, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ WARN] [1499318604.675410176, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318604.675486412, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318604.675527058, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318604.675556004, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ INFO] [1499318605.145527632, 1341.708000000]: Laser Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1499318605.145614241, 1341.708000000]: Starting Laser Plugin (ns = /)!
[ INFO] [1499318605.154089749, 1341.708000000]: Laser Plugin (ns = /)  <tf_prefix_>, set to ""
[ WARN] [1499318605.158758063, 1341.708000000]: Range plugin missing <radiation>, defaults to ultrasound
[ WARN] [1499318605.158840499, 1341.708000000]: Range plugin missing <fov>, defaults to 0.05
[ INFO] [1499318605.158877742, 1341.708000000]: Range plugin missing <gaussianNoise>, defaults to 0.0
[ INFO] [1499318605.158909882, 1341.708000000]: Range plugin missing <updateRate>, defaults to 0
[ INFO] [1499318605.244331364, 1341.708000000]: Camera Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1499318605.260901986, 1341.708000000]: Camera Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1499318605.268178012, 1341.708000000]: Camera Plugin (ns = /)  <tf_prefix_>, set to ""
[ INFO] [1499318605.295667008, 1341.708000000]: Camera Plugin (ns = /)  <tf_prefix_>, set to ""
[Wrn] [PriusHybridPlugin.cc:361] PriusHybridPlugin loading params
[ INFO] [1499318605.487444516, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: rear_right_wheel_joint
[ INFO] [1499318605.487560947, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: rear_left_wheel_joint
[ INFO] [1499318605.487821573, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: front_right_wheel_joint
[ INFO] [1499318605.487860817, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: front_left_wheel_joint
[ INFO] [1499318605.487897223, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: front_right_steer_joint
[ INFO] [1499318605.487938402, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: front_left_steer_joint
[ INFO] [1499318605.487983362, 1341.708000000]: GazeboRosJointStatePublisher is going to publish joint: steering_joint
[ INFO] [1499318605.488209156, 1341.708000000]: Starting GazeboRosJointStatePublisher Plugin (ns = //)!, parent name: prius
[ INFO] [1499318605.694392977, 1341.729000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1499318605.875331513, 1341.751000000]: Physics dynamic reconfigure ready.
[Wrn] [Publisher.cc:141] Queue limit reached for topic /gazebo/default/pose/local/info, deleting message. This warning is printed only once.



----

在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示_Docker_03

在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示_Docker_04


----详细过程如下----

ROS / GAZEBO中的Prius演示

这是使用ROS kinetic发布的传感器数据的 gazebo 8中的Prius的模拟。 通过发布ROS消息来控制汽车的节气门,制动器,转向和换档。ROS节点允许使用游戏手柄或操纵杆进行驾驶。

要求(基本)

该演示已经在Ubuntu Xenial(16.04)

推荐(选配)
  • 一个操纵杆
  • 创建到/dev/input/js0或的链接的操纵杆驱动程序/dev/input/js1
编译

首先克隆repo,然后运行脚本build_demo.bash它使用本地源代码构建了一个docker映像。

$ cd car_demo
$ ./build_demo.bash
运行

将游戏控制器连接到您的电脑。使用脚本run_demo.bash运行演示。

$ ./run_demo.bash

一个RVIZ窗口将打开,显示汽车和传感器输出。将出现一个Gazebo窗口,显示模拟。使用控制器驱动世界各地的prius,或者点击Gazebo窗口并使用WASD钥匙来驾驶汽车。

如果使用Logitech F710控制器:

  • 确保MODE状态指示灯熄灭
  • 将swtich设置为XInput模式
  • 右侧杆控制油门和制动器
  • 左键控制转向
  • Y把车放进DRIVE
  • A把车放进REVERSE
  • B把车放到中性

----


先看效果:

Gazebo:

參考網址:

1.  http://www.ros.org/news/2017/06/simulated-car-demo.html

2.  https://github.com/NVIDIA/nvidia-docker


----

智能汽车仿真演示 Tully Foote20176月30日上午10:30编辑

更多文章请关注《万象专栏》