Skip to content

Conversation

royzah
Copy link
Contributor

@royzah royzah commented Nov 7, 2024

Description

This PR refactors the UTMSPServiceController::networkRemoteID method to improve telemetry control logic:

  • Removes position-based telemetry control logic
  • Adds state-based control using MAV_STATE from HEARTBEAT messages
  • Telemetry now starts when vehicle is in MAV_STATE_ACTIVE state
  • Telemetry stops when vehicle transitions out of MAV_STATE_ACTIVE state
  • Simplifies code flow and removes unnecessary position comparisons

Test Steps

  1. Connect vehicle to QGC
  2. Setup UTM Network Remote ID parameters (serialNumber, operatorID, flightID)
  3. Verify telemetry starts when vehicle enters MAV_STATE_ACTIVE
  4. Verify telemetry continues at 3Hz while in MAV_STATE_ACTIVE
  5. Verify telemetry stops when vehicle exits MAV_STATE_ACTIVE state
  6. Check logs to confirm proper state transitions and telemetry behavior

Checklist:

Related Issue

N/A

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@HTRamsey
Copy link
Collaborator

Does this actually build when UTMSP is enabled? It looks like you are using variables that don't exist and staticcast should be static_cast

@royzah
Copy link
Contributor Author

royzah commented Nov 21, 2024

Hey @HTRamsey ,

Thanks a ton for catching that!

Yep, it does build with UTMSP enabled. The issues you pointed out were because my code formatter was randomly stripping out some underscores (_) when I saved the file. This messed up the variable names and turned static_cast into staticcast. I’ve fixed the formatter settings and cleaned up the code to use the correct variable names and static_cast.

Here’s a quick look at what changed:

Before
mavlink_global_position_int_t globalPosition;
mavlink_msg_global_position_int_decode(&message, &globalPosition);
vehicleLatitude = staticcast<double>(globalPosition.lat) / 1e7;
vehicleLongitude = staticcast<double>(globalPosition.lon) / 1e7;
vehicleAltitude = staticcast<double>(globalPosition.alt) / 1000;

After
mavlink_global_position_int_t globalPosition;
mavlink_msg_global_position_int_decode(&message, &globalPosition);
_vehicleLatitude = static_cast<double>(globalPosition.lat) / 1e7;
_vehicleLongitude = static_cast<double>(globalPosition.lon) / 1e7;
_vehicleAltitude = static_cast<double>(globalPosition.alt) / 1000;

@HTRamsey
Copy link
Collaborator

I don't know much about this code, but it looks good to me. Will merge along with my UTMSP singleton PR

@HTRamsey HTRamsey merged commit 9cf3dde into mavlink:master Nov 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants