-
Notifications
You must be signed in to change notification settings - Fork 6
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
Adcs controllers and main pointing strategy #92
Conversation
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.
For the most part looks really good. I left a couple miscellaneous questions. I think my largest concern is some slight divergence from where I think the flight computer implementations of the controllers may have been going (particularly the pointer state's PD buffer).
I just want to make sure we're one the same page about the internals of the MATLAB controllers and CXX controllers so we don't have any issues integrating the CXX functions into MATLAB (which I plan on doing once the full suite of attitude controllers is complete).
Let me know what you think!
@stewartaslan for awareness.
MATLAB/config.m
Outdated
@@ -70,6 +70,7 @@ | |||
% Torque on fuel/difference in angular rates in eci Nm/(rad/s). | |||
const.ATTITUDE_PD_KP = 75e-4; % imported from simulink | |||
const.ATTITUDE_PD_KD = 32.5e-4; % imported from simulink | |||
const.ATTITUDE_PD_derivative_buffer_size=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.
Will we need this for the flight algorithm you think? We're already buffering w_body
in the estimation step.
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, I wanted to have way to point even if quat_body_eci
was NaN. Before, the derivative term was just the gyro, but I wanted to see what would happen if I just did finite differences.
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.
Though I guess this basically doing the same thing as estimating w_body
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.
Ah okay. But in terms of the sorta version 1.0 of the GNC algorithms we're good keeping the finite difference estimation in the estimator and no buffer in the controller?
target_position_eci= other_satellite_state.dynamics.position_eci; | ||
sensor_readings.target_position_ecef= utl_rotateframe(quat_ecef_eci,target_position_eci); | ||
target_velocity_eci= other_satellite_state.dynamics.velocity_eci; | ||
sensor_readings.target_velocity_ecef= utl_rotateframe(quat_ecef_eci, target_velocity_eci)-cross(rate_ecef,sensor_readings.target_position_ecef); |
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.
Does CD GPS actually give us a velocity reading or were we going to calculate that ourselves?
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.
Yeah, we have to calculate that ourselves.
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.
So sensor_readings.target_velocity_ecef
will only live in MATLAB?
MATLAB/update_FC_state.m
Outdated
estimator.sat2sun_eci= env_sun_vector(sensor_readings.time); | ||
estimator.mag_ecef= env_magnetic_field(sensor_readings.time,sensor_readings.position_ecef); | ||
[estimator.quat_ecef_eci,~]=env_earth_attitude(sensor_readings.time); | ||
estimator.quat_eci_ecef= utl_quat_conj(estimator.quat_ecef_eci); | ||
estimator.mag_eci =utl_rotateframe(estimator.quat_eci_ecef,estimator.mag_ecef); | ||
estimator.sat2sun_body= sensor_readings.sat2sun_body; | ||
estimator.quat_body_eci=utl_triad(estimator.sat2sun_eci,estimator.mag_eci,sensor_readings.sat2sun_body,sensor_readings.magnetometer_body); | ||
estimator.angular_rate_body= sensor_readings.gyro_body; | ||
estimator.angular_momentum_body= const.JB*estimator.angular_rate_body+sensor_readings.wheel_momentum_body; | ||
estimator.magnetometer_body= sensor_readings.magnetometer_body; | ||
estimator.magnetic_field_body=estimator.magnetometer_body; | ||
estimator.time= sensor_readings.time; | ||
estimator.position_eci= utl_rotateframe(estimator.quat_eci_ecef,sensor_readings.position_ecef); | ||
estimator.velocity_eci= utl_rotateframe(estimator.quat_eci_ecef,sensor_readings.velocity_ecef+cross(const.earth_rate_ecef,sensor_readings.position_ecef)); | ||
estimator.target_position_eci=utl_rotateframe(estimator.quat_eci_ecef,sensor_readings.target_position_ecef); | ||
estimator.target_velocity_eci=utl_rotateframe(estimator.quat_eci_ecef,sensor_readings.target_velocity_ecef+cross(const.earth_rate_ecef,sensor_readings.target_position_ecef)); | ||
estimator.tumbling= ~(norm(estimator.angular_momentum_body)<const.MAXWHEELRATE*const.JWHEEL*0.7); | ||
estimator.low_power= false; | ||
estimator.eclipse= env_eclipse(estimator.position_eci,estimator.sat2sun_eci); | ||
estimator.valid_gps=all(isfinite([estimator.position_eci; estimator.velocity_eci; estimator.time])); | ||
estimator.valid_target_gps=estimator.valid_gps && all(isfinite([estimator.target_position_eci; estimator.target_velocity_eci; estimator.time])); | ||
|
||
if estimator.valid_gps && ~estimator.eclipse && ~all(isfinite(estimator.sat2sun_body)) | ||
estimator.sat2sun_body= [0;0;-1]; % assume the sun is coming from the docking face | ||
estimator.quat_body_eci=utl_triad(estimator.sat2sun_eci,estimator.mag_eci,estimator.sat2sun_body,estimator.magnetic_field_body); | ||
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.
Throwing this in an attitude estimator function and gps estimation function may be a good idea?
MATLAB/update_FC_state.m
Outdated
state.secondary_desired_direction_body= [0;0;1]; | ||
end | ||
if strcmp(state.main_state,'rendezvous') | ||
if estimator.tumbling || estimator.low_power || estimator.eclipse || ~estimator.valid_gps || ~estimator.valid_target_gps |
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 may be temporary, but if everything is behaving nominally except for having target position, velocity would we want to go back to detumble or hold attitude with the full ADCS system? The latter would probably give us a better shot at getting comms, gps, etc
EDIT: Actually setting it to 'detumble'
will let it propagate through to 'get gps'
, 'get target orbit'
, etc on the next FC pass correct? If so, I think this is still good.
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.
Hopefully if cd gps lock is lost, the orbit estimator can just propagate the target orbit, that way it won't have to go into detumble.
To run the simulation in MATLAB, go to the MATLAB directory in psim, then run:
there are other plotting functions in the |
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 great, I just have a few questions (mostly due to my ignorance of sim)
MATLAB/adcs/adcs_detumbler.m
Outdated
case 5 | ||
%save magnetic field reading | ||
state.old_magnetic_field= magnetometer_body; | ||
case 9 | ||
%calculate finite difference and bang bang controller | ||
deltaB= magnetometer_body-state.old_magnetic_field; | ||
state.magrod_moment_cmd= -sign(deltaB)*const.MAXMOMENT; |
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.
What's the meaning of 5 and 9?
%move to next state if initialization time has passed | ||
if state.initialization_hold_done || state.on_time>(30*60*1E9) | ||
state.initialization_hold_done=true;%save this in eprom | ||
state.main_state='detumble'; |
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.
FYI Flight Software stores on_time instead of hold_done. The rationale is that the satellite can have low battery charge and can die during the post-deployment phase. I don't think it's necessary to copy this into sim though.
r_hat_cross_sat2sun_body=cross(estimator.sat2sun_body,r_hat_eci); | ||
state.primary_current_direction_body= r_hat_body; | ||
state.primary_desired_direction_body= [1;0;0]; | ||
if( norm(r_hat_cross_sat2sun_body) > sin(10*pi/180)) |
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'll change the alignment threshold in Flight Software to also be 10 degrees
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.
In general is there some way we could standardize these thresholds across Flight Software and sim? It would be great to not have to manually ensure their similitude
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 like the organizational improvements! If this is good to go, merging it sooner rather than later would be cool so I can get on the rendezvous changes as well.
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 going to approve bc my questions aren't that important and sounds like work is waiting on this 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.
Looks good to me.
* starting adcs_update state machine * draft of adcs_update, main running * Draft of pointing and detumbling controllers * optional finite diff for pd controller * moved adcs into folder * removed config from unit tests * Update initialize_computer_states.m * better initial conditions * Long edge pointing * addressing comments * Some basic unit tests Former-commit-id: cc672c0 Former-commit-id: 695fc2fb42cf48094fdb355e53e9986d8f070488
No description provided.