Skip to content

AP_Scripting: update docs file to be more comprehensive #30504

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andyp1per
Copy link
Contributor

No description provided.

@andyp1per andyp1per requested a review from IamPete1 June 28, 2025 09:40
Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

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

Chat-GPT strikes again?

It certainty would be nice to get everything fully documented. But we have to make sure its documented correctly. I have only reviewed a small part of this, quite a bit of it is just wrong. I'm happy to work with you to get this across the line but I'm not interested in spending several hours reviewing PRs that were generated in 5 mins using AI.

---@return integer
function uint32_t_ud:toint() end

--- Custom 64-bit unsigned integer userdata type.
-- Essential for high-resolution timestamps (like from `micros()`) or large IDs where standard Lua numbers would lose precision.
Copy link
Member

Choose a reason for hiding this comment

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

micros returns uint32. This is used in utc epoch from the gps, and a few places in DroneCAN.

---@return uint32_t_ud -- microseconds
-- Returns the system time in microseconds since the autopilot booted.
-- This should be stored in a uint64_t_ud to avoid precision loss.
---@return uint64_t_ud -- Microseconds since boot.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
---@return uint64_t_ud -- Microseconds since boot.
---@return uint32_t_ud -- Microseconds since boot.

-- Prints text to the GCS and connected peripherals.
-- If a MAVLink GCS is connected, this is equivalent to `gcs:send_text(MAV_SEVERITY.DEBUG, text)`.
-- If the script is running on a peripheral, the text will be sent over the CAN bus.
---@param text string|number|integer -- The content to be printed. Non-string types will be converted to strings.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we convert none strings? I might be worth testing, our print is not a nice as the built in print.

---@param ... integer|number|uint32_t_ud|string|boolean -- data to be logged, type to match format string
-- Writes a custom log entry to the dataflash log with full formatting options. A timestamp is automatically added.
-- Example from `revert_param.lua`: `logger:write('QUIK','SRate,Gain,Param', 'ffn', srate, P:get(), axis .. stage)`
---@param name string -- A unique name for the log entry, must be 4 characters or less to avoid conflicts.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
---@param name string -- A unique name for the log entry, must be 4 characters or less to avoid conflicts.
---@param name string -- A unique name for the log entry, must be 4 characters or less.

-- Example from `revert_param.lua`: `logger:write('QUIK','SRate,Gain,Param', 'ffn', srate, P:get(), axis .. stage)`
---@param name string -- A unique name for the log entry, must be 4 characters or less to avoid conflicts.
---@param labels string -- Comma-separated labels for the data fields, up to 58 characters. E.g., "Lat,Lon,Alt".
---@param format string -- A format string defining the data types of the values. See https://ardupilot.org/dev/docs/code-overview-logger.html for format specifiers.
Copy link
Member

Choose a reason for hiding this comment

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

This URL does not exist.

---@class (exact) EFI_State_ud
local EFI_State_ud = {}

---@return EFI_State_ud
function EFI_State() end

-- get field
-- get field: Pressure/Temperature compensation for the engine.
---@return number
function EFI_State_ud:pt_compensation() end

-- set field
Copy link
Member

Choose a reason for hiding this comment

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

set description should match that for get.

---@return number
function EFI_State_ud:fuel_consumption_rate_cm3pm() end

-- set field
---@param value number
function EFI_State_ud:fuel_consumption_rate_cm3pm(value) end

-- get field
-- get field: The current fuel pressure, typically in kPa.
Copy link
Member

Choose a reason for hiding this comment

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

not typicaly, always in kPa.

@@ -233,87 +244,87 @@ function EFI_State_ud:fuel_pressure_status() end
---| '3' # Above nominal
function EFI_State_ud:fuel_pressure_status(status) end

-- get field
-- get field: The engine oil temperature, typically in degrees Celsius.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-- get field: The engine oil temperature, typically in degrees Celsius.
-- get field: The engine oil temperature, kelvin.

---@return number
function EFI_State_ud:oil_temperature() end

-- set field
---@param value number
function EFI_State_ud:oil_temperature(value) end

-- get field
-- get field: The engine oil pressure, typically in kPa.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-- get field: The engine oil pressure, typically in kPa.
-- get field: The engine oil pressure, in kPa.

---@return number
function EFI_State_ud:oil_pressure() end

-- set field
---@param value number
function EFI_State_ud:oil_pressure(value) end

-- get field
-- get field: The engine coolant temperature, typically in degrees Celsius.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-- get field: The engine coolant temperature, typically in degrees Celsius.
-- get field: The engine coolant temperature, kelvin.

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