-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 SCR_THD_PRIORITY #25686
Conversation
7e86001
to
8e05b41
Compare
This make me a little nervous in that people might change it without understanding properly. With increased priority it becomes possible for the script to prevent the flight code from doing its stuff. Maybe once the current scripting priority is not sufficient that is a good sign that the functionality really should be in the C++. I am a bit surprised this is needed, on H7 I have done lots of quite heavy things without issue, although in those cases I was not chasing timing. |
thus the warnings in the parameter docs
that is why is did this particular driver, I did a C++ and a lua version of the same protocol. The C++ one is much faster and of course has no timing issues. The lua one works without this change, but we get frequent timing issues where the sensor data is delayed. With the SCR_THD_PRIORITY set to 5 I get no timing issues. |
@@ -132,6 +132,14 @@ const AP_Param::GroupInfo AP_Scripting::var_info[] = { | |||
// @User: Advanced | |||
AP_GROUPINFO("DIR_DISABLE", 9, AP_Scripting, _dir_disable, 0), | |||
|
|||
// @Param: THD_PRIORITY | |||
// @DisplayName: Scripting thread priority | |||
// @Description: This sets the priority of the scripting thread. This is normally set to a low priority to prevent scripts from interfering with other parts of the system. Advanced users can change this priority if scripting needs to be prioritised for realtime applications. WARNING: changing this parameter can impact the stability of your flight controller. The scipting thread priority in this parameter is chosen based on a set of system level priorities for other subsystems. It is strongly recommended that you use the lowest priority that is sufficient for your application. Note that all scripts run at the same priority, so if you raise this priority you must carefully audit all lua scripts for behaviour that does not interfere with the operation of the system. |
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: normally we don't add "this sets" or "this controls" at the front of parameter descriptions because really all parameters "set" or "control" something. I'd shorten the first sentence to simply, "Priority of the scripting thread"
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.
seems OK to me.
8e05b41
to
4498e51
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.
Looks good.
this makes it possible to run lua scripts at higher priorities, which makes real time lua scripts (such as IMU drivers) possible
4498e51
to
94d3e99
Compare
this makes it possible to run lua scripts at higher priorities, which makes real time lua scripts (such as IMU drivers) possible
Tested with a 200Hz external AHRS driver over a UART
broken out from #25678