14void printUsage(
const char* program_name) {
17 <<
" " << program_name <<
" Run Guardian FSM scenario demo\n"
18 <<
" " << program_name <<
" --button-test\n"
19 <<
" " << program_name <<
" --servo-calibrate\n"
20 <<
" " << program_name <<
" --servo-console\n"
21 <<
" " << program_name <<
" --motion-home\n"
22 <<
" " << program_name <<
" --motion-smoke-test [options]\n"
23 <<
" " << program_name <<
" --camera-backend-check [options]\n"
24 <<
" " << program_name <<
" --live-test [options]\n"
26 <<
" --button-test Run a GPIO button diagnostic loop\n"
27 <<
" --full-demo Deprecated alias for --live-test\n"
28 <<
" --servo-calibrate Run an interactive raw-pulse calibration console\n"
29 <<
" --servo-console Run an interactive servo console (for example: 'base 90')\n"
30 <<
" --motion-home Move all joints to logical 0 / home and exit\n"
31 <<
" --motion-smoke-test Run the motion-only servo smoke test (all joints by default)\n"
32 <<
" --camera-backend-check Capture a short sample and report backend/frame stats\n"
33 <<
" --base Smoke-test only the base servo\n"
34 <<
" --lower Smoke-test only the lower servo\n"
35 <<
" --upper Smoke-test only the upper servo\n"
36 <<
" --grip Smoke-test only the grip servo\n"
37 <<
"\nOptions for --live-test:\n"
38 <<
" --camera-index <n> Camera index (default: 0)\n"
39 <<
" --expected-marker-id <n> Expected ArUco marker ID (default: 23)\n"
40 <<
" --camera-backend <name> Camera backend: auto, libcamera2opencv, or opencv (default: auto)\n"
41 <<
" --auto-ack Auto-send operator acknowledge when frozen\n"
42 <<
" --help Show this message\n"
43 <<
"\nLive-test controls:\n"
44 <<
" space/button Operator acknowledge\n"
45 <<
" 0/1/2/3 Select mode/routine\n"
46 <<
" d/a Base left/right\n"
47 <<
" w/s Forward/backward\n"
49 <<
" l/j Open/close gripper\n"
50 <<
" +/- Adjust camera focus (Pi Camera Module 3 only, -=autofocus)\n"
55 if (arg ==
"--base") {
59 if (arg ==
"--lower") {
63 if (arg ==
"--upper") {
67 if (arg ==
"--grip") {
74bool parseIntArg(
const char* text,
int& value) {
76 const std::string raw(text);
77 std::size_t parsed_count = 0;
78 const int parsed = std::stoi(raw, &parsed_count);
79 if (parsed_count != raw.size()) {
84 }
catch (
const std::exception&) {
89bool parseCameraBackendArg(
const std::string& raw,
95 if (raw ==
"opencv" || raw ==
"videocapture") {
99 if (raw ==
"libcamera2opencv" || raw ==
"libcamera" || raw ==
"cam2opencv") {
108int main(
int argc,
char* argv[]) {
109 bool run_button_test =
false;
110 bool run_live_test =
false;
111 bool run_servo_calibrate =
false;
112 bool run_servo_console =
false;
113 bool run_motion_home =
false;
114 bool run_motion_smoke_test =
false;
115 bool run_camera_backend_check =
false;
118 bool smoke_joint_selected =
false;
120 for (
int i = 1; i < argc; ++i) {
121 const std::string arg(argv[i]);
123 if (arg ==
"--help") {
128 if (arg ==
"--live-test") {
129 run_live_test =
true;
133 if (arg ==
"--button-test") {
134 run_button_test =
true;
138 if (arg ==
"--full-demo") {
139 std::cerr <<
"[CLI] --full-demo is deprecated; using --live-test."
141 run_live_test =
true;
145 if (arg ==
"--servo-calibrate") {
146 run_servo_calibrate =
true;
150 if (arg ==
"--servo-console") {
151 run_servo_console =
true;
155 if (arg ==
"--motion-home") {
156 run_motion_home =
true;
160 if (arg ==
"--motion-smoke-test") {
161 run_motion_smoke_test =
true;
165 if (arg ==
"--camera-backend-check") {
166 run_camera_backend_check =
true;
170 if (parseSmokeJointFlag(arg, smoke_options.
joint)) {
171 if (smoke_joint_selected) {
172 std::cerr <<
"Choose one smoke-test joint flag at a time." << std::endl;
176 run_motion_smoke_test =
true;
177 smoke_joint_selected =
true;
181 if (arg ==
"--auto-ack") {
186 if ((arg ==
"--camera-index" || arg ==
"--expected-marker-id" ||
187 arg ==
"--camera-backend") &&
189 if (arg ==
"--camera-backend") {
191 std::cerr <<
"Invalid camera backend for " << arg <<
": "
192 << argv[i + 1] << std::endl;
200 int parsed_value = 0;
201 if (!parseIntArg(argv[i + 1], parsed_value)) {
202 std::cerr <<
"Invalid numeric value for " << arg <<
": "
203 << argv[i + 1] << std::endl;
207 if (arg ==
"--camera-index") {
217 std::cerr <<
"Unknown or incomplete argument: " << arg << std::endl;
222 if ((run_button_test && run_live_test) ||
223 (run_button_test && run_servo_calibrate) ||
224 (run_button_test && run_servo_console) ||
225 (run_button_test && run_motion_home) ||
226 (run_button_test && run_motion_smoke_test) ||
227 (run_button_test && run_camera_backend_check) ||
228 (run_live_test && run_servo_calibrate) ||
229 (run_live_test && run_servo_console) ||
230 (run_live_test && run_motion_home) ||
231 (run_live_test && run_motion_smoke_test) ||
232 (run_live_test && run_camera_backend_check) ||
233 (run_servo_calibrate && run_servo_console) ||
234 (run_servo_calibrate && run_motion_home) ||
235 (run_servo_calibrate && run_motion_smoke_test) ||
236 (run_servo_calibrate && run_camera_backend_check) ||
237 (run_servo_console && run_motion_home) ||
238 (run_servo_console && run_motion_smoke_test) ||
239 (run_servo_console && run_camera_backend_check) ||
240 (run_motion_home && run_motion_smoke_test) ||
241 (run_motion_home && run_camera_backend_check) ||
242 (run_motion_smoke_test && run_camera_backend_check)) {
243 std::cerr <<
"Choose exactly one mode: --button-test, --live-test, --servo-calibrate, --servo-console, --motion-home, --motion-smoke-test, or --camera-backend-check."
250 if (run_button_test) {
254 if (run_servo_calibrate) {
258 if (run_servo_console) {
262 if (run_motion_home) {
266 if (run_motion_smoke_test) {
270 if (run_camera_backend_check) {
Top-level runtime mode controller for ARGUS.
Orchestrates runtime modes for ARGUS.
int runMotionSmokeTest(const MotionSmokeTestOptions &options)
Run motion-only smoke tests using the selected joint scope.
int runMotionHomePose()
Move the arm to the configured home pose and exit.
SmokeJoint
Joint selector used by motion smoke-test mode.
@ Base
Run smoke test for base joint only.
@ Upper
Run smoke test for upper joint only.
@ Lower
Run smoke test for lower joint only.
@ Grip
Run smoke test for gripper joint only.
int runCameraBackendCheck(const LiveTestOptions &options)
Run camera backend validation/check mode.
int runInteractiveServoConsole()
Run interactive servo console mode.
int runLiveMarkerTest(const LiveTestOptions &options)
Run live safety supervision mode.
int runServoCalibration()
Run interactive raw-pulse servo calibration mode.
int runButtonTest()
Run physical-button diagnostics.
int runGuardianScenarioDemo()
Run the scripted guardian scenario demonstration.
BackendPreference
Backend selection policy.
@ Auto
Auto-select backend based on platform/runtime constraints.
@ OpenCvVideoCapture
Force OpenCV VideoCapture backend.
@ Libcamera2OpenCv
Force libcamera2opencv callback backend.
int main(int argc, char *argv[])
Options used by live test and camera backend check modes.
bool auto_ack
Auto-send acknowledge after freeze for testing.
CameraCapture::BackendPreference backend_preference
Requested camera backend policy.
int expected_marker_id
Expected marker ID (legacy CLI option).
int camera_index
Camera index passed to CameraCapture.
Options for the motion smoke-test mode.
SmokeJoint joint
Joint subset to smoke-test.