test-medulla.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 # -*- coding: utf-8 -*-
00003 
00004 import dbus
00005 import dbus.mainloop.glib
00006 import gobject
00007 from optparse import OptionParser
00008 
00009 def get_variables_reply(r):
00010         print 'variables:'
00011         print str(r)
00012 
00013 def get_variables_error(e):
00014         print 'error:'
00015         print str(e)
00016         loop.quit()
00017 
00018 if __name__ == '__main__':
00019         parser = OptionParser()
00020         parser.add_option("-s", "--system", action="store_true", dest="system", default=False,
00021                         help="use the system bus instead of the session bus")
00022 
00023         (options, args) = parser.parse_args()
00024 
00025         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
00026         
00027         if options.system:
00028                 bus = dbus.SystemBus()
00029         else:
00030                 bus = dbus.SessionBus()
00031         
00032         network = dbus.Interface(bus.get_object('ch.epfl.mobots.Aseba', '/'), dbus_interface='ch.epfl.mobots.AsebaNetwork')
00033         print network.GetNodesList()
00034 
00035         #network.SetVariable("e-puck 1", "leftSpeed", [10])
00036         #network.SetVariable("e-puck 1", "rightSpeed", [-10])
00037 
00038         network.SendEvent(0, [])
00039 
00040         #print network.GetVariable("e-puck 1", "leftSpeed",reply_handler=get_variables_reply,error_handler=get_variables_error)
00041 
00042         print 'starting loop'
00043         loop = gobject.MainLoop()
00044         loop.run()


aseba
Author(s): Stéphane Magnenat
autogenerated on Thu Jan 2 2014 11:17:17