Add options

This commit is contained in:
Kalman 2018-08-16 19:34:01 +08:00
parent e40a4aaa3f
commit 0d1b063942
5 changed files with 82 additions and 9 deletions

View File

@ -197,6 +197,36 @@ enum class Option : std::uint8_t {
ZERO_DRIFT_CALIBRATION,
/** Erase chip */
ERASE_CHIP,
/**
* min exposure time, valid if auto-exposure
*
* range: [0,?], default: ?
*/
MIN_EXPOSURE_TIME,
/**
* The range of accelerometer
*
* values: {?}, default: ?
*/
ACCELEROMETER_RANGE,
/**
* The range of gyroscope
*
* values: {?}, default: ?
*/
GYROSCOPE_RANGE,
/**
* The parameter of accelerometer low pass filter
*
* values: {?}, default: ?
*/
ACCELEROMETER_LOW_PASS_FILTER,
/**
* The parameter of gyroscope low pass filter
*
* values: {?}, default: ?
*/
GYROSCOPE_LOW_PASS_FILTER,
/** Last guard */
LAST
};

View File

@ -64,6 +64,21 @@ int XuCamCtrlId(Option option) {
case Option::FRAME_RATE:
return 7;
break;
case Option::MIN_EXPOSURE_TIME:
return 8;
break;
case Option::ACCELEROMETER_RANGE:
return 9;
break;
case Option::GYROSCOPE_RANGE:
return 10;
break;
case Option::ACCELEROMETER_LOW_PASS_FILTER:
return 11;
break;
case Option::GYROSCOPE_LOW_PASS_FILTER:
return 12;
break;
default:
LOG(FATAL) << "No cam ctrl id for " << option;
}
@ -137,7 +152,10 @@ void Channels::UpdateControlInfos() {
for (auto &&option : std::vector<Option>{
Option::FRAME_RATE, Option::IMU_FREQUENCY, Option::EXPOSURE_MODE,
Option::MAX_GAIN, Option::MAX_EXPOSURE_TIME,
Option::DESIRED_BRIGHTNESS, Option::IR_CONTROL, Option::HDR_MODE})
Option::DESIRED_BRIGHTNESS, Option::IR_CONTROL, Option::HDR_MODE
Option::MIN_EXPOSURE_TIME, Option::ACCELEROMETER_RANGE,
Option::GYROSCOPE_RANGE, Option::ACCELEROMETER_LOW_PASS_FILTER,
Option::GYROSCOPE_LOW_PASS_FILTER})
{
control_infos_[option] = XuControlInfo(option);
}
@ -182,6 +200,11 @@ std::int32_t Channels::GetControlValue(const Option &option) const {
case Option::DESIRED_BRIGHTNESS:
case Option::IR_CONTROL:
case Option::HDR_MODE:
case Option::MIN_EXPOSURE_TIME:
case Option::ACCELEROMETER_RANGE:
case Option::GYROSCOPE_RANGE:
case Option::ACCELEROMETER_LOW_PASS_FILTER:
case Option::GYROSCOPE_LOW_PASS_FILTER:
return XuCamCtrlGet(option);
case Option::ZERO_DRIFT_CALIBRATION:
case Option::ERASE_CHIP:
@ -242,7 +265,12 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) {
case Option::MAX_EXPOSURE_TIME:
case Option::DESIRED_BRIGHTNESS:
case Option::IR_CONTROL:
case Option::HDR_MODE: {
case Option::HDR_MODE:
case Option::MIN_EXPOSURE_TIME:
case Option::ACCELEROMETER_RANGE:
case Option::GYROSCOPE_RANGE:
case Option::ACCELEROMETER_LOW_PASS_FILTER:
case Option::GYROSCOPE_LOW_PASS_FILTER: {
if (!in_range())
break;
XuCamCtrlSet(option, value);
@ -273,6 +301,11 @@ bool Channels::RunControlAction(const Option &option) const {
case Option::DESIRED_BRIGHTNESS:
case Option::IR_CONTROL:
case Option::HDR_MODE:
case Option::MIN_EXPOSURE_TIME:
case Option::ACCELEROMETER_RANGE:
case Option::GYROSCOPE_RANGE:
case Option::ACCELEROMETER_LOW_PASS_FILTER:
case Option::GYROSCOPE_LOW_PASS_FILTER:
LOG(WARNING) << option << " run action useless";
return false;
default:

View File

@ -22,7 +22,12 @@ const std::map<Model, CapabilitiesSupports> capabilities_supports_map = {
{Model::STANDARD, {Capabilities::STEREO_COLOR, Capabilities::IMU}}};
const std::map<Model, OptionSupports> option_supports_map = {
{Model::STANDARD, {Option::ERASE_CHIP}}};
{Model::STANDARD,
{Option::GAIN, Option::BRIGHTNESS, Option::CONTRAST, Option::EXPOSURE_MODE,
Option::MAX_EXPOSURE_TIME, Option::ERASE_CHIP, Option::MIN_EXPOSURE_TIME,
Option::ACCELEROMETER_RANGE, Option::GYROSCOPE_RANGE,
Option::ACCELEROMETER_LOW_PASS_FILTER,
Option::GYROSCOPE_LOW_PASS_FILTER}}};
const std::map<Model, std::map<Capabilities, StreamRequests>>
stream_requests_map = {

View File

@ -35,6 +35,8 @@ Motions::~Motions() {
void Motions::SetMotionCallback(motion_callback_t callback) {
motion_callback_ = callback;
if (motion_callback_) {
accel_range = channels_->GetControlValue(Option::ACCELEROMETER_RANGE);
gyro_range = channels_->GetControlValue(Option::GYROSCOPE_RANGE);
channels_->SetImuCallback([this](const ImuPacket &packet) {
if (!motion_callback_ && !motion_datas_enabled_) {
LOG(WARNING) << "";
@ -53,9 +55,9 @@ void Motions::SetMotionCallback(motion_callback_t callback) {
imu->temperature = seg.temperature / 326.8f + 25;
if (imu->flag == 1) {
imu->accel[0] = seg.aceel_or_gyro[0] * 12.f / 0x10000;
imu->accel[1] = seg.aceel_or_gyro[1] * 12.f / 0x10000;
imu->accel[2] = seg.aceel_or_gyro[2] * 12.f / 0x10000;
imu->accel[0] = seg.aceel_or_gyro[0] * 1.f * accel_range / 0x10000;
imu->accel[1] = seg.aceel_or_gyro[1] * 1.f * accel_range / 0x10000;
imu->accel[2] = seg.aceel_or_gyro[2] * 1.f * accel_range / 0x10000;
imu->gyro[0] = 0;
imu->gyro[1] = 0;
imu->gyro[2] = 0;
@ -63,9 +65,9 @@ void Motions::SetMotionCallback(motion_callback_t callback) {
imu->accel[0] = 0;
imu->accel[1] = 0;
imu->accel[2] = 0;
imu->gyro[0] = seg.aceel_or_gyro[0] * 1000.f / 0x10000;
imu->gyro[1] = seg.aceel_or_gyro[1] * 1000.f / 0x10000;
imu->gyro[2] = seg.aceel_or_gyro[2] * 1000.f / 0x10000;
imu->gyro[0] = seg.aceel_or_gyro[0] * 1.f * gyro_range / 0x10000;
imu->gyro[1] = seg.aceel_or_gyro[1] * 1.f * gyro_range / 0x10000;
imu->gyro[2] = seg.aceel_or_gyro[2] * 1.f * gyro_range / 0x10000;
} else {
imu->Reset();
}

View File

@ -57,6 +57,9 @@ class Motions {
bool is_imu_tracking;
std::mutex mtx_datas_;
int accel_range = 12;
int gyro_range = 1000;
};
MYNTEYE_END_NAMESPACE