Input Messages

Human input device types for teleoperation and manual control.

from horus import JoystickInput, KeyboardInput

JoystickInput

Gamepad/joystick state — axes and buttons.

joy = horus.JoystickInput(
    axes=[0.0, 0.5, 0.0, 0.0, 0.0, 0.0],  # Up to 6 axes
    buttons=[0, 0, 1, 0, 0, 0, 0, 0],       # Up to 16 buttons (0/1)
)

# Common mapping: axes[0]=left_x, axes[1]=left_y, axes[2]=right_x, axes[3]=right_y
linear = joy.axes[1] * 1.0   # Forward/back
angular = joy.axes[0] * 2.0  # Turn
FieldTypeDescription
axeslist[float]Analog axis values (-1.0 to 1.0)
buttonslist[int]Button states (0=released, 1=pressed)

KeyboardInput

Keyboard key state.

key = horus.KeyboardInput(key_code=119, pressed=True)  # 'w' key
FieldTypeDescription
key_codeintKey code
pressedboolWhether key is pressed

Example: Joystick Teleoperation

import horus

def teleop_tick(node):
    joy = node.recv("joystick")
    if joy is None:
        return

    # Dead zone filtering
    lx = joy.axes[1] if abs(joy.axes[1]) > 0.1 else 0.0
    rx = joy.axes[0] if abs(joy.axes[0]) > 0.1 else 0.0

    cmd = horus.CmdVel(linear=lx * 1.0, angular=rx * 2.0)

    # E-stop on button 0 (A/Cross)
    if joy.buttons[0]:
        cmd = horus.CmdVel(linear=0.0, angular=0.0)

    node.send("cmd_vel", cmd)

teleop = horus.Node(
    name="teleop",
    subs=[horus.JoystickInput],
    pubs=[horus.CmdVel],
    tick=teleop_tick,
    rate=30,
)
horus.run(teleop)

See Also