Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic calibration controller (Der dessen name nicht genannt werden darf II) #798

Merged
merged 56 commits into from
Jul 7, 2024

Conversation

tuxbotix
Copy link
Contributor

@tuxbotix tuxbotix commented Apr 7, 2024

Introduced Changes

The current work in #695 mainly provides the calibration line detection and extracting measurements (although the PR originally meant to implement the integration too).

Whichever PR gets merged last, will connect the final integration (writing calibration results, validation, etc) or as a 3rd PR.

Depends on #1076 (for datatypes & workflow testing) - It can be decoupled if nessesary.
Fixes #131

State changes:

  • Controller's commands (blue thin stripe is "capture"
  • other two are vision cyclers, Yellow is "captured value" -> fake measurement generator randomly deciding to send or not.
    image

Workflow

The controller node tracks the state of the primary state and issues the calibration commands when the primary state is set to Calibrate.

Commands & State

  • Inactive
    • Do nothing when the primary state is anything other than Calibrate
    • Transition to Initialize when the primary state goes to Calibrate and also set the cycle time.
  • Initialize { started time }
    • Active during initialization, waits for initial_stabilization_delay until the robot finishes movement and stabilizes.
    • Once the timeout is reached, transition to LookAt with the stored LookAt command list. If nothing is found, jump to Processing phase.
  • LookAt { target, camera, dispatch_time }
    • Move the head to the given target.
    • Waits look_at_dispatch_waiting from dispatch_time to ensure the head movement is complete.
    • Once the timeout is complete, switch to 'Capture'
  • Capture { dispatch_time }
    • The vision node extracts measurements using the camera images. Shall do necessary filtering in this phase as well.
    • Waits until a measurement arrives with this information & stores it.
      • This may need improvements - See TODOs
    • Transition to the next LookAt once capture information arrives or jump to Processing if all look-at commands are executed.
  • Processing
    • Runs the solver, gets the results and persists to storage if satisfactory.
    • Transition to Finish once above is complete.
  • Finish
    • End state. Does nothing until exiting calibration primary phase.
    • Auto-change primary state??

ToDo / Known Issues

  • Verify that the use of PerceptionInput is correct
  • Handle when a measurement cannot be obtained from a given position (retry?, move to next look-at?
    • vision retries and says RetriesExceeded if it can't find any measurement.
    • If both cameras fail to find a measurement, it'll goto the next one.
  • Consider where to run the actual calibration processing -> on the node, on a future or a separate cycler
    • Done on the controller as of now, seems to be fast enough*
  • CalibrationCommand (also tracks state) could be improved.
    • Further actions added for Next Iterations
  • LookAt commands use a timeout to decide the end of the movement. Consider alternatives
    • Won't consider anything else for this PR
  • The initial phase (after activating calibration) uses a timeout (instead of checking if the pose is reached and stable). Consider alternatives
    • Won't consider anything else for this PR
  • Remove logging and replace with AdditionalOutputs
  • Nested match and if blocks could be made more elegant/ flatter
    • Done as much as I can. Reviewer could help!

Ideas for Next Iterations (Not This PR)

  • Make look-at commands configurable (got a fixed list for now)
  • Finalize the integration and include tests for the entire workflow.
  • Should consider adding camera to the capture command. (already done)
  • Decide on keeping the timeout for look-at or check for reaching the look-at status (joint value?)
  • Decide on keeping the timeout for initial to calibration start - might want to look at IMU, etc values for stability?
  • Should we automatically switch to Initial state after reaching Finish state in calibration?

How to Test

Webots or a NAO:

  • On Twix, subscribe to:
    • Control.main_outputs.calibration_command to look at the calibration phase
    • Control.main_outputs.primary_state to verify the transition from initial to calibration (useful for Webots)
  • Enter the calibration mode from Initial, (press ctrl + shift + x on webots for 1 second of "simulated time")
  • If on webots, pepsi run will print the state changes and measurement collection on the terminal

@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch from 31761f3 to 52633c0 Compare April 7, 2024 13:20
@tuxbotix tuxbotix marked this pull request as ready for review April 7, 2024 13:57
@tuxbotix tuxbotix enabled auto-merge April 7, 2024 13:57
@schmidma
Copy link
Member

schmidma commented May 5, 2024

This looks extremely wip, but resides in "Request for Review"... Do you expect of getting a review on your code in the current state? If not, please move to "In Progress"

@tuxbotix
Copy link
Contributor Author

tuxbotix commented May 6, 2024 via email

@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch from d2cc79e to b42a0ec Compare May 29, 2024 16:56
@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch 6 times, most recently from c795dfe to da1c1f0 Compare June 26, 2024 13:15
@tuxbotix
Copy link
Contributor Author

Fixed majority of the TODO/ WIP stuff. Works on Webots (Will test on a NAO today)

It would be great if a review can be done on this status to confirm the design choices and finalize this PR.

@tuxbotix tuxbotix added calibration:Automatic is:Dependent This is blocked because something else needs to happen first. labels Jun 26, 2024
@knoellle knoellle self-assigned this Jun 26, 2024
@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch 2 times, most recently from 8f74ca0 to 3442d67 Compare June 30, 2024 23:04
crates/types/src/calibration.rs Outdated Show resolved Hide resolved
crates/types/src/parameters.rs Outdated Show resolved Hide resolved
crates/types/src/calibration.rs Outdated Show resolved Hide resolved
crates/control/src/world_state_composer.rs Outdated Show resolved Hide resolved
crates/calibration/src/lines.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/control/src/calibration_controller.rs Outdated Show resolved Hide resolved
crates/types/src/calibration.rs Outdated Show resolved Hide resolved
crates/vision/src/calibration_measurement_provider.rs Outdated Show resolved Hide resolved
crates/types/src/calibration.rs Outdated Show resolved Hide resolved
crates/types/src/calibration.rs Outdated Show resolved Hide resolved
crates/types/src/calibration.rs Outdated Show resolved Hide resolved
@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch from 1abbc0f to b6b4a98 Compare July 2, 2024 15:12
@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch 2 times, most recently from 103e9bd to 354cbdd Compare July 3, 2024 11:15
@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch 3 times, most recently from 536db86 to b9045e1 Compare July 5, 2024 14:43
@tuxbotix tuxbotix force-pushed the feature/calibration_orchestrator branch from b9045e1 to 178155b Compare July 5, 2024 21:41
@knoellle knoellle added the RC24 label Jul 6, 2024
@knoellle
Copy link
Contributor

knoellle commented Jul 6, 2024

Apart from walking to positions on the field, this PR also seems to largely fix #127.

JackyBloxx and others added 4 commits July 7, 2024 00:53
* central_gamestate_timing

* rebase

* rebas

* add last_filtered_game_controller_state_change to filtered_game_controller_state

* rebase

* formating

* formating die 2te

* rebase fixes

* fix working now

* Format

* remove new lines

* format

---------

Co-authored-by: phillip kammradt <phillip.kammradt@tuhh>
Copy link
Contributor

@knoellle knoellle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, nu aber 😄
LGTM

@tuxbotix tuxbotix added this pull request to the merge queue Jul 7, 2024
Merged via the queue into HULKs:main with commit 9b9b9a9 Jul 7, 2024
25 checks passed
@tuxbotix tuxbotix deleted the feature/calibration_orchestrator branch July 7, 2024 12:54
oleflb pushed a commit to oleflb/hulk that referenced this pull request Jul 15, 2024
…n darf II) (HULKs#798)

* Initial work

* All compiles *except* getting the measurements from vision

* Make the controller to work

* Make the behaviour simulator happy

* Capture loop runs. Basic variety supports waiting for look-at.

* Fake data format

* Cleaner state handling

* Got rid of calibration_control crate

* Clippyfying

* SerializeHierarchy for Measurement

* Rename measurement provider

* Use naming "CalibrationCommand"

* Update last capture command time

* WIP

* Add missing fake data

* Extend timestamp checking to work properly.

* Start fake measurement

* Switch to center circle candidates and trigger calibration

* Additional output for debugging

* fix rebase

* All Woerks ;)

* parametrize all

* Change defaults

* Remove center circle calibration dependency

* Clean unused dependencies

* Import cleanups

* Fix serialisation mishaps and some other bits

* Fix a few more errors

* DOn't clone field_dimensions

* Review fixes, pass 1

* Woerks

* More cleaning

* Simplify the vision cycler

* Prettier fixes

* Fix for re-enabling calibration after finish state

* Reorder imports

* fix more
style issues

* Clean up state tracking

* destructure instead of match

* Simplify calibration command: pass 1

* Simplify calibration command: pass 2

* Cleaned up

* Replace From trait with a function that take &self

* Reduce visibility

* Fix malformed commet

* Apply suggestions

* Add copy trait

* Simplified things

* Make the big match smaller

* Copy trait changed things

* change headmotions for calibration

* Central gamestate timeing (HULKs#1006)

* central_gamestate_timing

* rebase

* rebas

* add last_filtered_game_controller_state_change to filtered_game_controller_state

* rebase

* formating

* formating die 2te

* rebase fixes

* fix working now

* Format

* remove new lines

* format

---------

Co-authored-by: phillip kammradt <phillip.kammradt@tuhh>

* Change head motion cases

* Use an inner struct to handle changing states

* Simplify calibration command -> calibration capture command

* Rename calibration command ;)

---------

Co-authored-by: JackyBlox <[email protected]>
Co-authored-by: phillip kammradt <phillip.kammradt@tuhh>
oleflb pushed a commit that referenced this pull request Sep 30, 2024
…n darf II) (#798)

* Initial work

* All compiles *except* getting the measurements from vision

* Make the controller to work

* Make the behaviour simulator happy

* Capture loop runs. Basic variety supports waiting for look-at.

* Fake data format

* Cleaner state handling

* Got rid of calibration_control crate

* Clippyfying

* SerializeHierarchy for Measurement

* Rename measurement provider

* Use naming "CalibrationCommand"

* Update last capture command time

* WIP

* Add missing fake data

* Extend timestamp checking to work properly.

* Start fake measurement

* Switch to center circle candidates and trigger calibration

* Additional output for debugging

* fix rebase

* All Woerks ;)

* parametrize all

* Change defaults

* Remove center circle calibration dependency

* Clean unused dependencies

* Import cleanups

* Fix serialisation mishaps and some other bits

* Fix a few more errors

* DOn't clone field_dimensions

* Review fixes, pass 1

* Woerks

* More cleaning

* Simplify the vision cycler

* Prettier fixes

* Fix for re-enabling calibration after finish state

* Reorder imports

* fix more
style issues

* Clean up state tracking

* destructure instead of match

* Simplify calibration command: pass 1

* Simplify calibration command: pass 2

* Cleaned up

* Replace From trait with a function that take &self

* Reduce visibility

* Fix malformed commet

* Apply suggestions

* Add copy trait

* Simplified things

* Make the big match smaller

* Copy trait changed things

* change headmotions for calibration

* Central gamestate timeing (#1006)

* central_gamestate_timing

* rebase

* rebas

* add last_filtered_game_controller_state_change to filtered_game_controller_state

* rebase

* formating

* formating die 2te

* rebase fixes

* fix working now

* Format

* remove new lines

* format

---------

Co-authored-by: phillip kammradt <phillip.kammradt@tuhh>

* Change head motion cases

* Use an inner struct to handle changing states

* Simplify calibration command -> calibration capture command

* Rename calibration command ;)

---------

Co-authored-by: JackyBlox <[email protected]>
Co-authored-by: phillip kammradt <phillip.kammradt@tuhh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
calibration:Automatic is:Dependent This is blocked because something else needs to happen first.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Control calibration node for automatic calibration
4 participants