@@ -7,7 +7,7 @@ use communication::messages::TextOrBinary;
7
7
use eframe:: egui:: Widget ;
8
8
use gilrs:: { Axis , Button , Gamepad , GamepadId , Gilrs } ;
9
9
use serde_json:: { json, Value } ;
10
- use types:: { joints:: head:: HeadJoints , step_plan:: Step } ;
10
+ use types:: { joints:: head:: HeadJoints , motion_command :: MotionCommand , step_plan:: Step } ;
11
11
12
12
use crate :: { nao:: Nao , panel:: Panel } ;
13
13
@@ -58,6 +58,13 @@ impl RemotePanel {
58
58
)
59
59
}
60
60
61
+ fn update_motion_command ( & self , motion_command : Value ) {
62
+ self . nao . write (
63
+ "parameters.behavior.injected_motion_command" ,
64
+ TextOrBinary :: Text ( motion_command) ,
65
+ )
66
+ }
67
+
61
68
fn update_look_at_angle ( & self , joints : Value ) {
62
69
self . nao . write (
63
70
"parameters.head_motion.injected_head_joints" ,
@@ -71,6 +78,7 @@ impl Widget for &mut RemotePanel {
71
78
const UPDATE_DELAY : Duration = Duration :: from_millis ( 100 ) ;
72
79
const HEAD_PITCH_SCALE : f32 = 1.0 ;
73
80
const HEAD_YAW_SCALE : f32 = 1.0 ;
81
+ const DEADZONE : f32 = 0.1 ;
74
82
75
83
self . gilrs . inc ( ) ;
76
84
@@ -118,6 +126,15 @@ impl Widget for &mut RemotePanel {
118
126
turn,
119
127
} ;
120
128
129
+ let injected_motion_command =
130
+ if step. forward . abs ( ) < DEADZONE && step. left . abs ( ) < DEADZONE {
131
+ Some ( MotionCommand :: Stand {
132
+ head : types:: motion_command:: HeadMotion :: ZeroAngles ,
133
+ } )
134
+ } else {
135
+ None
136
+ } ;
137
+
121
138
if self . enabled {
122
139
let now = SystemTime :: now ( ) ;
123
140
if now
@@ -128,14 +145,18 @@ impl Widget for &mut RemotePanel {
128
145
self . last_update = now;
129
146
self . update_step ( serde_json:: to_value ( step) . unwrap ( ) ) ;
130
147
self . update_look_at_angle ( serde_json:: to_value ( injected_head_joints) . unwrap ( ) ) ;
148
+ self . update_motion_command (
149
+ serde_json:: to_value ( & injected_motion_command) . unwrap ( ) ,
150
+ ) ;
131
151
}
132
152
}
133
153
134
154
ui. vertical ( |ui| {
135
155
let label_1 = ui. label ( & format ! ( "{:#?}" , step) ) ;
136
156
let label_2 = ui. label ( & format ! ( "{:#?}" , injected_head_joints) ) ;
157
+ let label_3 = ui. label ( & format ! ( "{:#?}" , injected_motion_command) ) ;
137
158
138
- label_1. union ( label_2)
159
+ label_1. union ( label_2) . union ( label_3 )
139
160
} )
140
161
. inner
141
162
} else {
0 commit comments