Skip to content

Commit

Permalink
Merge pull request #84 from funnbot/pr/fix-calib-timeout
Browse files Browse the repository at this point in the history
Fix calib timeout
  • Loading branch information
ju1ce authored Aug 24, 2022
2 parents fecaaf8 + 1095ab5 commit d4f05eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 36 deletions.
5 changes: 0 additions & 5 deletions AprilTagTrackers/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ void GUI::SetManualCalibVisible(bool visible)
ForwardToMainThread(impl, &MainFrame::SetManualCalibVisible, std::move(visible));
}

void GUI::SaveManualCalib()
{
ForwardToMainThread(impl, &MainFrame::SaveManualCalib);
}

PreviewControl::PreviewControl(RefPtr<GUI> _gui, PreviewId _id)
: gui(_gui), id(_id)
{
Expand Down
2 changes: 0 additions & 2 deletions AprilTagTrackers/GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class GUI
void SetManualCalib(const ManualCalib::Real& calib);
/// Set if the manual calib window is visible.
void SetManualCalibVisible(bool visible = true);
/// Save manual calib to user config
void SaveManualCalib();

/// Defined in GUI/MainFrame.h, but used as opaque ptr, not to be included in headers.
class MainFrame;
Expand Down
45 changes: 19 additions & 26 deletions AprilTagTrackers/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ bool GUI::MainFrame::IsPreviewVisible(PreviewId id)

ManualCalib::Real GUI::MainFrame::GetManualCalib()
{
return manualCalib.GetAsReal();
return config.manualCalib.GetAsReal();
}

void GUI::MainFrame::SetManualCalib(const ManualCalib::Real& calib)
{
manualCalib.SetFromReal(calib);
config.manualCalib.SetFromReal(calib);

using Clock = std::chrono::steady_clock;
static Clock::time_point lastUpdate = Clock::now();
Expand All @@ -123,22 +123,20 @@ void GUI::MainFrame::SetManualCalib(const ManualCalib::Real& calib)
void GUI::MainFrame::SetManualCalibVisible(bool visible)
{
manualCalibForm->SetSizerVisible(visible);
// can be called from checkbox event, SetValue won't trigger another event
manualCalibCheckBox->SetValue(visible);
if (visible)
{
manualCalib = config.manualCalib;
manualCalibForm->Update();
Fit();
}
else
{
config.Save();
}
tracker->manualRecalibrate = visible;
}

void GUI::MainFrame::SaveManualCalib()
{
config.manualCalib = manualCalib;
config.Save();
}

void GUI::MainFrame::OnNotebookPageChanged(wxBookCtrlEvent& evt)
{
RefPtr<wxNotebook> nb = static_cast<wxNotebook*>(evt.GetEventObject());
Expand Down Expand Up @@ -249,34 +247,29 @@ void GUI::MainFrame::CreateCameraPage(RefPtr<wxNotebook> pages)
cam.AddGet(CheckBoxButton{lc.CAMERA_CALIBRATION_MODE,
[this](auto& evt)
{
bool checked = evt.IsChecked();
SetManualCalibVisible(checked);
if (!checked)
{
SaveManualCalib();
}
SetManualCalibVisible(evt.IsChecked());
}})
->GetWidget();

manualCalibForm = cam.PopSizer().SubForm();

manualCalibForm->PushSizer<wxBoxSizer>(wxVERTICAL)
.Add(Label{lc.CAMERA_CALIBRATION_INSTRUCTION})
.Add(Labeled{lc.calib.X, InputNumber{manualCalib.posOffset[0]}})
.Add(Labeled{lc.calib.Y, InputNumber{manualCalib.posOffset[1]}})
.Add(Labeled{lc.calib.Z, InputNumber{manualCalib.posOffset[2]}})
.Add(Labeled{lc.calib.PITCH, InputNumber{manualCalib.angleOffset[0]}})
.Add(Labeled{lc.calib.YAW, InputNumber{manualCalib.angleOffset[1]}})
.Add(Labeled{lc.calib.ROLL, InputNumber{manualCalib.angleOffset[2]}})
.Add(Labeled{lc.calib.SCALE, InputNumber{manualCalib.scale}})
.Add(CheckBoxButton{ lc.CAMERA_MULTICAM_CALIB, [this](auto& evt)
.Add(Labeled{lc.calib.X, InputNumber{config.manualCalib.posOffset[0]}})
.Add(Labeled{lc.calib.Y, InputNumber{config.manualCalib.posOffset[1]}})
.Add(Labeled{lc.calib.Z, InputNumber{config.manualCalib.posOffset[2]}})
.Add(Labeled{lc.calib.PITCH, InputNumber{config.manualCalib.angleOffset[0]}})
.Add(Labeled{lc.calib.YAW, InputNumber{config.manualCalib.angleOffset[1]}})
.Add(Labeled{lc.calib.ROLL, InputNumber{config.manualCalib.angleOffset[2]}})
.Add(Labeled{lc.calib.SCALE, InputNumber{config.manualCalib.scale}})
.Add(CheckBoxButton{lc.CAMERA_MULTICAM_CALIB, [this](auto& evt)
{
tracker->multicamAutocalib = evt.IsChecked();
} })
.Add(CheckBoxButton{ lc.CAMERA_LOCK_HEIGHT, [this](auto& evt)
}})
.Add(CheckBoxButton{lc.CAMERA_LOCK_HEIGHT, [this](auto& evt)
{
tracker->lockHeightCalib = evt.IsChecked();
} });
}});

manualCalibForm->SetSizerVisible(false);
}
Expand Down
3 changes: 0 additions & 3 deletions AprilTagTrackers/GUI/MainFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class GUI::MainFrame : protected wxFrame
void SetManualCalib(const ManualCalib::Real& calib);
/// Set if the manual calib window is visible.
void SetManualCalibVisible(bool visible = true);
/// Save manual calib to user config.
void SaveManualCalib();

private:
void OnCloseWindow();
Expand All @@ -76,7 +74,6 @@ class GUI::MainFrame : protected wxFrame
/// Reference to params sub form
RefPtr<Form::FormBuilder> manualCalibForm;
RefPtr<wxCheckBox> manualCalibCheckBox;
ManualCalib manualCalib{};

std::array<PreviewFrame, 2> previews;
};
Expand Down

0 comments on commit d4f05eb

Please sign in to comment.