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

AP_GPS_GSOF: Support GPS_RAW_DATA for external logging #25517

Open
Ryanf55 opened this issue Nov 11, 2023 · 15 comments
Open

AP_GPS_GSOF: Support GPS_RAW_DATA for external logging #25517

Ryanf55 opened this issue Nov 11, 2023 · 15 comments

Comments

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 11, 2023

Feature request

Is your feature request related to a problem? Please describe.

Right now, there is no way to enable the internal logging on the PX1 GNSS because the API is only available over the ethernet web UI. Internal logging is used for tech support to analyze system performance. Since PX1 has little flight hours on small fixed wing drones, this is particularly useful to have the ArduPilot community be able to supply logs.

Describe the solution you'd like

  • Consume GPS_RAW_DATA in AP_GPS_GSOF
  • Handle disabling logging on disarm, and log continuation on arm
  • Send enable logging/disable logging commands as appropriate
  • Stretch: Handle runtime param updates
  • Update wiki entry for PX1: https://github.com/ArduPilot/ardupilot_wiki/pull/5540/files
  • Create follow up issue for dealing with log data filling up and whether old logs are overwritten, the user is notified that logs are full, or something else

Describe alternatives you've considered

Connect laptop temporarily.

Platform
[ ] All
[ ] AntennaTracker
[ ] Copter
[ ] Plane
[ ] Rover
[ ] Submarine

Further details

The following binary data commands are what need to be sent for logging. There is no TransNumber, so just hard code these in the implementation file. If there is an ACK, parse the ACK.

Start Logging: 02 00 4C 09 08 44 45 46 41 55 4C 54 00 62 03 
Stop Logging: 02 00 4C 09 09 44 45 46 41 55 4C 54 00 63 03

Dependencies

The configuration ack/nack pattern from gsof-49-50 branch needs to be merged in before there is ability to do configuration responses. This ticket could be done without acks, however it will need to be changed.

@Ryanf55 Ryanf55 changed the title AP_GPS_GSOF: Support GPS_RAW_DATA AP_GPS_GSOF: Support GPS_RAW_DATA for external logging Nov 12, 2023
@abhinavs1920
Copy link

I would like to work on this issue. Please assign it to me.

@abhinavs1920
Copy link

Thanks for assigning this issue to me. I am working on it.

@Ryanf55
Copy link
Collaborator Author

Ryanf55 commented Nov 14, 2023

Thanks for assigning this issue to me. I am working on it.

Great. Let me know if you get stuck or are ready for a review.

@abhinavs1920
Copy link

Can you please provide me with some references or contexts about the AP_GPS library?

@Ryanf55
Copy link
Collaborator Author

Ryanf55 commented Nov 14, 2023

The wiki is very brief:
https://ardupilot.org/dev/docs/apmcopter-programming-libraries.html

The main interface for GPS is here: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_GPS/AP_GPS.h

This library follows the frontend-backend split.
https://ardupilot.org/dev/docs/code-overview-sensor-drivers.html#frontend-backend-split

Implementation that all GPS's follow is here:
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_GPS/AP_GPS.cpp

GSOF header file:
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_GPS/AP_GPS_GSOF.h

GSOF implementation:
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_GPS/AP_GPS_GSOF.cpp

For retrieving a parameter from the param server, you can do it like so:

const auto com_port = gps._com_port[state.instance].get();

Then, you need to write a validation function to ensure the user has not put a bogus value for the param, since param limits are not enforced:

AP_GPS_GSOF::validate_com_port(const uint8_t com_port) const {

For example, if a user sets GPS_RAW_DATA to a value of 99, the validation helper should return false.

Next, write the implementation of the logger configuration message, similar to requestBaud:

AP_GPS_GSOF::requestBaud(const HW_Port portindex)

The packet buffer structure was detailed on the initial issue description; seems like you can just hard code it as a constexpr buffer.

Make sure to calculate the checksum AFTER populating the transaction number buffer[4].

@kannishk
Copy link

kannishk commented Jan 5, 2024

Is this still open?

@Ryanf55
Copy link
Collaborator Author

Ryanf55 commented Jan 5, 2024

Is this still open?

Yep!

@shrey0303
Copy link

Hello, I was working on this issue, so I think the solution should follow as:

-> Get the GPS_RAW_DATA and validate as you mentioned
-> Then to handle enable/disable logging upon arm/disarm by fetching param1, if param1 = 1{AP_GPS_GSOF::requestBaud(const HW_Port portindex) and hard code as constexpr buffer and calculate checksum} else it writes nothing
Is it possible to directly add data log on flight controller memory using AP::logger().Write(Name,label......) instead of requestBaud function?
As I am willing to contribute but I am new to this project, plz provide the necessary feedback and guidance

@pulak-gautam
Copy link
Contributor

pulak-gautam commented Jan 7, 2024

@Ryanf55 The second last hexadecimal is supposed to be checksum right? Since 0x3 is an ending tag following how binary commands were handled in AP_GPS_GSOF::requestBaud
but, hexadecimals preceding don't add up to that in the preceeding binary commands given
for eg. in Start Logging: 02 00 4C 09 08 44 45 46 41 55 4C 54 00 62 03, 0x62 is csum but preceeding hex add up to 0x264. Could you please guide me as to where I am going wrong here?

@Ryanf55
Copy link
Collaborator Author

Ryanf55 commented Jan 7, 2024

@Ryanf55 The second last hexadecimal is supposed to be checksum right? Since 0x3 is an ending tag following how binary commands were handled in AP_GPS_GSOF::requestBaud but, hexadecimals preceding don't add up to that in the preceeding binary commands given for eg. Start Logging: 02 00 4C 09 08 44 45 46 41 55 4C 54 00 62 03 0x62 is csum but preceeding hex add up to 0x264. Could you please guide me as to where I am going wrong here?

The checksum is a uint8_t. We rely on natural overflow of the uint8_t for it to work. 0x264 larger than the max value of uint8_t. Also, the first 0x02 is also excluded.

@pulak-gautam
Copy link
Contributor

pulak-gautam commented Jan 19, 2024

@Ryanf55 I have mostly done the work described in this ticket. But, I have been stuck in implementing the arming/disarming scenarios. I tried scanning through the source code for doing this but still couldn't find the right method to call.

Could you help me out here, and point me in the right direction? (I am sorry for the delay, got involved in university work)

@Ryanf55
Copy link
Collaborator Author

Ryanf55 commented Jan 20, 2024

@Ryanf55 I have mostly done the work described in this ticket. But, I have been stuck in implementing the arming/disarming scenarios. I tried scanning through the source code for doing this but still couldn't find the right method to call.

Could you help me out here, and point me in the right direction? (I am sorry for the delay, got involved in university work)

Ah no worries, want to put what you have up for review in a pull request without the integration to arm/disarm? That's still quite useful, and could be merged after a review.

@pulak-gautam
Copy link
Contributor

@Ryanf55 I have put up what I did in the pull request #26042. Thanks

@Theonewhomadethings
Copy link
Contributor

Is there still room to contribute on this issue? @Ryanf55

@Ryanf55 Ryanf55 added the Driver label May 9, 2024
@Saloni-2005
Copy link

@Ryanf55 Hello Sir I want to contribute in GSoC through your organization and needed the guidance for the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants