Class: RoadToRubykaigi::SignalInterpreter
- Inherits:
-
Object
- Object
- RoadToRubykaigi::SignalInterpreter
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/road_to_rubykaigi/signal_interpreter.rb
Defined Under Namespace
Classes: Walk
Constant Summary collapse
- CONTINUATION_WINDOW_SECONDS =
short window used for continuation detection to avoid tail smoothing
0.2- CONTINUATION_TIMEOUT_SECONDS =
time without a continuation event before declaring a stop
0.8- SPEED_RATIO_MIN =
0.7- SPEED_RATIO_MAX =
2.3- CADENCE_PIVOT =
Assumed motions:
- in-place running (high intensity, walk-level cadence) - forward running (moderate intensity, high cadence)Forward running raises cadence; in-place running raises intensity. Speed = cadence_amp + intensity_boost. cadence_amp is dominant; lifts forward-run. intensity_boost is supplementary; lifts in-place-run, whose cadence stays near walk and so cannot be picked up by cadence_amp alone.
1.0- CADENCE_GAIN =
walking reference; below passes through, above gets gain
4.5- INTENSITY_PIVOT =
cadence ratios are narrow (~1.0-1.3), so amplify aggressively
1.1- INTENSITY_WEIGHT =
intensity must clearly exceed walking before contributing
1.6- SPEED_SMOOTHING_ALPHA =
additive boost weight for in-place run
0.4- STOPPED =
Walk states
:stopped- WALKING =
no walk in progress; next start flips direction
:walking- PAUSED =
continuation events arriving
:paused
Instance Method Summary collapse
- #log_cue(phase, text) ⇒ Object
-
#process ⇒ Object
Drain every queued sample per tick so the pipeline rate matches the sensor rate instead of being capped at frame rate.
Instance Method Details
#log_cue(phase, text) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/road_to_rubykaigi/signal_interpreter.rb', line 55 def log_cue(phase, text) return unless ENV['SIG_LOG'] == '1' @sig_log_io ||= open_sig_log_io @sig_log_io.puts "[cue] t=#{Time.now.to_f} phase=#{phase} #{text}" end |
#process ⇒ Object
Drain every queued sample per tick so the pipeline rate matches the sensor rate instead of being capped at frame rate. NOTE: :input events may fire multiple times per tick — action handlers must be safe under repeated same-tick calls (idempotent or self-gated).
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/road_to_rubykaigi/signal_interpreter.rb', line 43 def process Config.signal_source.drain do |data| if (action = interpret(data)) EventDispatcher.publish(:input, action) end end if walk_expired? stop EventDispatcher.publish(:input, :stop) end end |