Skip to content

Safe crash #1825

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 3 commits into
base: main
Choose a base branch
from
Open

Safe crash #1825

wants to merge 3 commits into from

Conversation

schluis
Copy link
Contributor

@schluis schluis commented Apr 5, 2025

Why? What?

Describe here why you created this PR and what it does

Fixes #

ToDo / Known Issues

If this is a WIP describe which problems are to be fixed.

Ideas for Next Iterations (Not This PR)

If there are some improvements that could be done in a next iteration, describe them here.

How to Test

Describe how to test your changes. (For the reviewer)

@github-project-automation github-project-automation bot moved this to Request for Review in Development Apr 5, 2025
@schluis schluis moved this from Request for Review to In Progress in Development Apr 5, 2025
Comment on lines +146 to +150
if (position.right_knee_pitch <= 90.0_f32.to_radians()
|| position.left_knee_pitch <= 90.0_f32.to_radians())
&& (position.left_hip_pitch >= -40.0_f32.to_radians()
|| position.right_hip_pitch >= -40.0_f32.to_radians())
&& inertial_measurement_unit.accelerometer.z < -8.0
Copy link
Contributor

Choose a reason for hiding this comment

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

can you extract this to a variable with a name like is_... to properly name what you want to check here

Comment on lines +112 to 158
sit_down_interpolator.advance_by(
loop_duration,
&ConditionInput {
filtered_angular_velocity: Vector3::zeros(),
ground_contact: true,
fall_state: FallState::Upright,
},
);

let sit_down_joints_command = MotorCommands {
positions: sit_down_interpolator.value(),
stiffnesses: Joints::fill(0.8),
};

send_sit_down(
&mut writer,
sit_down_joints_command.positions,
sit_down_joints_command.stiffnesses,
)
.wrap_err("failed to send sit down command to LoLA")?;

if sit_down_interpolator.is_finished() {
operation_state = OperationState::GuestsInControl;
sit_down_interpolator.reset();
}
} else if !connections
.values()
.any(|connection| connection.is_sending_control_frames)
{
let battery = self.shared_state.lock().unwrap().battery;
send_idle(&mut writer, battery).wrap_err(
let shared_state = self.shared_state.lock().unwrap();
if let (Some(position), Some(inertial_measurement_unit)) = (
shared_state.position,
shared_state.inertial_measurement_unit,
) {
if (position.right_knee_pitch <= 90.0_f32.to_radians()
|| position.left_knee_pitch <= 90.0_f32.to_radians())
&& (position.left_hip_pitch >= -40.0_f32.to_radians()
|| position.right_hip_pitch >= -40.0_f32.to_radians())
&& inertial_measurement_unit.accelerometer.z < -8.0
{
operation_state = OperationState::SittingDown;
}
}
send_idle(&mut writer, shared_state.battery).wrap_err(
"a shadowy flight into the dangerous world of a man who does not exist",
)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the function is getting really long, can you split it up into smaller sub-tasks?

Comment on lines +1 to +22
#[derive(Deserialize, Serialize)]
pub struct SitDown {}

pub fn sit_down() -> bool {
interpolator: MotionFile::from_path(paths.motions.join("sit_down.json"))?.try_into()?,


let last_cycle_duration = context.cycle_time.last_cycle_duration;

self.interpolator
.advance_by(last_cycle_duration, context.condition_input);

context.motion_safe_exits[MotionType::SitDown] = self.interpolator.is_finished();

Ok(MainOutputs {
sit_down_joints_command: MotorCommands {
positions: self.interpolator.value(),
stiffnesses: Joints::fill(0.8),
}
.into(),
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? Added accidentally?

@oleflb oleflb self-assigned this May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants