forked from HULKs/hulk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote_control.rs
More file actions
48 lines (40 loc) · 1.22 KB
/
Copy pathremote_control.rs
File metadata and controls
48 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use color_eyre::Result;
use context_attribute::context;
use framework::MainOutput;
use linear_algebra::vector;
use serde::{Deserialize, Serialize};
use types::{
motion_command::{HeadMotion, MotionCommand},
parameters::RemoteControlParameters,
};
#[context]
pub struct CreationContext {}
#[context]
pub struct CycleContext {
remote_control_parameters: Parameter<RemoteControlParameters, "remote_control_parameters">,
}
#[derive(Deserialize, Serialize)]
pub struct RemoteControl {}
#[context]
#[derive(Default)]
pub struct MainOutputs {
pub motion_command: MainOutput<MotionCommand>,
}
impl RemoteControl {
pub fn new(_context: CreationContext) -> Result<Self> {
Ok(RemoteControl {})
}
pub fn cycle(&mut self, context: CycleContext) -> Result<MainOutputs> {
let motion_command = MotionCommand::WalkWithVelocity {
head: HeadMotion::Center,
velocity: vector![
context.remote_control_parameters.walk.forward,
context.remote_control_parameters.walk.left,
],
angular_velocity: context.remote_control_parameters.walk.turn,
};
Ok(MainOutputs {
motion_command: motion_command.into(),
})
}
}