back to Index

joy_receive

2014-07-19

joystick receiver


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]:
import time, lcm
from python.forseti2 import piemos_cmd
from python.fearing import xbox_joystick_state

In [5]:
class RobotRunner:

    def handle_joy(self, chan, data):
        msg = xbox_joystick_state.decode(data)
        l,r = msg.axes[1], msg.axes[3]
        print(l,r)
#         self.robot.cmd(l,r)

    def lcm_run(self):
        lc=lcm.LCM('udpm://239.255.76.67:7667?ttl=1')
        sub=lc.subscribe("robot0/joy", self.handle_joy)
        self.running = True
        while self.running:
            lc.handle()
#             for tick in self.ticks:
#                 tick()
            time.sleep(.01)

In [6]:
rr=RobotRunner()

In [7]:
rr.lcm_run()


(0.0, -0.0789819061756134)
(0.0, -0.0789819061756134)
(0.0, -0.0789819061756134)
(0.0, -0.0789819061756134)
(0.0, -0.0789819061756134)
(0.0, -0.9556565880775452)
(0.014709921553730965, -0.9556565880775452)
(0.014709921553730965, -0.9556565880775452)
(0.014709921553730965, -0.9556565880775452)
(0.014709921553730965, -0.9556565880775452)
(0.014709921553730965, -0.9556565880775452)
(0.014709921553730965, -0.08584856986999512)
(0.014709921553730965, -0.08584856986999512)
(0.014709921553730965, 0.08917508274316788)
(0.01809747703373432, 0.08917508274316788)
(0.01809747703373432, 0.08917508274316788)
(0.01809747703373432, 0.08917508274316788)
(0.01809747703373432, 0.08917508274316788)
(0.01809747703373432, 0.08917508274316788)
(0.01809747703373432, -0.058229316025972366)
(0.014709921553730965, -0.058229316025972366)
(0.014709921553730965, -0.058229316025972366)
(0.014709921553730965, -0.058229316025972366)
(0.014709921553730965, -0.058229316025972366)
(0.014709921553730965, -0.058229316025972366)
(0.014709921553730965, -0.013397625647485256)
(0.011291848495602608, -0.013397625647485256)
(0.011291848495602608, -0.013397625647485256)
(0.011291848495602608, -0.013397625647485256)
(0.011291848495602608, -0.013397625647485256)
(0.011291848495602608, -0.013397625647485256)
(0.011291848495602608, -0.003021332435309887)
(0.014709921553730965, -0.003021332435309887)
(0.014709921553730965, -0.003021332435309887)
(0.014709921553730965, -0.003021332435309887)
(0.014709921553730965, -0.003021332435309887)
(0.014709921553730965, -0.003021332435309887)
(0.014709921553730965, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, -0.1031220406293869)
(0.014709921553730965, -0.1031220406293869)
(0.014709921553730965, -0.40687277913093567)
(0.014709921553730965, -0.40687277913093567)
(0.014709921553730965, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.014709921553730965, -1.0)
(0.014709921553730965, -1.0)
(0.014709921553730965, -1.0)
(0.014709921553730965, -1.0)
(0.014709921553730965, -1.0)
(0.014709921553730965, -0.7934507131576538)
(0.014709921553730965, -0.7934507131576538)
(0.014709921553730965, -0.1272927075624466)
(0.014709921553730965, -0.1272927075624466)
(0.014709921553730965, 0.0)
(0.01809747703373432, 0.0)
(0.01809747703373432, 0.0)
(0.01809747703373432, 0.0)
(0.01809747703373432, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, 1.0)
(0.01809747703373432, 1.0)
(0.01809747703373432, 1.0)
(0.01809747703373432, 1.0)
(0.01809747703373432, 1.0)
(0.014709921553730965, 1.0)
(0.014709921553730965, 1.0)
(0.014709921553730965, 1.0)
(0.014709921553730965, 1.0)
(0.014709921553730965, 1.0)
(0.014709921553730965, 0.8001953363418579)
(0.014709921553730965, 0.8001953363418579)
(0.014709921553730965, 0.0)
(0.014709921553730965, 0.0)
(0.014709921553730965, -0.00991851557046175)
(0.014709921553730965, -0.00991851557046175)
(0.014709921553730965, 0.020172735676169395)
(0.01809747703373432, 0.020172735676169395)
(0.01809747703373432, 0.020172735676169395)
(0.01809747703373432, 0.020172735676169395)
(0.01809747703373432, 0.020172735676169395)
(0.01809747703373432, 0.020172735676169395)
(0.01809747703373432, 0.22727133333683014)
(0.014709921553730965, 0.22727133333683014)
(0.014709921553730965, 0.22727133333683014)
(0.014709921553730965, 0.22727133333683014)
(0.014709921553730965, 0.22727133333683014)
(0.014709921553730965, 0.22727133333683014)
(0.014709921553730965, 1.0)
(0.014709921553730965, 1.0)
(0.014709921553730965, 0.7691580057144165)
(0.014709921553730965, 0.7691580057144165)
(0.014709921553730965, 0.16858424246311188)
(0.01809747703373432, 0.16858424246311188)
(0.01809747703373432, 0.16858424246311188)
(0.01809747703373432, 0.16858424246311188)
(0.01809747703373432, 0.16858424246311188)
(0.01809747703373432, 0.16858424246311188)
(0.01809747703373432, 0.0028992583975195885)
(0.014709921553730965, 0.0028992583975195885)
(0.014709921553730965, 0.0028992583975195885)
(0.014709921553730965, 0.0028992583975195885)
(0.014709921553730965, 0.0028992583975195885)
(0.014709921553730965, 0.0028992583975195885)
(0.014709921553730965, -0.08929716050624847)
(0.014709921553730965, -0.08929716050624847)
(0.014709921553730965, -0.12036500126123428)
(0.014709921553730965, -0.12036500126123428)
(0.014709921553730965, -0.20322275161743164)
(0.014709921553730965, -0.20322275161743164)
(0.014709921553730965, -0.5966979265213013)
(0.014709921553730965, -0.5966979265213013)
(0.014709921553730965, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -1.0)
(0.01809747703373432, -0.6726584434509277)
(0.014709921553730965, -0.6726584434509277)
(0.014709921553730965, -0.6726584434509277)
(0.014709921553730965, -0.6726584434509277)
(0.014709921553730965, -0.6726584434509277)
(0.014709921553730965, -0.6726584434509277)
(0.014709921553730965, 0.07193212956190109)
(0.01809747703373432, 0.07193212956190109)
(0.01809747703373432, 0.07193212956190109)
(0.01809747703373432, 0.07193212956190109)
(0.01809747703373432, 0.07193212956190109)
(0.01809747703373432, 0.07193212956190109)
(0.01809747703373432, 0.8623310327529907)
(0.01809747703373432, 0.8623310327529907)
(0.01809747703373432, 1.0)
(0.01809747703373432, 1.0)
(0.01809747703373432, 0.9969786405563354)
(0.01809747703373432, 0.9969786405563354)
(0.01809747703373432, 0.0)
(0.01809747703373432, 0.0)
(0.01809747703373432, -0.013397625647485256)
(0.2526627480983734, -0.013397625647485256)
(0.2526627480983734, -0.013397625647485256)
(0.2526627480983734, -0.013397625647485256)
(0.2526627480983734, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(0.9189122915267944, -0.013397625647485256)
(0.9189122915267944, -0.013397625647485256)
(0.9189122915267944, -0.013397625647485256)
(0.9189122915267944, -0.013397625647485256)
(0.09286782145500183, -0.013397625647485256)
(0.09286782145500183, -0.013397625647485256)
(0.09286782145500183, -0.013397625647485256)
(0.09286782145500183, -0.013397625647485256)
(0.014709921553730965, -0.013397625647485256)
(0.014709921553730965, -0.013397625647485256)
(0.014709921553730965, -0.013397625647485256)
(0.014709921553730965, -0.013397625647485256)
(-0.06918545812368393, -0.013397625647485256)
(-0.06918545812368393, -0.013397625647485256)
(-0.06918545812368393, -0.013397625647485256)
(-0.06918545812368393, -0.013397625647485256)
(-0.06918545812368393, -0.013397625647485256)
(-0.06918545812368393, -0.016846217215061188)
(-0.6300851702690125, -0.016846217215061188)
(-0.6300851702690125, -0.016846217215061188)
(-0.6300851702690125, -0.016846217215061188)
(-0.6300851702690125, -0.016846217215061188)
(-0.6300851702690125, -0.016846217215061188)
(-0.6300851702690125, -0.013397625647485256)
(-0.9971923232078552, -0.013397625647485256)
(-0.9971923232078552, -0.013397625647485256)
(-0.9971923232078552, -0.013397625647485256)
(-0.9971923232078552, -0.013397625647485256)
(-0.9937742352485657, -0.013397625647485256)
(-0.9937742352485657, -0.013397625647485256)
(-0.9937742352485657, -0.013397625647485256)
(-0.9937742352485657, -0.013397625647485256)
(-0.6742454171180725, -0.013397625647485256)
(-0.6742454171180725, -0.013397625647485256)
(-0.6742454171180725, -0.013397625647485256)
(-0.6742454171180725, -0.013397625647485256)
(0.17105624079704285, -0.013397625647485256)
(0.17105624079704285, -0.013397625647485256)
(0.17105624079704285, -0.013397625647485256)
(0.17105624079704285, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.016846217215061188)
(0.38520461320877075, -0.016846217215061188)
(0.38520461320877075, -0.016846217215061188)
(0.38520461320877075, -0.016846217215061188)
(0.38520461320877075, -0.016846217215061188)
(0.38520461320877075, -0.016846217215061188)
(0.38520461320877075, -0.013397625647485256)
(0.07589953392744064, -0.013397625647485256)
(0.07589953392744064, -0.013397625647485256)
(0.07589953392744064, -0.013397625647485256)
(0.07589953392744064, -0.013397625647485256)
(0.07248146086931229, -0.013397625647485256)
(0.07248146086931229, -0.013397625647485256)
(0.07248146086931229, -0.013397625647485256)
(0.07248146086931229, -0.013397625647485256)
(0.08270516246557236, -0.013397625647485256)
(0.08270516246557236, -0.013397625647485256)
(0.08270516246557236, -0.013397625647485256)
(0.08270516246557236, -0.013397625647485256)
(0.15408796072006226, -0.013397625647485256)
(0.15408796072006226, -0.013397625647485256)
(0.15408796072006226, -0.013397625647485256)
(0.15408796072006226, -0.013397625647485256)
(0.42603838443756104, -0.013397625647485256)
(0.42603838443756104, -0.013397625647485256)
(0.42603838443756104, -0.013397625647485256)
(0.42603838443756104, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(1.0, -0.013397625647485256)
(0.8474990129470825, -0.013397625647485256)
(0.8474990129470825, -0.013397625647485256)
(0.8474990129470825, -0.013397625647485256)
(0.8474990129470825, -0.013397625647485256)
(0.5789971351623535, -0.013397625647485256)
(0.5789971351623535, -0.013397625647485256)
(0.5789971351623535, -0.013397625647485256)
(0.5789971351623535, -0.013397625647485256)
(0.10989715158939362, -0.013397625647485256)
(0.10989715158939362, -0.013397625647485256)
(0.10989715158939362, -0.013397625647485256)
(0.10989715158939362, -0.013397625647485256)
(-0.004608294926583767, -0.013397625647485256)
(-0.004608294926583767, -0.013397625647485256)
(-0.22556230425834656, -0.013397625647485256)
(-0.22556230425834656, -0.013397625647485256)
(-0.22556230425834656, -0.013397625647485256)
(-0.22556230425834656, -0.013397625647485256)
(-1.0, -0.013397625647485256)
(-1.0, -0.013397625647485256)
(-1.0, -0.013397625647485256)
(-1.0, -0.013397625647485256)
(-0.443098247051239, -0.013397625647485256)
(-0.443098247051239, -0.013397625647485256)
(-0.443098247051239, -0.013397625647485256)
(-0.443098247051239, -0.013397625647485256)
(0.0079348124563694, -0.013397625647485256)
(0.0079348124563694, -0.013397625647485256)
(0.0079348124563694, -0.013397625647485256)
(0.0079348124563694, -0.013397625647485256)
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-7-2fe86163f725> in <module>()
----> 1 rr.lcm_run()

<ipython-input-5-355ffd401688> in lcm_run(self)
     12         self.running = True
     13         while self.running:
---> 14             lc.handle()
     15 #             for tick in self.ticks:
     16 #                 tick()

KeyboardInterrupt: 

In [ ]: