diff --git a/docs/device/4-device-collector.md b/docs/device/4-device-collector.md index b4359fc9e..f8139e7bc 100644 --- a/docs/device/4-device-collector.md +++ b/docs/device/4-device-collector.md @@ -189,6 +189,94 @@ topics: - error_code ``` +--- +### 模板语法使用 + +## 概述 + +模板语法是一种动态生成字符串的强大工具,特别适用于根据时间范围动态生成文件路径和文件名。基于 [Handlebars](https://handlebarsjs.com/) 模板引擎,集成了 [Day.js](https://day.js.org/) 时间处理库。 + +通过掌握这些模板语法,您可以轻松创建动态的文件路径和文件名,大大提高数据管理的灵活性和自动化程度。 + +## 基本语法 + +### 支持的变量 + +目前支持以下两个时间变量: + +- `start_time` - 当前采集任务的开始时间 +- `end_time` - 当前采集任务的结束时间 + +### 基本模板格式 + +``` +{{变量名.format('格式字符串')}} +``` + +### 示例 + +```javascript +// 基本用法 +'{{start_time.format("YYYY-MM-DD")}}' +// 输出: "2021-01-01" + +// 组合使用 +'data/{{start_time.format("YYYY")}}/{{start_time.format("MM")}}/file.log' +// 输出: "data/2021/01/file.log" +``` + +## 时间格式化 + +### 常用格式化选项 + +基于 [Day.js 格式化文档](https://day.js.org/docs/en/display/format),支持以下格式: + +| 格式 | 输出 | 描述 | +|------|------|------| +| `YYYY` | 2021 | 四位年份 | +| `YY` | 21 | 两位年份 | +| `MM` | 01-12 | 月份(补零) | +| `M` | 1-12 | 月份 | +| `DD` | 01-31 | 日期(补零) | +| `D` | 1-31 | 日期 | +| `HH` | 00-23 | 小时(补零) | +| `H` | 0-23 | 小时 | +| `mm` | 00-59 | 分钟(补零) | +| `m` | 0-59 | 分钟 | +| `ss` | 00-59 | 秒(补零) | +| `s` | 0-59 | 秒 | + +### 格式化示例 + +```javascript +// 日期格式 +'{{start_time.format("YYYY-MM-DD")}}' // 2021-01-01 +'{{start_time.format("YYYY/MM/DD")}}' // 2021/01/01 +'{{start_time.format("MM-DD-YYYY")}}' // 01-01-2021 + +// 时间格式 +'{{start_time.format("HH:mm:ss")}}' // 10:30:00 +'{{start_time.format("HH-mm")}}' // 10-30 + +// 组合格式 +'{{start_time.format("YYYY-MM-DD HH:mm:ss")}}' // 2021-01-01 10:30:00 +'{{start_time.format("YYYYMMDD_HHmmss")}}' // 20210101_103000 + +// 按年月日组织的文件夹结构 +'logs/{{start_time.format("YYYY")}}/{{start_time.format("MM")}}/{{start_time.format("DD")}}' +// 输出: logs/2021/01/01 + +// 时间范围文件夹 +'data/{{start_time.format("YYYY-MM-DD")}}_to_{{end_time.format("YYYY-MM-DD")}}' +// 输出: data/2021-01-01_to_2021-01-02 +``` + +## 参考文档 + +- [Handlebars 官方文档](https://handlebarsjs.com/guide/) +- [Day.js 官方文档](https://day.js.org/docs/en/display/format) +- [Day.js 格式化选项](https://day.js.org/docs/en/display/format#list-of-all-available-formats) + --- 通过以上详细步骤和说明,管理员可全面、准确地对设备数采客户端进行配置,确保设备数据采集工作的高效运行。 diff --git a/docs/use-case/4-online-simulation-test.md b/docs/use-case/4-online-simulation-test.md index 936e6a59d..ca4790b4a 100644 --- a/docs/use-case/4-online-simulation-test.md +++ b/docs/use-case/4-online-simulation-test.md @@ -92,7 +92,7 @@ tar -czvf install.tar.gz ./install - 源码构建与编译后的可执行程序 -可参考平台文档 👉 https://docs.coscene.cn/docs/sim-and-tests/regression/test-bundle-management +可参考 [Test Bundle 管理文档](../sim-and-tests/regression/4-test-bundle-management.md) 获取更多信息 **_对于企业用户,还支持 GitHub / GitLab 持续集成上传构建产物,跳过手动上传过程。_** @@ -127,7 +127,7 @@ test_case/ ### 文件结构规范 -请严格遵循[平台规定的路径结构](https://docs.coscene.cn/docs/sim-and-tests/regression/intro): +请严格遵循[平台规定的路径结构](../sim-and-tests/regression/1-intro.md): ![文件结构示意图](./img/4-online-simulation-test-13.png) @@ -152,7 +152,7 @@ test_case/ - 手动选择记录执行 - 按标签或版本筛选测试集 -详细配置参考 👉 https://docs.coscene.cn/docs/sim-and-tests/regression/config-management +详细配置请参考[测试配置管理文档](../sim-and-tests/regression/3-config-management.md) ![4-online-simulation-test-18](./img/4-online-simulation-test-18.png) ![4-online-simulation-test-19](./img/4-online-simulation-test-19.png) ![4-online-simulation-test-20](./img/4-online-simulation-test-20.png) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/device/4-device-collector.md b/i18n/en/docusaurus-plugin-content-docs/current/device/4-device-collector.md index ab314bc1e..578a8af9f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/device/4-device-collector.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/device/4-device-collector.md @@ -180,6 +180,96 @@ topics: --- +### Template Syntax Usage + +## Overview + +Template syntax is a powerful tool for dynamically generating strings, particularly suitable for dynamically generating file paths and filenames based on time ranges. Based on the [Handlebars](https://handlebarsjs.com/) template engine, integrated with the [Day.js](https://day.js.org/) time processing library. + +By mastering these template syntaxes, you can easily create dynamic file paths and filenames, greatly improving the flexibility and automation of data management. + +## Basic Syntax + +### Supported Variables + +Currently supports the following two time variables: + +- `start_time` - The start time of the current collection task +- `end_time` - The end time of the current collection task + +### Basic Template Format + +``` +{{variable_name.format('format_string')}} +``` + +### Examples + +```javascript +// Basic usage +'{{start_time.format("YYYY-MM-DD")}}' +// Output: "2021-01-01" + +// Combined usage +'data/{{start_time.format("YYYY")}}/{{start_time.format("MM")}}/file.log' +// Output: "data/2021/01/file.log" +``` + +## Time Formatting + +### Common Formatting Options + +Based on [Day.js formatting documentation](https://day.js.org/docs/en/display/format), supports the following formats: + +| Format | Output | Description | +|--------|--------|-------------| +| `YYYY` | 2021 | 4-digit year | +| `YY` | 21 | 2-digit year | +| `MM` | 01-12 | Month (zero-padded) | +| `M` | 1-12 | Month | +| `DD` | 01-31 | Date (zero-padded) | +| `D` | 1-31 | Date | +| `HH` | 00-23 | Hour (zero-padded) | +| `H` | 0-23 | Hour | +| `mm` | 00-59 | Minute (zero-padded) | +| `m` | 0-59 | Minute | +| `ss` | 00-59 | Second (zero-padded) | +| `s` | 0-59 | Second | + +### Formatting Examples + +```javascript +// Date formats +'{{start_time.format("YYYY-MM-DD")}}' // 2021-01-01 +'{{start_time.format("YYYY/MM/DD")}}' // 2021/01/01 +'{{start_time.format("MM-DD-YYYY")}}' // 01-01-2021 + +// Time formats +'{{start_time.format("HH:mm:ss")}}' // 10:30:00 +'{{start_time.format("HH-mm")}}' // 10-30 + +// Combined formats +'{{start_time.format("YYYY-MM-DD HH:mm:ss")}}' // 2021-01-01 10:30:00 +'{{start_time.format("YYYYMMDD_HHmmss")}}' // 20210101_103000 + +// Folder structure organized by year/month/day +'logs/{{start_time.format("YYYY")}}/{{start_time.format("MM")}}/{{start_time.format("DD")}}' +// Output: logs/2021/01/01 + +// Time range folders +'data/{{start_time.format("YYYY-MM-DD")}}_to_{{end_time.format("YYYY-MM-DD")}}' +// Output: data/2021-01-01_to_2021-01-02 +``` + +## Reference Documentation + +- [Handlebars Official Documentation](https://handlebarsjs.com/guide/) +- [Day.js Official Documentation](https://day.js.org/docs/en/display/format) +- [Day.js Formatting Options](https://day.js.org/docs/en/display/format#list-of-all-available-formats) + +--- + Through these detailed steps and instructions, administrators can comprehensively and accurately configure the device data collection client, ensuring efficient operation of device data collection. If you have any questions, please feel free to contact us for support. + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/use-case/4-online-simulation-test.md b/i18n/en/docusaurus-plugin-content-docs/current/use-case/4-online-simulation-test.md new file mode 100644 index 000000000..8bb786863 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/use-case/4-online-simulation-test.md @@ -0,0 +1,198 @@ +--- +sidebar_position: 4 +--- + +# Cloud-Based Simulation & Automated Algorithm Verification + +## Background + +In **robotics R&D**, the endless cycle of testing and validating algorithms and software is often the most time‑consuming and error‑prone part of daily work. + +Sound familiar? + +- You tweak _one_ line of code and end up testing all day +- Your local simulation stack suddenly breaks—re‑installing is a minefield +- Multiple teammates run their own tests … and the results never match + +For teams working on **mobile robots and embodied intelligence**, the pain is even sharper: + +- Rapid software iterations demand continuous validation +- Simulation stacks are complex and costly to maintain +- No unified test standards, so results are hard to quantify +- Limited local compute; long queues for every test run + +--- + +At **coScene** we kept asking ourselves: + +_What if you could validate every algorithm change on demand—zero setup, fully reproducible, and with standardized outputs?_ + +Leveraging our deep experience in **data loops** and **productivity tooling**, we built a one‑stop **cloud simulation platform** grounded in the **SceneOps philosophy**: + +**Just five quick steps to set things up.** +Upload your program and the platform auto‑runs the tests, captures data, and generates visual reports—fully online, zero local dependencies! + +![4-online-simulation-test-1](./img/4-online-simulation-test-1.png) + +This guide walks through Ubuntu 22.04 + ROS 2 Humble + Gazebo as an example. +For other simulators, see the official site: [coScene Platform](https://www.coscene.cn/). + +--- + +## 🧱 Step 1: Build Your Own Test Runtime + +Every team’s tech stack is unique, so coScene lets you create a custom container image with all your dependencies and push it to the platform. + +A minimal `Dockerfile` template: + +```Dockerfile +# syntax=docker/dockerfile:1.2 +ARG BASE_IMAGE=osrf/ros:humble-desktop-full +FROM ${BASE_IMAGE} as base +... +WORKDIR /action/ros2_ws +``` + +Open‑source sample 👉 [Regression_Test-Sample](https://github.com/coscene-io/Regression_Test-Sample/blob/main/Dockerfile) + +After building, push the image to your organization’s private registry so everyone can reuse the same, stable test environment. + +1. Sign in to coScene, open **Organization → Image Registry** to get your push URL + ![4-online-simulation-test-2](./img/4-online-simulation-test-2.PNG) + ![4-online-simulation-test-3](./img/4-online-simulation-test-3.PNG) + ![4-online-simulation-test-4](./img/4-online-simulation-test-4.PNG) + +2. Log in to Docker and push the image + ![4-online-simulation-test-5](./img/4-online-simulation-test-5.PNG) + +3. Verify the image inside the platform and copy its link + ![4-online-simulation-test-6](./img/4-online-simulation-test-6.png) + +You now have a shared “runtime base” for all future simulation tests, with every dependency baked in. + +--- + +## 📦 Step 2: Upload Your Algorithm & Test Program + +After modifying your code, build and package it: + +```bash +tar -czvf install.tar.gz ./install # recommended: package the install/ folder +``` + +In your coScene project, click **Upload Program**. +The platform auto‑extracts the archive and places it in the test container. + +![4-online-simulation-test-8](./img/4-online-simulation-test-8.png) +![4-online-simulation-test-9](./img/4-online-simulation-test-9.png) +![4-online-simulation-test-10](./img/4-online-simulation-test-10.png) +![4-online-simulation-test-11](./img/4-online-simulation-test-11.png) + +Supported uploads: + +- Compiled executables or raw source to be built in‑container + +Refer to the [Test Bundle Management Docs](../sim-and-tests/regression/4-test-bundle-management.md) for more info. + +**Enterprise Edition**: integrate GitHub/GitLab CI to push artifacts automatically—no manual upload required. + +--- + +## 🧪 Step 3: Prepare Test Cases + +Within **Organization → Project → Records** you can define multiple test cases. +Each record is a virtual “test scene” containing: + +- **Map**: `map.pgm` + `map.yaml` +- **Robot model** (e.g., `turtlebot3_waffle_pi`) +- **Config** (e.g., `case.yaml`) +- **Gazebo world** +- Any extra resources + +Example layout: + +``` +test_case/ +├── map.pgm +├── map.yaml +├── case.yaml +├── world.world +└── extra_configs/ +``` + +![4-online-simulation-test-12](./img/4-online-simulation-test-12.png) + +:::info Important Note + +### Directory Convention + +Follow the [official path structure](../sim-and-tests/regression/1-intro.md): + +![Structure diagram](./img/4-online-simulation-test-13.png) + +::: + +### Tagging + +Add labels (e.g., `Navigation_Error`) for easy filtering: + +![Step 1: Tag manager](./img/4-online-simulation-test-14.png) +![Step 2: New tag](./img/4-online-simulation-test-15.png) +![Step 3: Set properties](./img/4-online-simulation-test-16.png) +![Step 4: Apply tag](./img/4-online-simulation-test-17.png) + +You can now select cases by tag in the next step. + +--- + +## ⚙️ Step 4: Configure Test Triggers + +Each project supports flexible trigger rules: + +- Auto‑run tests on every program upload +- Manually select specific records +- Filter by tag or version + +Refer to the [Regression Config Management](../sim-and-tests/regression/3-config-management.md) for more info. + +![4-online-simulation-test-18](./img/4-online-simulation-test-18.png) +![4-online-simulation-test-19](./img/4-online-simulation-test-19.png) +![4-online-simulation-test-20](./img/4-online-simulation-test-20.png) + +--- + +## 📊 Step 5: Run & Monitor Tests + +During execution you get: + +- Live visualization of robot state (Gazebo viewer supported) +- Automatic data recording +- Standardized test reports + +![4-online-simulation-test-21](./img/4-online-simulation-test-21.png) +![4-online-simulation-test-22](./img/4-online-simulation-test-22.png) +![4-online-simulation-test-23](./img/4-online-simulation-test-23.gif) + +Report includes: + +- 📍 Trajectory plots +- ✅ Pass / fail metrics +- 🪵 Logs & exceptions +- 🖼️ Charts & statistics + +![4-online-simulation-test-24](./img/4-online-simulation-test-24.png) +![4-online-simulation-test-25](./img/4-online-simulation-test-25.png) + +--- + +## 🚀 Wrap‑Up: Offload the Grind, Focus on Innovation + +After every code change, you no longer need to: + +- Rebuild environments +- Re‑run scripts by hand +- Manually diff logs + +Just **one upload**, and coScene handles the rest—standardized, automated, and always reproducible—so you can spend more time on what truly matters. + +👉 Sign up and try it out ![https://www.coscene.cn/](https://www.coscene.cn/)