set_state_led_off (자동 모드)
이 절에서는 자동 운전 중에 set_state_led_off를 사용하는 방법을 설명합니다. 이 함수는 로봇의 상태 LED를 완전히 끕니다. 유지보수 중이거나 조용히 운용할 때 LED 표시를 잠시 끄는 용도로 자주 사용합니다.
자동 모드에서만, 컨트롤러 v3.4 이상에서 사용할 수 있습니다. 다른 모드이거나 이전 버전 컨트롤러이면 false를 반환합니다. 모드는 get_robot_mode가 반환하는 값으로 확인합니다.
일반적인 사용법
진단 중에 LED 조명을 끕니다.
LED 빛이 비전 캘리브레이션이나 카메라 감지를 방해할 수 있을 때 사용합니다.
LED를 꺼서 “일시 정지” 또는 “대기” 상태를 나타냅니다.
예제
LED 함수는 다른 모드에서 거부되므로, 예제에서는 LED 함수를 호출하기 전에 제어권(Control Authority)을 얻고 자동 모드로 설정합니다.
#include <atomic>
#include <chrono>
#include <cstdio>
#include <thread>
std::atomic<bool> g_bHasControlAuthority(false);
void OnMonitoringAccessControlCB(const MONITORING_ACCESS_CONTROL eAccess)
{
if (eAccess == MONITORING_ACCESS_CONTROL_GRANT)
g_bHasControlAuthority = true;
}
drfl.set_on_monitoring_access_control(OnMonitoringAccessControlCB);
if (!drfl.open_connection("192.168.137.100")) return 1;
drfl.manage_access_control(MANAGE_ACCESS_CONTROL_FORCE_REQUEST);
while (!g_bHasControlAuthority)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// 자동 모드가 아니면 LED 함수가 거부됩니다
if (!drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS)) return 1;
if (!drfl.set_state_led_off()) {
printf("[ERROR] Failed to turn off the State LED.\n");
return 1;
}
printf("[LED] State LED has been turned off.\n");
std::this_thread::sleep_for(std::chrono::seconds(3));
if (drfl.state_led_reset()) // 이후 LED 복원
printf("[LED] LED reset to default state.\n");
else
printf("[ERROR] Failed to reset LED state.\n");
이 함수는 모든 LED 출력을 끕니다. LED 빛으로 인한 방해나 주변광 간섭 없이 작업할 수 있습니다.
참고
true를 반환해도 LED가 바뀌었다는 뜻은 아닙니다.
팁
일시 정지 중에 대기 또는 비활성 상태를 나타낼 때 사용합니다.
유지보수가 끝나면 state_led_reset과 함께 사용해 LED 동작을 복원하세요.
카메라 캘리브레이션이나 빛에 민감한 작업을 할 때 유용합니다.