Skip to content
Snippets Groups Projects
Commit 95f04c47 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

Merge branch 'devel-PA' into 'devel-PA'

joystick launcher

See merge request !12
parents 80fdcbb8 8beae832
No related branches found
No related tags found
1 merge request!12joystick launcher
Pipeline #16552 failed
# Joystick Launcher
Start and stop the controller from the a joystick.
## Install
```bash
sudo cp *.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable joystick-launcher
sudo systemctl start joystick-launcher
```
## Use
To start the controller, press LR1 + north (triangle on a ps-like gamepad)
To stop the controller, press LR1 + west (square on a ps-like gamepad)
[Unit]
Description=Gepetto Quadruped Reactive Walking
[Service]
Type=simple
WorkingDirectory=/home/pi/src/quadruped-reactive-walking/build
ExecStart=/home/pi/src/quadruped-reactive-walking/build/gepetto-quadruped-reactive-walking
#!/usr/bin/env python3
"""Start and stop the odri-controller service."""
import dbus
from inputs import get_gamepad
SERVICE = "gepetto-quadruped-reactive-walking.service"
SYSTEMD = "org.freedesktop.systemd1"
SYSTEMDS = '/' + SYSTEMD.replace('.', '/')
def get_manager():
sysbus = dbus.SystemBus()
systemd1 = sysbus.get_object(SYSTEMD, SYSTEMDS)
return dbus.Interface(systemd1, SYSTEMD + ".Manager")
def start(manager):
manager.StartUnit(SERVICE, "replace")
def stop(manager):
manager.StopUnit(SERVICE, "replace")
def main():
manager = get_manager()
security = False # ensure no accidental trigger
while True:
for event in get_gamepad():
if event.code == "BTN_TR":
security = event.state == 1
elif security and event.state == 1:
if event.code == "BTN_NORTH":
start(manager)
elif event.code == "BTN_WEST":
stop(manager)
if __name__ == "__main__":
main()
[Unit]
Description=Start the Gepetto Quadruped Reactive Walking service from a joystick
StartLimitIntervalSec=2
[Service]
Type=simple
Restart=always
RestartSec=5
WorkingDirectory=/home/pi/src/quadruped-reactive-walking/scripts/joystick-launcher
ExecStart=/home/pi/src/quadruped-reactive-walking/scripts/joystick-launcher/joystick-launcher.py
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment