From dc0c898a5b03c52421f090f9f38759ffdf4c93e7 Mon Sep 17 00:00:00 2001 From: storypku Date: Sun, 6 Sep 2020 18:14:28 +0800 Subject: [PATCH] Docs|Scripts: improved record downloader renamed from rosbag_helper.py --- docs/demo_guide/README.md | 58 +++++++------ docs/demo_guide/README_cn.md | 84 +++++++++++-------- docs/demo_guide/record_helper.py | 79 +++++++++++++++++ docs/demo_guide/rosbag_helper.py | 66 --------------- docs/howto/how_to_launch_Apollo.md | 2 +- .../Apollo_Installation_cn.md | 4 +- 6 files changed, 160 insertions(+), 133 deletions(-) create mode 100755 docs/demo_guide/record_helper.py delete mode 100755 docs/demo_guide/rosbag_helper.py diff --git a/docs/demo_guide/README.md b/docs/demo_guide/README.md index a603aa6afe..90ff6ddcb3 100644 --- a/docs/demo_guide/README.md +++ b/docs/demo_guide/README.md @@ -14,48 +14,52 @@ Setup steps: 1. Start the docker release environment using the command: - ``` - bash docker/scripts/dev_start.sh - ``` + ``` + bash docker/scripts/dev_start.sh + ``` 2. Enter the docker release environment: - ``` - bash docker/scripts/dev_into.sh - ``` + ``` + bash docker/scripts/dev_into.sh + ``` 3. Build Apollo in the Container: - ``` - bash apollo.sh build - ``` - `Note:` If you do not have a GPU, you can use the following script instead - ``` - bash apollo.sh build_cpu - ``` + ``` + bash apollo.sh build + ``` + + `Note:` If you do not have a GPU, you can use the following script instead + + ``` + bash apollo.sh build_cpu + ``` 4. Bootstrap to start ros call and Monitor module and Dreamview - ``` - bash scripts/bootstrap.sh - ``` + + ``` + bash scripts/bootstrap.sh + ``` 5. Download demo record: - ``` - cd docs/demo_guide/ - python rosbag_helper.py demo_3.5.record - ``` + + ``` + cd docs/demo_guide/ + python record_helper.py demo_3.5.record + ``` 6. Now you can play the record: - ``` - cyber_recorder play -f docs/demo_guide/demo_3.5.record --loop - ``` + ``` + cyber_recorder play -f docs/demo_guide/demo_3.5.record --loop + ``` - The `--loop` option enables record to keep playing the bag in a loop playback mode. + The `--loop` option enables record to keep playing the bag in a loop playback + mode. 7. Open Chrome and go to **localhost:8888** to access Apollo Dreamview, which - opens the screen below. - ![](images/dv_trajectory.png) - The car in Dreamview is happy to move around! + opens the screen below. ![](images/dv_trajectory.png) The car in Dreamview is + happy to move around! Congratulations! diff --git a/docs/demo_guide/README_cn.md b/docs/demo_guide/README_cn.md index f65548f8b7..abd4c89695 100644 --- a/docs/demo_guide/README_cn.md +++ b/docs/demo_guide/README_cn.md @@ -1,54 +1,64 @@ # 运行线下演示 -如果你没有车辆及车载硬件, Apollo还提供了一个计算机模拟环境,可用于演示和代码调试。 +如果你没有车辆及车载硬件, Apollo 还提供了一个计算机模拟环境,可用于演示和代码调 +试。 -线下演示首先要Fork并且Clone Apollo在GitHub的代码,然后需要设置docker的release环境,请参照 [how_to_build_and_release](https://github.com/ApolloAuto/apollo/blob/master/docs/howto/how_to_build_and_release.md)文档中的[Install docker](https://github.com/ApolloAuto/apollo/blob/master/docs/howto/how_to_build_and_release.md#docker)章节。 +线下演示首先要 Fork 并且 Clone Apollo 在 GitHub 的代码,然后需要设置 docker 的 +release 环境,请参照 +[how_to_build_and_release](https://github.com/ApolloAuto/apollo/blob/master/docs/howto/how_to_build_and_release.md)文 +档中 +的[Install docker](https://github.com/ApolloAuto/apollo/blob/master/docs/howto/how_to_build_and_release.md#docker)章 +节。 -Apollo演示的安装步骤: +Apollo 演示的安装步骤: -1. 运行如下命令启动docker的release环境: +1. 运行如下命令启动 docker 的 release 环境: - ``` - bash docker/scripts/dev_start.sh - ``` + ``` + bash docker/scripts/dev_start.sh + ``` -2. 运行如下命令进入docker的release环境: +2. 运行如下命令进入 docker 的 release 环境: - ``` - bash docker/scripts/dev_into.sh - ``` + ``` + bash docker/scripts/dev_into.sh + ``` -3. 在Docker中编译Apollo: - ``` - bash apollo.sh build - ``` - `Note:` 如果没有GPU,请使用下面的命令 +3. 在 Docker 中编译 Apollo: - ``` - bash apollo.sh build_cpu - ``` + ``` + bash apollo.sh build + ``` -4. 启动DreamView - ``` - bash scripts/bootstrap.sh - ``` + `Note:` 如果没有 GPU,请使用下面的命令 -5. 下载demo record: - ``` - cd docs/demo_guide/ - python rosbag_helper.py demo_3.5.record - ``` + ``` + bash apollo.sh build_cpu + ``` -6. 运行如下命令回放record: +4. 启动 DreamView - ``` - cyber_recorder play -f docs/demo_guide/demo_3.5.record --loop - ``` + ``` + bash scripts/bootstrap.sh + ``` - 选项 `--loop` 用于设置循环回放模式. +5. 下载 demo record: -7. 打开Chrome浏览器,在地址栏输入**localhost:8888**即可访问Apollo Dreamview,如下图所示: - ![](images/dv_trajectory.png) - 现在你能看到有一辆汽车在模拟器里移动! + ``` + cd docs/demo_guide/ + python record_helper.py demo_3.5.record + ``` -恭喜你完成了Apollo的演示步骤! +6. 运行如下命令回放 record: + + ``` + cyber_recorder play -f docs/demo_guide/demo_3.5.record --loop + ``` + + 选项 `--loop` 用于设置循环回放模式. + +7. 打开 Chrome 浏览器,在地址栏输入**localhost:8888**即可访问 Apollo Dreamview, + 如下图所示: ![](images/dv_trajectory.png) 现在你能看到有一辆汽车在模拟器里移 + 动! + +恭喜你完成了 Apollo 的演示步骤! diff --git a/docs/demo_guide/record_helper.py b/docs/demo_guide/record_helper.py new file mode 100755 index 0000000000..106db22d72 --- /dev/null +++ b/docs/demo_guide/record_helper.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 + +############################################################################### +# Copyright 2018 The Apollo Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### +""" +A script for downloading Apollo record files +""" + +import os +import sys +import argparse +import subprocess + +DOWNLOAD_LINK_PREFIX = "https://github.com/ApolloAuto/apollo/releases/download" + +URL_LISTING = [ + "v1.0.0/demo_1.0.bag", + "v1.5.0/demo_1.5.bag", + "v2.0.0/demo_2.0.bag", + "v2.0.0/apollo_2.0_camera_sample.bag", + "v2.5.0/demo_2.5.bag", + "v3.5.0/demo_3.5.record", +] + + +def build_urls(): + urls = {} + for u in URL_LISTING: + urls[os.path.basename(u)] = "{}/{}".format(DOWNLOAD_LINK_PREFIX, u) + return urls + + +def download_record(record_name, urls): + """ + Match and download record from urls, and save it locally + """ + if record_name not in urls: + print( + "Unknown record: {}. Type \"{} --help\" on available records.".format( + record_name, + sys.argv[0])) + return False + url = urls[record_name] + print("Downloading {}".format(url)) + result = subprocess.run(["wget", url, "-O", record_name]) + return result.returncode == 0 + + +if __name__ == "__main__": + urls = build_urls() + name_desc = "record name. Available records: {}".format( + ", ".join(u for u in urls)) + parser = argparse.ArgumentParser( + description="A script for downloading Apollo demo records") + parser.add_argument( + "name", + type=str, + help=name_desc) + args = parser.parse_args() + + requested_record = args.name + success = download_record(requested_record, urls) + if success: + print("Successfully downloaded {}".format(requested_record)) + else: + print("Bad luck, failed to download {}".format(requested_record)) diff --git a/docs/demo_guide/rosbag_helper.py b/docs/demo_guide/rosbag_helper.py deleted file mode 100755 index 73752a6684..0000000000 --- a/docs/demo_guide/rosbag_helper.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -############################################################################### -# Copyright 2018 The Apollo Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################### - -import os - -import urllib.request -import urllib.parse -import urllib.error - - -URL_LIST = [ - "https://github.com/ApolloAuto/apollo/releases/download/v1.5.0/demo_1.5.bag", - "https://github.com/ApolloAuto/apollo/releases/download/v2.0.0/demo_2.0.bag", - "https://github.com/ApolloAuto/apollo/releases/download/v2.0.0/apollo_2.0_camera_sample.bag", - "https://github.com/ApolloAuto/apollo/releases/download/v2.5.0/demo_2.5.bag", - "https://github.com/ApolloAuto/apollo/releases/download/v1.0.0/demo_1.0.bag", - "https://github.com/ApolloAuto/apollo/releases/download/v3.5.0/demo_3.5.record", -] - -URL_DICT = {} -for link in URL_LIST: - name = link.split("/")[-1] - URL_DICT[name] = link - - -def retrieve_rosbag(bagname): - if bagname not in URL_DICT: - print( - "bag[%s] is unknown, use one of the following rosbag names:\n%s" % - (bagname, ", ".join([name for name in URL_DICT.keys()]))) - return False - url = URL_DICT[bagname] - print("Downloading from %s" % url) - ret = os.system('wget %s -O %s' % (url, bagname)) - return ret == 0 - - -if __name__ == "__main__": - import argparse - parser = argparse.ArgumentParser( - description='retrieve demo rosbag file from remote') - parser.add_argument( - 'name', - type=str, - help='rosbag names. You can choose one of [%s]' % ", ".join( - [name for name in URL_DICT.keys()])) - args = parser.parse_args() - if retrieve_rosbag(args.name): - print("Download %s success" % args.name) - else: - print("Download %s failed" % args.name) diff --git a/docs/howto/how_to_launch_Apollo.md b/docs/howto/how_to_launch_Apollo.md index 89683c1267..7a4158ba9a 100644 --- a/docs/howto/how_to_launch_Apollo.md +++ b/docs/howto/how_to_launch_Apollo.md @@ -59,7 +59,7 @@ To see if the system works, use the demo 'record' to "feed" the system. ``` # You need to download the demo record using the following commands cd docs/demo_guide/ -python3 rosbag_helper.py demo_3.5.record +python3 record_helper.py demo_3.5.record # You can now replay this demo "record" in a loop with the '-l' flag cyber_recorder play -f docs/demo_guide/demo_3.5.record -l diff --git a/docs/specs/D-kit/Waypoint_Following/Apollo_Installation_cn.md b/docs/specs/D-kit/Waypoint_Following/Apollo_Installation_cn.md index 876abcef6f..689c8697e0 100644 --- a/docs/specs/D-kit/Waypoint_Following/Apollo_Installation_cn.md +++ b/docs/specs/D-kit/Waypoint_Following/Apollo_Installation_cn.md @@ -533,7 +533,7 @@ c.回放数据包 在终端输入以下命令下载数据包: ``` -python docs/demo_guide/rosbag_helper.py demo_3.5.record +python3 docs/demo_guide/record_helper.py demo_3.5.record ``` 输入以下命令可以回放数据包,在浏览器DreamView中应该可以看到回放画面。 @@ -606,4 +606,4 @@ function check_esd_files() { fi } ``` -不同的apollo版本可能对检查的库文件名称的要求不同,可根据实际情况建立软连接。 \ No newline at end of file +不同的apollo版本可能对检查的库文件名称的要求不同,可根据实际情况建立软连接。 -- GitLab