Skip to content

Log message on robot mode changes#1923

Merged
mcm001 merged 4 commits intoPhotonVision:mainfrom
mcm001:fms-state-pub
Apr 19, 2025
Merged

Log message on robot mode changes#1923
mcm001 merged 4 commits intoPhotonVision:mainfrom
mcm001:fms-state-pub

Conversation

@mcm001
Copy link
Contributor

@mcm001 mcm001 commented Apr 19, 2025

Description

Log messages to the logger immediately at startup and then every time the value changes using a NT listener.

Add startup:

[2025-04-19 09:29:00] [NetworkTables - NTDriverStation] [INFO] ROBOT TRANSITIONED MODES! From NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=false, m_dsAttached=false] to NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=false, m_dsAttached=false]

At connect to roborio

[2025-04-19 09:29:00] [NetworkTables - NTDriverStation] [INFO] ROBOT TRANSITIONED MODES! From NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=false, m_dsAttached=false] to NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=false, m_dsAttached=false]

On transition to disabled, with FMS attached

[2025-04-19 09:29:54] [NetworkTables - NTDriverStation] [INFO] ROBOT TRANSITIONED MODES! From NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=false, m_dsAttached=false] to NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=true, m_dsAttached=true]

On transition to autonomous

[2025-04-19 09:30:14] [NetworkTables - NTDriverStation] [INFO] ROBOT TRANSITIONED MODES! From NtControlWord[m_enabled=false, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=true, m_dsAttached=true] to NtControlWord[m_enabled=true, m_autonomous=true, m_test=false, m_emergencyStop=false, m_fmsAttached=true, m_dsAttached=true]

On transition to teleop

[2025-04-19 09:31:06] [NetworkTables - NTDriverStation] [INFO] ROBOT TRANSITIONED MODES! From NtControlWord[m_enabled=true, m_autonomous=true, m_test=false, m_emergencyStop=false, m_fmsAttached=true, m_dsAttached=true] to NtControlWord[m_enabled=true, m_autonomous=false, m_test=false, m_emergencyStop=false, m_fmsAttached=true, m_dsAttached=true]

I left some comments about potential data races. I haven't had issues yet.

Meta

Merge checklist:

  • Pull Request title is short, imperative summary of proposed changes
  • The description documents the what and why
  • If this PR changes behavior or adds a feature, user documentation is updated
  • If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly
  • If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1
  • If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated
  • If this PR addresses a bug, a regression test for it is added

@crschardt
Copy link
Contributor

Very good addition. Is it possible to include match time too?

@mcm001
Copy link
Contributor Author

mcm001 commented Apr 19, 2025

If that's in NT, yeah absolutely

@mcm001
Copy link
Contributor Author

mcm001 commented Apr 19, 2025

Copy link
Contributor Author

@mcm001 mcm001 left a comment

Choose a reason for hiding this comment

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

Let's also publish with it match number/type/event name/etc?

Copy link
Contributor

@crschardt crschardt left a comment

Choose a reason for hiding this comment

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

Added. It's logging the match info on each mode change (if the data is available). I can change that if you would prefer only logging once when the data becomes available.

@mcm001
Copy link
Contributor Author

mcm001 commented Apr 19, 2025

This seems reasonable to me! Net positive and no net negative to this afaict. Thank you!!

@mcm001 mcm001 enabled auto-merge (squash) April 19, 2025 23:19
Copy link
Contributor Author

@mcm001 mcm001 left a comment

Choose a reason for hiding this comment

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

Obama.png

Copy link
Contributor

@crschardt crschardt left a comment

Choose a reason for hiding this comment

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

I can't test it without an FMS or some hack to publish match data to NT. (lol) Any suggestions?

@mcm001 mcm001 merged commit 089233f into PhotonVision:main Apr 19, 2025
39 checks passed
@mcm001 mcm001 deleted the fms-state-pub branch April 19, 2025 23:45
@mcm001
Copy link
Contributor Author

mcm001 commented Apr 19, 2025

We could test using one of our photonlib examples running a robot sim, which will publish to FMSInfo. I could have added unit tests but its hard to make assertions against console output and I'm lazy.

@mcm001 mcm001 mentioned this pull request Apr 20, 2025
samfreund pushed a commit to samfreund/photonvision that referenced this pull request Jun 28, 2025
@Gold856 Gold856 added the enhancement New feature or request label Jul 12, 2025
@Gold856 Gold856 added the backend Things relating to photon-core and photon-server label Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Things relating to photon-core and photon-server enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants