コード例 #1
0
    def __init__(self, **kwargs):

        import threading

        super(RoboPad, self).__init__(**kwargs)

        # some trash he-he

        # t = threading.Thread(target=self.some_current_data)
        # t.daemon = True
        # t.start()

        # # print('running super(Gamepad, self).__init__()')

        # joystickhand and joystickrun
        self.joystickhand = Joystick(size_hint=(.4, .4),
                                     pos_hint={'x': 0.0, 'y': .2},
                                     sticky=True)
        self.add_widget(self.joystickhand)
        self.joystickrun = Joystick(size_hint=(.4, .4),
                                    pos_hint={'x': 0.6, 'y': .2})
        self.add_widget(self.joystickrun)

        # add some buttons
        self.catchbutton = Button(size_hint=(.15, .15),
                                  pos_hint={'x': .8, 'y': .65},
                                  text='Catch me!')
        self.add_widget(self.catchbutton)

        # add debug Labels
        # self.debug_label = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .8, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label)
        # self.debug_label_hand = Label(size_hint=(.2, .2),
        #                               pos_hint={'x': .1, 'y': .8},
        #                               text='message ... ...',)
        # self.add_widget(self.debug_label_hand)
        # self.debug_label_run = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .5, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label_run)

        # bind joystick
        self.joystickrun.bind(pad=self.update_coordinates_run)
        self.joystickhand.bind(pad=self.update_coordinates_hand)

        # bind button
        self.catchbutton.bind(on_press=self.update_catch_release)

        # self.global_reader()

        self.current_hand_pos = {}
        self.saved_hand_pos = {}
        self.current_run_pos = {}
        self.saved_run_pos = {}

        Clock.schedule_interval(self.timer, 0.1)
コード例 #2
0
    def __init__(self, **kwargs):
        super(RoboPad, self).__init__(**kwargs)

        # # print('running super(Gamepad, self).__init__()')

        # joystickhand and joystickrun
        self.joystickhand = Joystick(size_hint=(.4, .4),
                                     pos_hint={
                                         'x': 0.0,
                                         'y': .2
                                     },
                                     sticky=True)
        self.add_widget(self.joystickhand)
        self.joystickrun = Joystick(size_hint=(.4, .4),
                                    pos_hint={
                                        'x': 0.6,
                                        'y': .2
                                    })
        self.add_widget(self.joystickrun)

        # add some buttons
        self.catchbutton = Button(size_hint=(.15, .15),
                                  pos_hint={
                                      'x': .8,
                                      'y': .65
                                  },
                                  text='Catch me!')
        self.add_widget(self.catchbutton)

        # add debug Labels
        # self.debug_label = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .8, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label)
        # self.debug_label_hand = Label(size_hint=(.2, .2),
        #                               pos_hint={'x': .1, 'y': .8},
        #                               text='message ... ...',)
        # self.add_widget(self.debug_label_hand)
        # self.debug_label_run = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .5, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label_run)

        # bind joystick
        self.joystickrun.bind(pad=self.update_coordinates_run)
        self.joystickhand.bind(pad=self.update_coordinates_hand)

        # bind button
        self.catchbutton.bind(on_press=self.update_catch_release)

        self.old_headx = 0.0
        self.old_handy = 0.0
        self.old_turnx = 0.0
        self.old_runy = 0.0
        self.last_command_sent_at = 0.0
コード例 #3
0
 def build(self):
     self.root = BoxLayout()
     self.root.padding = 25
     joystick = Joystick()
     joystick.bind(pad=self.update_coordinates)
     self.root.add_widget(joystick)
     self.label = Label()
コード例 #4
0
    def __init__(self, **kwargs):
        super(RoboPad, self).__init__(**kwargs)

        print('running super(Gamepad, self).__init__()')

        # joystickhand and joystickhead
        self.joystickhand = Joystick(size_hint=(.4, .4),
                                     pos_hint={'x':0.0, 'y':.2})
        self.add_widget(self.joystickhand)
        self.joystickhead = Joystick(size_hint=(.4, .4),
                                     pos_hint={'x':0.6, 'y':.2})
        self.add_widget(self.joystickhead)

        # add some buttons
        self.catchbutton = Button(size_hint=(.15, .15),
                                  pos_hint={'x': .8, 'y': .65},
                                  text='Catch me!')
        self.add_widget(self.catchbutton)
コード例 #5
0
    def __init__(self, **kwargs):
        super(RoboPad, self).__init__(**kwargs)

        # print('running super(Gamepad, self).__init__()')

        # joystickhand and joystickrun
        # self.joystickhand = Joystick(size_hint=(.4, .4),
        #                              pos_hint={'x':0.0, 'y':.2},
        #                              sticky=True)
        # self.add_widget(self.joystickhand)
        self.joystickrun = Joystick(size_hint=(.4, .4),
                                    pos_hint={'x':0.6, 'y':.2})
        self.add_widget(self.joystickrun)

        # add some buttons
        # self.catchbutton = Button(size_hint=(.15, .15),
        #                           pos_hint={'x': .8, 'y': .65},
        #                           text='Catch me!')
        # self.add_widget(self.catchbutton)

        # add debug Labels
        self.debug_label = Label(size_hint=(.2, .2),
                                     pos_hint={'x': .8, 'y': .8},
                                     text='message ... ...',)  # multiline=True,)
        self.add_widget(self.debug_label)
        # self.debug_label_hand = Label(size_hint=(.2, .2),
        #                               pos_hint={'x': .1, 'y': .8},
        #                               text='message ... ...',)
        # self.add_widget(self.debug_label_hand)
        # self.debug_label_run = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .5, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label_run)
        
        # bind joystick
        self.joystickrun.bind(pad=self.update_coordinates_run)
コード例 #6
0
    def __init__(self, **kwargs):
        super(RoboPad, self).__init__(**kwargs)

        # # print('running super(Gamepad, self).__init__()')

        # joystickhand and joystickrun
        self.joystickhand = Joystick(size_hint=(.45, .45),
                                     pos_hint={
                                         'x': 0.0,
                                         'y': .2
                                     },
                                     sticky=True)
        self.add_widget(self.joystickhand)
        self.joystickrun = Joystick(size_hint=(.45, .45),
                                    pos_hint={
                                        'x': 0.6,
                                        'y': .2
                                    })
        self.joystickhand.bind(pad=self.update_coordinates_hand)

        self.add_widget(self.joystickrun)
        self.joystickrun.bind(pad=self.update_coordinates_run)

        # add some buttons
        self.catchbutton = Button(size_hint=(.15, .15),
                                  pos_hint={
                                      'x': .8,
                                      'y': .65
                                  },
                                  text='Catch me!')
        self.add_widget(self.catchbutton)
        self.catchbutton.bind(on_press=self.update_catch_release)

        # self.reset_stat_button = Button(size_hint=(.05, .05),
        #                                 pos_hint={'x': .6, 'y': .65},
        #                                 text='reset stat')
        # self.add_widget(self.reset_stat_button)
        # self.reset_stat_button.bind(on_press=self.reset_stat_button)

        # add debug Labels
        self.debug_label = Label(
            size_hint=(.4, .0),
            pos_hint={
                'x': .2,
                'y': .2
            },
            text='message ... ...',
        )  # multiline=True,)
        self.add_widget(self.debug_label)
        # self.debug_label_hand = Label(size_hint=(.2, .2),
        #                               pos_hint={'x': .1, 'y': .8},
        #                               text='message ... ...',)
        # self.add_widget(self.debug_label_hand)
        # self.debug_label_run = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .5, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label_run)

        # bind joystick

        # bind button

        self.slider_accept_command_timeout = Slider(size_hint=(.4, .03),
                                                    pos_hint={
                                                        'x': .1,
                                                        'y': .9
                                                    },
                                                    min=0.02,
                                                    max=0.2,
                                                    value=0.05)
        self.add_widget(self.slider_accept_command_timeout)
        self.slider_accept_command_timeout.bind(
            value=self.OnSliderAcccepptCommandTiteoutValueChange)

        self.slider_velocity_factor = Slider(size_hint=(.4, .03),
                                             pos_hint={
                                                 'x': .1,
                                                 'y': .85
                                             },
                                             min=0.01,
                                             max=10.0,
                                             value=0.3)
        self.add_widget(self.slider_velocity_factor)
        self.slider_velocity_factor.bind(
            value=self.OnSliderVelocityFactorValueChange)

        #  not used , just place holder
        self.slider_timeout_timer_start = Slider(size_hint=(.4, .03),
                                                 pos_hint={
                                                     'x': .1,
                                                     'y': .8
                                                 },
                                                 min=0.02,
                                                 max=0.2,
                                                 value=0.11)
        self.add_widget(self.slider_timeout_timer_start)
        self.slider_timeout_timer_start.bind(
            value=self.OnSliderTimeoutTimerStartValueChange)

        self.accept_command_timeout = 0.05  # 0.6 is too short, broke app!
        #
        # for slow motion 0.1 ok ok
        # for fast motiion 0.0.25 is not enough

        # self.timeout_slow = 0.14
        self.timeout_timer_start = 0.14
        self.velocity_factor = 0.3

        self.old_headx = 0.0
        self.old_handy = 0.0
        self.old_turnx = 0.0
        self.old_runy = 0.0
        self.last_command_sent_at = 0.0

        # self.current_hand_pos = {'headx': 0.0, 'handy': 0.0}
        # self.saved_hand_pos = {}
        # self.last_hand_move = {}
        # self.current_run_pos = {'turnx': 0.0, 'runy': 0.0}
        # self.saved_run_pos = {'turnx': 0.0, 'runy': 0.0}
        # self.last_run_move = {}

        self.current_pos = {
            'headx': 0.0,
            'handy': 0.0,
            'turnx': 0.0,
            'runy': 0.0
        }
        self.saved_pos = {
            'headx': 0.0,
            'handy': 0.0,
            'turnx': 0.0,
            'runy': 0.0
        }

        self.last_move = {
            'headx': 0.0,
            'handy': 0.0,
            'turnx': 0.0,
            'runy': 0.0
        }

        self.mean_time_send_command_data = 0.05
        self.counter_send_command_data = 1
        self.counter_commands = 1

        Clock.schedule_interval(self.timer, self.timeout_timer_start)
コード例 #7
0
    def __init__(self, **kwargs):
        super(RoboPad, self).__init__(**kwargs)

        # # print('running super(Gamepad, self).__init__()')

        # joystickhand and joystickrun
        self.joystickhand = Joystick(size_hint=(.5, .5),
                                     pos_hint={'x': .0, 'y': .0},
                                     sticky=True)
        self.add_widget(self.joystickhand)
        self.joystickrun = Joystick(size_hint=(.5, .5),
                                    pos_hint={'x': .5, 'y': .0})
        self.joystickhand.bind(pad=self.update_coordinates_hand)

        self.add_widget(self.joystickrun)
        self.joystickrun.bind(pad=self.update_coordinates_run)

        # add some buttons
        self.catchbutton = Button(size_hint=(.3, .1),
                                  pos_hint={'x': .7, 'y': .9},
                                  text='Catch me!')
        self.add_widget(self.catchbutton)
        self.catchbutton.bind(on_press=self.update_catch_release)

        self.dance_button = Button(size_hint=(.2, .1),
                                  pos_hint={'x': .4, 'y': .9},
                                  text='Dance!')
        self.add_widget(self.dance_button)
        self.dance_button.bind(on_press=self.update_dance)

        self.hiphop_dance = Button(size_hint=(.2, .1),
                                  pos_hint={'x': .1, 'y': .9},
                                  text='hip-hop!')
        self.add_widget(self.hiphop_dance)
        self.hiphop_dance.bind(on_press=self.update_hiphop)

        # self.reset_stat_button = Button(size_hint=(.05, .05),
        #                                 pos_hint={'x': .6, 'y': .65},
        #                                 text='reset stat')
        # self.add_widget(self.reset_stat_button)
        # self.reset_stat_button.bind(on_press=self.reset_stat_button)

        # add debug Labels
        self.debug_label = Label(size_hint=(.4, .0),
                                     pos_hint={'x': .2, 'y': .2},
                                     text='message ... ...',)  # multiline=True,)
        self.add_widget(self.debug_label)

        # self.debug_label_hand = Label(size_hint=(.2, .2),
        #                               pos_hint={'x': .1, 'y': .8},
        #                               text='message ... ...',)
        # self.add_widget(self.debug_label_hand)
        # self.debug_label_run = Label(size_hint=(.2, .2),
        #                              pos_hint={'x': .5, 'y': .8},
        #                              text='message ... ...',)  # multiline=True,)
        # self.add_widget(self.debug_label_run)

        # bind joystick



        # bind button


        self.slider_accept_command_timeout = Slider(size_hint=(.4, .03),
                                                    pos_hint={'x': .1,
                                                              'y': .9},
                                                    min=0.02,
                                                    max=0.2,
                                                    value=0.05)
        # self.add_widget(self.slider_accept_command_timeout)

        self.slider_accept_command_timeout.bind(value=self.OnSliderAcccepptCommandTiteoutValueChange)

        self.slider_velocity_factor = Slider(size_hint=(.4, .03),
                                                    pos_hint={'x': .1,
                                                              'y': .85},
                                                    min=0.01,
                                                    max=10.0,
                                                    value=0.3)
        # self.add_widget(self.slider_velocity_factor)

        self.slider_velocity_factor.bind(value=self.OnSliderVelocityFactorValueChange)

        #  not used , just place holder
        self.slider_timeout_timer_start = Slider(size_hint=(.4, .03),
                                                    pos_hint={'x': .1,
                                                              'y': .8},
                                                    min=0.02,
                                                    max=0.2,
                                                    value=0.11)
        # self.add_widget(self.slider_timeout_timer_start)

        self.slider_timeout_timer_start.bind(value=self.OnSliderTimeoutTimerStartValueChange)


        self.slider_gear_factor = Slider(size_hint=(.4, .03),
                                                    pos_hint={'x': .1,
                                                              'y': .8},
                                                    min=1,
                                                    max=5,
                                                    value=3)
        self.add_widget(self.slider_gear_factor)

        self.slider_gear_factor.bind(value=self.OnSliderGearFactorValueChange)

        self.accept_command_timeout = 0.05  # 0.6 is too short, broke app!
                            #
                            # for slow motion 0.1 ok ok
                            # for fast motiion 0.0.25 is not enough

        # self.timeout_slow = 0.14
        self.timeout_timer_start = 0.14
        self.velocity_factor = 0.3


        self.old_headx = 0.0
        self.old_handy = 0.0
        self.old_turnx = 0.0
        self.old_runy = 0.0
        self.last_command_compiled_before_send = time.time()
        self.last_command_sent_at = time.time()

        # self.current_hand_pos = {'headx': 0.0, 'handy': 0.0}
        # self.saved_hand_pos = {}
        # self.last_hand_move = {}
        # self.current_run_pos = {'turnx': 0.0, 'runy': 0.0}
        # self.saved_run_pos = {'turnx': 0.0, 'runy': 0.0}
        # self.last_run_move = {}

        self.mean_time_send_command_data = 0.0
        self.counter_send_command_data = 1
        self.counter_commands = 1

        self.dance = False
        self.hiphop = 1

        self.gear = 3

        self.robot_host = '192.168.4.1'  # hardcoded robot ip t4m net
        self.robot_port = 80

        self.current_pos = {'headx': 0.0, 'handy': 0.0, 'turnx': 0.0, 'runy': 0.0, 'gear': self.gear}
        self.saved_pos = {'headx': 0.0, 'handy': 0.0, 'turnx': 0.0, 'runy': 0.0, 'gear': self.gear}

        self.last_move = {'headx': 0.0, 'handy': 0.0, 'turnx': 0.0, 'runy': 0.0, 'gear': self.gear}

        self.saved_command = {'gear': self.gear}
        self.command_sent = True

        # self.SERVO_MIN = 35   # real servo min-max
        # self.SERVO_MAX = 125
        self.SERVO_MIN = 40     # compatible with 0.8.3.0.9
        self.SERVO_MAX = 117
        self.servo_center = self.SERVO_MAX - self.SERVO_MIN
        self.SERVO_NEAR_ZERO = 0.03
        self.SERVO_FACTOR = 1.3


        Clock.schedule_interval(self.timer_with_saved_params, self.timeout_timer_start)  # start afterburner