Road to RubyKaigi:
Play Hard(ware)
@makicamel
RubyKaigi 2026
2025.04.22.
Slide 2
Slide 2 text
About Me
@makicamel / Maki Kawahara
Loves Ruby , beer and sake
Co-Organizer of PicoPicoRuby
Creator of "Road to RubyKaigi"
Slide 3
Slide 3 text
Road to RubyKaigi
Road to RubyKaigi
https://github.com/makicamel/road_to_rubykaigi
Slide 4
Slide 4 text
Road to RubyKaigi
A Ruby game by Rubyists, for Rubyists
A side-scrolling action game played in the terminal
Defeat bugs, escape deadlines, and make it to RubyKaigi
Slide 5
Slide 5 text
Road to RubyKaigi
Slide 6
Slide 6 text
PicoRuby
Slide 7
Slide 7 text
PicoRuby
PicoRuby is very HOT at RubyKaigi 2026!
Slide 8
Slide 8 text
PicoRuby
Ruby for embedded systems
Runs on microcontrollers
e.g. Raspberry Pi Pico 2W
Slide 9
Slide 9 text
Microcontroller
Connect various I/O to build your own device
Slide 10
Slide 10 text
Acceleration
Slide 11
Slide 11 text
Acceleration
What is acceleration?
The rate of change of velocity
e.g.
A car starting to move: positive acceleration
A car cruising at constant speed: acceleration is 0
Slide 12
Slide 12 text
Acceleration
Acceleration
Expresses changes in motion as numbers
Lets us extract features and read movement
3-axis accelerometer module KXR94-2050
https://akizukidenshi.com/catalog/g/g105153/
Slide 13
Slide 13 text
Acceleration
With an accelerometer,
a human walking can make the game character walk!
Slide 14
Slide 14 text
Accelerometer
3 axes
x: left-right
y: front-back
z: up-down
Reads acceleration on each axis
Slide 15
Slide 15 text
Accelerometer
Waveform while standing still
Almost no change in acceleration
Slide 16
Slide 16 text
Accelerometer
Waveform while walking
Draws periodic arcs
Slide 17
Slide 17 text
Accelerometer
Find patterns of change to read "motion"
Slide 18
Slide 18 text
Walk Detection
Slide 19
Slide 19 text
Walk Detection: Time
Acceleration at a single moment
A single point alone can't reveal "motion"
Slide 20
Slide 20 text
Walk Detection: Time
Acceleration change over a time window
"Moving" means changing over time
Observe variation within the window
Slide 21
Slide 21 text
Walk Detection: Motion Intensity
Amount of acceleration change in a time window = motion intensity
How scattered the acceleration is
Slide 22
Slide 22 text
Walk Detection: Motion Intensity
Condense acceleration change over a time window into a single
number
Represents motion intensity
Still / walking become distinguishable
Waveform information is lost
Periodicity, rhythm of the wave
Acceptable for this case
If motion intensity exceeds a threshold, the player is "walking"
Slide 23
Slide 23 text
Walk Detection: Extracting Motion Intensity
Slide 24
Slide 24 text
Walk Detection: Extracting Motion Intensity
1. Extract motion intensity per axis
2. Sum the extracted values
Slide 25
Slide 25 text
Walk Detection: Per-Axis Motion Intensity
e.g. Z axis
Slide 26
Slide 26 text
Walk Detection: Per-Axis Motion Intensity
Mean
mean = samples.sum / samples.size
Deviation from the mean for each sample
dev(n) = sample[n] - mean
Squared deviation
dev(n)²
Mean of squared deviations
(dev(1)² + dev(2)² + ... dev(n)²) / samples.size
Slide 27
Slide 27 text
Walk Detection: Per-Axis Motion Intensity
Mean
mean = samples.sum / samples.size
Deviation from the mean for each sample
dev(n) = sample[n] - mean
Squared deviation
dev(n)²
Mean of squared deviations
(dev(1)² + dev(2)² + ... dev(n)²) / samples.size
Slide 28
Slide 28 text
Walk Detection: Per-Axis Motion Intensity
Mean
mean = samples.sum / samples.size
Deviation from the mean for each sample
dev(n) = sample[n] - mean
Squared deviation
dev(n)²
Mean of squared deviations
(dev(1)² + dev(2)² + ... dev(n)²) / samples.size
Slide 29
Slide 29 text
Walk Detection: Per-Axis Motion Intensity
Mean
mean = samples.sum / samples.size
Deviation from the mean for each sample
dev(n) = sample[n] - mean
Squared deviation
dev(n)²
Mean of squared deviations
(dev(1)² + dev(2)² + ... dev(n)²) / samples.size
Slide 30
Slide 30 text
Walk Detection: Per-Axis Motion Intensity
Motion intensity along the Z axis over the window
Slide 31
Slide 31 text
Walk Detection: Per-Axis Motion Intensity
Motion intensity along X, Y, Z axes over the window
Slide 32
Slide 32 text
Walk Detection: Per-Axis Motion Intensity
Sum the per-axis motion intensities
def motion_intensity
Math.sqrt(var(0) + var(1) + var(2))
end
Motion intensity over the window
Slide 33
Slide 33 text
Walk Detection: Per-Axis Motion Intensity
Walking starts when motion intensity exceeds the threshold
class SignalInterpreter
def walk_started?
@window.motion_intensity > Config.start_threshold
end
Slide 34
Slide 34 text
Walk Detection
After this,
add stop detection,
running behavior,
jump detection, and so on,
done!