Add unit tests for SafetyState
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 90/100
Hướng nghiên cứu
Đọc src/utils/safety_state.hpp và src/utils/safety_state.cpp để hiểu SafetyState::evaluate và reasons_to_string, sau đó so sánh bố cục trong test/test_utils/test_main.cpp. Cho phép điều khiển thời gian host trong test/host/Arduino.h, thêm bộ kiểm thử test/test_safety/test_main.cpp được chỉ định và mục trong Makefile, rồi chạy make test. Công việc hoàn tất khi mỗi trường hợp được liệt kê có bài kiểm thử riêng và bộ kiểm thử chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C
- Star
- 11
- Fork
- 2
- Merge trung bình
- 18 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CU-Robotics/firmware
-
Pre-flight checksĐang mởin progress
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
CU-Robotics/firmware#222 ·
-
Fix existing clang-tidy findingsCó thể đã có người làm @roccoagain đã nhận hôm nay. Đang mở
CU-Robotics/firmware#262 · 1 người được giao ·
-
not started
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
CU-Robotics/firmware#258 ·
-
good first issue not started
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
CU-Robotics/firmware#256 ·
-
in progress software-in-the-loop
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
CU-Robotics/firmware#250 · 1 bình luận ·
Tất cả issue của CU-Robotics/firmware
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
ROCm/rocm-libraries#16108 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
wiznet_common: emac_wiznet_transmit() reports a frame as failed when the SEND_OK read is delayed (IDFGH-18721)Có thể đã có người làm @valdijanio đã nhận hôm nay. Đang mởStatus: Opened
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
espressif/esp-eth-drivers#198 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
schrodinger/pymol-open-source#532 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
facebookexperimental/hermit#347 ·
Maintainer thường phản hồi trong vòng 1 ngày