back to Index

joy_broadcast

2014-07-20

joystick driver using gamepad API


In [1]:
# Cross-notebook include shim
with open("nbinclude.ipynb") as nbinclude_f: # don't rename nbinclude_f
    import IPython.nbformat.current
    get_ipython().run_cell(IPython.nbformat.current.read(nbinclude_f, 'json').worksheets[0].cells[0].input)

In [2]:
nbinclude('gamepad_widget')



In [3]:
import time, lcm
from python.forseti2 import piemos_cmd
from python.fearing import xbox_joystick_state
import python.fearing

In [4]:
lc=lcm.LCM('udpm://239.255.76.67:7667?ttl=1')
xbs=xbox_joystick_state()
xbs.header = python.fearing.header()

In [5]:
def cmd(left, right):
    xbs.axes[1]=left
    xbs.axes[3]=right
    print(left, right)
    lc.publish('robot0/joy', xbs.encode())

In [6]:
widgets.interact(cmd,
                 left=JoystickFloatWidget(axis_id=1),
                 right=JoystickFloatWidget(axis_id=3))


0.0487075410783 -0.0755333080888

In [6]:


In [6]: