Add unit tests for SafetyState
まだ誰も着手していません。
評価
調査の方向性
src/utils/safety_state.hpp と src/utils/safety_state.cpp を読んで SafetyState::evaluate と reasons_to_string を理解し、test/test_utils/test_main.cpp の構成と比較してください。test/host/Arduino.h でホスト時刻を制御できるようにし、指定された test/test_safety/test_main.cpp のテストスイートと Makefile のエントリーを追加して、make test を実行してください。列挙されたすべてのケースに個別のテストがあり、スイートが成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
SafetyState decides whether the motors may move, and it has no tests. Good first task. No hardware needed.
Files
src/utils/safety_state.hpp,src/utils/safety_state.cppsrc/utils/timing.hpp(Timer, usesmicros())test/host/Arduino.h(host stub;micros()always returns 0 today)Makefile
Steps
- Read
SafetyState::evaluate. It takes four booleans and returns a bitmask ofReasonflags.NONE(0) means the motors are armed. - Make time controllable in host tests. In
test/host/Arduino.h, in the non-FW_SIMULATIONbranch, replace the fixedmicros()with:
Runinline uint32_t host_fake_micros = 0; inline uint32_t micros() { return host_fake_micros; }make testto check nothing else broke. - Create
test/test_safety/test_main.cpp(copy the layout oftest/test_utils/test_main.cpp) and add to theMakefile:HOST_TEST_SRC_test_safety := $(TEST_DIR)/test_safety/test_main.cpp src/utils/safety_state.cpp - Write one test per case, with a fresh
SafetyStateandhost_fake_micros = 0at the start of each:- Each input on its own sets exactly its own bit (transmitter, not configured, slow loop, gimbal power off).
- All four bad at once sets all four bits.
- Gimbal power just turned on:
GIMBAL_POWER_SETTLINGis set. - Gimbal power on for
GIMBAL_POWER_SETTLE_US(3 s) or more: settling clears andmotors_armed()is true. - Power off then on again: the 3 s wait starts over.
reasons_to_string:NONEgives"none", two bits give both names separated by one space, and a small buffer (length 5) never overflows and stays null-terminated.
Done when
make testpasses with the newtest_safetysuite.- Each case above has its own test.
- 主要言語
- C
- スター
- 11
- フォーク
- 2
- 平均マージ
- 18日 3時間
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CU-Robotics/firmware のほかの issue
-
Pre-flight checksオープンin progress
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
CU-Robotics/firmware#222 ·
-
Fix existing clang-tidy findings対応中かも @roccoagain が今日担当しました。 オープン
CU-Robotics/firmware#262 · 担当者 1 名 ·
-
not started
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
CU-Robotics/firmware#258 ·
-
good first issue not started
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
CU-Robotics/firmware#256 ·
-
in progress software-in-the-loop
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
CU-Robotics/firmware#250 · コメント 1 件 ·
CU-Robotics/firmware の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
schrodinger/pymol-open-source#532 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
facebookexperimental/hermit#347 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
CTSRD-CHERI/cheribsd#2769 ·
メンテナーはふだん 2 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
luainkernel/lunatik#2633 ·
メンテナーはふだん 1 日以内に返信