-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
AHRS: add ability to configure AHRS via mavlink commands #28485
base: master
Are you sure you want to change the base?
Conversation
Nice. If you can, feel free to add one such packet so that this code is used by a driver. |
b19d652
to
c4ca633
Compare
Linked PR in MAVLink repo: |
5f30de1
to
8faccc4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have something at the AHRS-backend level rather than at the EAHRS level for this. Turning GNSS off is a thing for EKF3, for example, just not in master right now.
@peterbarker , where can I find the code you were talking about (Turning GNSS off for EKF3)? I looked through the branches in the repository and requests, but I couldn't find it |
Check the code path of aux function 65 "GPS Disable": https://ardupilot.org/copter/docs/common-auxiliary-functions.html |
Did I get the idea right, you want to see something like this? |
yea, this is nice and portable between the EARHS drivers. Just making sure for commands we have a way to undo them (ie turn GNSS on/off in flight to test dead reckoning) |
Yes, we used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, yea I'm overall on board with the approach here. I haven't tested it yet.
#if AP_AHRS_EXTERNAL_ENABLED | ||
case EKFType::EXTERNAL: | ||
return external.set_gnss_state(enabled); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code paths that aux function 105 takes could be used to disable GPS in EKF2/3.
105
Not required for the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll create a next request with these changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll create a next request with these changes
... not sure I understand this response.
We have an existing mechanism for enabling/disabling gnss use, we should use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that I understood what I need right, but I added the GPS disabling for EKF2/3
This is looking nicer than the write-bytes approach. I'm going to mark this for DevCall for discussion. |
Nothing to add from me, I'm in favor of this change and believe it sets up a nice pattern for adding future generic commands to the EKF/EAHRS. |
#if AP_AHRS_EXTERNAL_ENABLED | ||
case EKFType::EXTERNAL: | ||
return external.set_gnss_state(enabled); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll create a next request with these changes
... not sure I understand this response.
We have an existing mechanism for enabling/disabling gnss use, we should use it here.
bool AP_ExternalAHRS::write_bytes(const char *bytes, uint8_t len) | ||
{ | ||
if (!backend) { | ||
return false; | ||
} | ||
return backend->write_bytes(bytes, len); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -121,6 +121,9 @@ class AP_ExternalAHRS { | |||
bool get_accel(Vector3f &accel); | |||
void send_status_report(class GCS_MAVLINK &link) const; | |||
bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const; | |||
void set_data_sending_state(bool enabled); | |||
void set_gnss_state(bool enabled); | |||
bool write_bytes(const char *bytes, uint8_t len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -220,6 +220,9 @@ class AP_ExternalAHRS_InertialLabs : public AP_ExternalAHRS_backend { | |||
void update_thread(); | |||
bool check_uart(); | |||
bool check_header(const ILabsHeader *h) const; | |||
bool write_bytes(const char *bytes, uint8_t len) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer an override; should be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -42,6 +42,9 @@ class AP_ExternalAHRS_backend { | |||
virtual bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const = 0; | |||
virtual void get_filter_status(nav_filter_status &status) const {} | |||
virtual bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const { return false; } | |||
virtual void set_data_sending_state(bool enabled) {} | |||
virtual void set_gnss_state(bool enabled) {} | |||
virtual bool write_bytes(const char *bytes, uint8_t len) { return false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual bool write_bytes(const char *bytes, uint8_t len) { return false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
libraries/GCS_MAVLink/GCS_Common.cpp
Outdated
{ | ||
switch (packet.command) { | ||
case MAV_CMD_AHRS_START: | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ |
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
void AP_ExternalAHRS_InertialLabs::set_data_sending_state(bool enabled) | ||
{ | ||
if (enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: bracket should be on the same line as the if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hi @valbv, Thanks for this. What's the purpose of disabling an EAHRS? I guess it's to test a complete failure of the external AHRS system? I wonder what testing has been done for this? |
@@ -137,4 +137,14 @@ void AP_AHRS_External::get_control_limits(float &ekfGndSpdLimit, float &ekfNavVe | |||
ekfNavVelGainScaler = 0.5; | |||
} | |||
|
|||
void AP_AHRS_External::set_data_sending_state(bool enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's put some comments above the methods..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To elaborate, at minimum, copy the comments across all the headers. Although the clasess inherit/override methods, not everyone's editor propogates the description, so AP generally copies comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
libraries/AP_AHRS/AP_AHRS_External.h
Outdated
@@ -87,6 +87,9 @@ class AP_AHRS_External : public AP_AHRS_Backend { | |||
void send_ekf_status_report(class GCS_MAVLINK &link) const override; | |||
|
|||
void get_control_limits(float &ekfGndSpdLimit, float &controlScaleXY) const override; | |||
|
|||
void set_data_sending_state(bool enabled) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments here too would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
More comments would be nice, there are very few which makes it difficult to review but also it will be even more difficult for future developers trying to figure out how to use the various methods |
It's for the ability to send commands to EAHRS like "Enable/Disable GNSS", "Start/Stop magnitometer calibration in flight" and everything that device can receive