-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add the math and the motions left and right wideStance * cleaned up * Edit stiffnes in motions * Rename WideStance to KeeperMotion * finished Motion file and Bug Fixes * Cleanup * rm match stamant and added if statment * renamend things * fixed default.json * fixed naming and added a newline
- Loading branch information
Showing
15 changed files
with
589 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use color_eyre::Result; | ||
use context_attribute::context; | ||
use framework::MainOutput; | ||
use hardware::PathsInterface; | ||
use motionfile::{MotionFile, MotionInterpolator}; | ||
use serde::{Deserialize, Serialize}; | ||
use types::{ | ||
condition_input::ConditionInput, | ||
cycle_time::CycleTime, | ||
joints::{mirror::Mirror, Joints}, | ||
motion_selection::{MotionSafeExits, MotionSelection, MotionType}, | ||
motor_commands::MotorCommands, | ||
}; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct KeeperJumpLeft { | ||
interpolator: MotionInterpolator<MotorCommands<Joints<f32>>>, | ||
} | ||
|
||
#[context] | ||
pub struct CreationContext { | ||
hardware_interface: HardwareInterface, | ||
} | ||
|
||
#[context] | ||
pub struct CycleContext { | ||
condition_input: Input<ConditionInput, "condition_input">, | ||
cycle_time: Input<CycleTime, "cycle_time">, | ||
motion_selection: Input<MotionSelection, "motion_selection">, | ||
|
||
motion_safe_exits: CyclerState<MotionSafeExits, "motion_safe_exits">, | ||
} | ||
|
||
#[context] | ||
#[derive(Default)] | ||
pub struct MainOutputs { | ||
pub keeper_jump_left_motor_commands: MainOutput<MotorCommands<Joints<f32>>>, | ||
} | ||
|
||
impl KeeperJumpLeft { | ||
pub fn new(context: CreationContext<impl PathsInterface>) -> Result<Self> { | ||
let paths = context.hardware_interface.get_paths(); | ||
Ok(Self { | ||
interpolator: MotionFile::from_path(paths.motions.join("keeper_jump_right.json"))? | ||
.try_into()?, | ||
}) | ||
} | ||
|
||
pub fn cycle(&mut self, context: CycleContext) -> Result<MainOutputs> { | ||
let last_cycle_duration = context.cycle_time.last_cycle_duration; | ||
let condition_input = context.condition_input; | ||
|
||
if context.motion_selection.current_motion == MotionType::KeeperJumpLeft { | ||
self.interpolator | ||
.advance_by(last_cycle_duration, condition_input); | ||
} else { | ||
self.interpolator.reset(); | ||
} | ||
context.motion_safe_exits[MotionType::KeeperJumpLeft] = self.interpolator.is_finished(); | ||
|
||
Ok(MainOutputs { | ||
keeper_jump_left_motor_commands: self.interpolator.value().mirrored().into(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use color_eyre::Result; | ||
use context_attribute::context; | ||
use framework::MainOutput; | ||
use hardware::PathsInterface; | ||
use motionfile::{MotionFile, MotionInterpolator}; | ||
use serde::{Deserialize, Serialize}; | ||
use types::{ | ||
condition_input::ConditionInput, | ||
cycle_time::CycleTime, | ||
joints::Joints, | ||
motion_selection::{MotionSafeExits, MotionSelection, MotionType}, | ||
motor_commands::MotorCommands, | ||
}; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct KeeperJumpRight { | ||
interpolator: MotionInterpolator<MotorCommands<Joints<f32>>>, | ||
} | ||
|
||
#[context] | ||
pub struct CreationContext { | ||
hardware_interface: HardwareInterface, | ||
} | ||
|
||
#[context] | ||
pub struct CycleContext { | ||
condition_input: Input<ConditionInput, "condition_input">, | ||
cycle_time: Input<CycleTime, "cycle_time">, | ||
motion_selection: Input<MotionSelection, "motion_selection">, | ||
|
||
motion_safe_exits: CyclerState<MotionSafeExits, "motion_safe_exits">, | ||
} | ||
|
||
#[context] | ||
#[derive(Default)] | ||
pub struct MainOutputs { | ||
pub keeper_jump_right_motor_commands: MainOutput<MotorCommands<Joints<f32>>>, | ||
} | ||
|
||
impl KeeperJumpRight { | ||
pub fn new(context: CreationContext<impl PathsInterface>) -> Result<Self> { | ||
let paths = context.hardware_interface.get_paths(); | ||
Ok(Self { | ||
interpolator: MotionFile::from_path(paths.motions.join("keeper_jump_right.json"))? | ||
.try_into()?, | ||
}) | ||
} | ||
|
||
pub fn cycle(&mut self, context: CycleContext) -> Result<MainOutputs> { | ||
let last_cycle_duration = context.cycle_time.last_cycle_duration; | ||
let condition_input = context.condition_input; | ||
|
||
if context.motion_selection.current_motion == MotionType::KeeperJumpRight { | ||
self.interpolator | ||
.advance_by(last_cycle_duration, condition_input); | ||
} else { | ||
self.interpolator.reset(); | ||
} | ||
context.motion_safe_exits[MotionType::KeeperJumpRight] = self.interpolator.is_finished(); | ||
|
||
Ok(MainOutputs { | ||
keeper_jump_right_motor_commands: self.interpolator.value().into(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.