-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Add Statespace model support to SITL #29462
base: master
Are you sure you want to change the base?
Conversation
@@ -528,6 +541,7 @@ def options_for_frame(self, frame, vehicle, opts): | |||
if frame.startswith(p): | |||
ret = self.options[vehicle]["frames"][p] | |||
break | |||
print("ret is (%s)" % ret) |
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 debug?
const char *colon = strchr(frame_str, ':'); | ||
size_t slen = strlen(frame_str); | ||
if (colon != nullptr && slen > 5 && strcmp(&frame_str[slen-5], ".json") == 0) { | ||
load_frame_params(colon+1); | ||
} |
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 saw this function in Plane too; the part that finds a colon and a string ending in .json
. Do you think there is a way to refactor this and reuse it?
Something like bool is_json_frame(const char *fram_str)
if (model.coll_max - model.coll_min > 0.0f) { | ||
hover_coll = (model.coll_hover - model.coll_min) / (model.coll_max - model.coll_min); | ||
} | ||
float servos_raw[16]; |
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.
Is there a define we could use for the max servos? I thought certain versions of AP support 32.
float Dlatlag_dot = (-model.Lag)*(Dlatlag)+(model.Lag)*(_roll_in); | ||
float Dlonlag_dot = (-model.Lag)*(Dlonlag)+(model.Lag)*(_pitch_in); | ||
float Dcollag_dot = (-model.Lag)*(Dcollag)+(model.Lag)*(_throttle_in); | ||
float Dpedlag_dot = (-model.Lag)*(Dpedlag)+(model.Lag)*(_yaw_in); |
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.
Some of these locals could be const.
rot_accel.y = (model.Mu)*(velocity_air_bf.x)+(model.Mlon)*(Dlonlag); | ||
rot_accel.z = (model.Nr)*(gyro.z)+((model.Nped)-(model.Lag*model.Lead))*(Dpedlag)+(model.Lag*model.Lead)*(_yaw_in); | ||
|
||
float lateral_y_thrust = (model.Yv)*(velocity_air_bf.y)+(model.Ylat)*(Dlatlag); |
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.
Perhaps run astyle on the code? Some operators have space around them, others don't.
|
||
// ramp speed estimate towards control out | ||
float runup_increment = dt / runup_time; | ||
if (motor_status > 2) { |
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.
Is there an enum for the status?
This PR adds a separate model to SITL to support state space models. It currently supports multirotor and helicopter models. It also uses JSON files for model parameter inputs. This allows anyone to use their own state space dynamic model without having to modify the SITL code.