-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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_Scripting: added external AHRS scripting backend #25678
base: master
Are you sure you want to change the base?
Conversation
2449236
to
a678c75
Compare
1fb033a
to
6886d61
Compare
6886d61
to
201ebb4
Compare
3a6febc
to
8349741
Compare
8349741
to
fa4132c
Compare
fa4132c
to
49fa0b1
Compare
49fa0b1
to
3e45c6e
Compare
Why do we need the drivers for the anything other than external AHRS? Currently the external AHRS lib already populates all the libraries directly with the existing drivers? Why does the scripting driver need to publish via external AHRS and directly to the sensor driver? |
no, it doesn't, it is the individual backends that do that, not the library itself. It really needs to be this way as the backend knows what makes sense to publish and can have more details that the frontend knows (eg. backend usually knows the GPS details, frontend only knows the estimator solution) |
Currently this tells external AHRS the accel and gyro and then passes the same information to the INS lib. Why not just pass the information to AHRS and have it pass on to the INS lib rather than doing it in the script? There is not the duplication for the other sensors, but you could include them in the state, or have new function that passes though to the sensor lib. My concern is more really about the code structure and the data flow. Its useful for all the data to flow the same way between all the different back-ends. It makes testing and debugging easier if there are few "entry points" for the data from the script. I guess the counter argument is that the script itself is a external AHRS back end so it is the same as the others. I think I would tend to make the distinction at the scripting bindings, the script itself is part of the external AHRS unit not part of AP. Some use UART to get the data into AP, the scripting back end used the scripting bindings. |
this is by design, and is quite important. |
3e45c6e
to
81b691e
Compare
state.velocity = _state.velocity; | ||
} | ||
|
||
if (_state.have_origin && !state.have_origin) { |
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.
This confused me for a few moments, that extra _
is a bit subtle. Maybe new_state
rather than _state
?
local mag_data_message_t_ud = {} | ||
|
||
---@return mag_data_message_t_ud | ||
function mag_data_message_t() end |
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.
It might be worth a rename on this, its the creation function so you would have to rename the whole object.
Its a little late now, but I wonder it we would have been better to namespace these userdata. Currently you do:
data = mag_data_message_t()
We could name space it so the creation is not global:
data = compass:mag_data_message_t()
|
||
-- set field | ||
---@param value Vector3f_ud | ||
function mag_data_message_t_ud:field(value) end |
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 generator gives you a default description all of the user data fields "set field" or "get field". So I think have a field called "field" is confusing. Maybe the object could be compass_data_message
and the filed mag_field
.
---@param value number | ||
function gps_data_message_t_ud:ned_vel_down(value) end | ||
|
||
-- set field | ||
---@param value number | ||
function gps_data_message_t_ud:ned_vel_east(value) end | ||
|
||
-- set field | ||
---@param value number | ||
function gps_data_message_t_ud:ned_vel_north(value) end |
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.
Why not a vector 3? Or a vector 2 for north/east and a float for down?
|
||
-- set field | ||
---@param value integer | ||
function gps_data_message_t_ud:satellites_in_view(value) end |
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.
This is quite verbose, some of the others are really not. "vdop", "ms_tow".
@@ -95,6 +95,7 @@ singleton AP_BattMonitor method get_cell_voltage boolean uint8_t'skip_check uint | |||
include AP_GPS/AP_GPS.h | |||
|
|||
singleton AP_GPS depends (AP_GPS_ENABLED && (!defined(HAL_BUILD_AP_PERIPH) || defined(HAL_PERIPH_ENABLE_GPS))) | |||
singleton AP_GPS semaphore |
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.
Adding the semaphore at this point mean that all the methods call it. Why not just add it in the cpp for the handle_external
function? Like wise for all the others.
include AP_Airspeed/AP_Airspeed.h | ||
singleton AP_Airspeed depends (AP_AIRSPEED_EXTERNAL_ENABLED == 1) && (APM_BUILD_TYPE(APM_BUILD_ArduPlane)||APM_BUILD_COPTER_OR_HELI) | ||
singleton AP_Airspeed semaphore | ||
singleton AP_Airspeed rename airspeed |
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 amazed airspeed
is not used a local variable in any of our example scripts. But this might conflict with scripts in the wild.
I think its OK because the local variable with overwrite the global so the script will work, just not the this new lib, but it might be worth checking, would also be interesting to see if luacheck would catch it.
81b691e
to
4d1a0d7
Compare
4d1a0d7
to
06a71a5
Compare
this prevents an unhealthy error due to no change
and a common implementation of mavlink message send
common logging for all EAHRS backends
06a71a5
to
4463e46
Compare
This allows lua scripts to provide the following backends:
It builds on top of #25674 and re-implements the InertialLabs driver as a lua script
also builds on: