diff --git a/doc/zh-Hans/spec_control_api.md b/doc/zh-Hans/spec_control_api.md index 65cce67..7a294a0 100644 --- a/doc/zh-Hans/spec_control_api.md +++ b/doc/zh-Hans/spec_control_api.md @@ -16,8 +16,8 @@ | 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 通道地址 | 说明 | | :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----------- | :----- | -| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 0x0100 | | -| IMU 频率 | imu_frequency | 2 | 200 | 200 | 500 | √ | 0x23 | XU_CAM_CTRL | 0x0100 | | +| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 0x0100 | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55,60} | +| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 0x0100 | 有效值为{100,200,250,333,500} | | 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0x0100 | 0:开启自动曝光; 1:关闭 | | 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 | | 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 | diff --git a/src/internal/channels.cc b/src/internal/channels.cc index d9cf38b..f7960fd 100644 --- a/src/internal/channels.cc +++ b/src/internal/channels.cc @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include MYNTEYE_BEGIN_NAMESPACE @@ -152,6 +154,19 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) { } return true; }; + auto in_values = [&option, &value](std::vector values) { + if (std::find(values.begin(), values.end(), value) != values.end()) { + return true; + } else { + std::ostringstream ss; + std::copy( + values.begin(), values.end(), + std::ostream_iterator(ss, ",")); + LOG(WARNING) << option << " set value invalid, must be {" << ss.str() + << "}"; + return false; + } + }; switch (option) { case Option::GAIN: case Option::BRIGHTNESS: @@ -162,8 +177,17 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) { LOG(WARNING) << option << " set value failed"; } } break; - case Option::FRAME_RATE: - case Option::IMU_FREQUENCY: + case Option::FRAME_RATE: { + if (!in_range() || + !in_values({10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60})) + break; + XuCamCtrlSet(option, value); + } break; + case Option::IMU_FREQUENCY: { + if (!in_range() || !in_values({100, 200, 250, 333, 500})) + break; + XuCamCtrlSet(option, value); + } break; case Option::EXPOSURE_MODE: case Option::MAX_GAIN: case Option::MAX_EXPOSURE_TIME: diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/launch/mynteye.launch b/wrappers/ros/src/mynt_eye_ros_wrapper/launch/mynteye.launch index 0250024..ec071a1 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/launch/mynteye.launch +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/launch/mynteye.launch @@ -17,23 +17,23 @@ - + - + - + - + - + @@ -41,19 +41,19 @@ - + - + - + - +