Esempio n. 1
0
class UserInterface:
    def __init__(self):
        # Joystick
        self.joy = JoystickInterface()
        self.joy.disable_joy()

        # Sequence Manager
        sequences_dir = rospy.get_param("~sequences_dir")
        self.sequence_manager = SequenceManager(sequences_dir)

        # Sequence Action Server
        self.sequence_action_server = SequenceActionServer(
            self.sequence_manager)
        self.sequence_action_server.start()

        # Sequence Autorun
        self.sequence_autorun = SequenceAutorun()

        # Matlab node manager
        self.matlab_manager = MatlabManager()

        self.tcp_server = TcpServer()
        self.tcp_server.start()

    def shutdown(self):
        self.sequence_manager.shutdown()
        self.tcp_server.quit()
Esempio n. 2
0
    def __init__(self):
        self.gauss_ros_logger = RosLogger()

        # Joystick
        self.joy = JoystickInterface()
        self.joy.disable_joy()

        # Sequence Manager
        sequences_dir = rospy.get_param("~sequences_dir")
        self.sequence_manager = SequenceManager(sequences_dir,
                                                self.gauss_ros_logger)

        # Sequence Action Server
        self.sequence_action_server = SequenceActionServer(
            self.sequence_manager, self.gauss_ros_logger)
        self.sequence_action_server.start()

        # Sequence Autorun
        self.sequence_autorun = SequenceAutorun(self.gauss_ros_logger)

        #Matlab node manager
        #self.matlab_manager=MatlabManager()

        self.gauss_ros_logger.publish_log_status("INFO",
                                                 "UserInterface start over")
    def __init__(self):

        # Joystick
        self.joy = JoystickInterface()
        self.joy.disable_joy()

        # Blockly Server
        self.blockly_server = BlocklyActionServer()
        self.blockly_server.start()
class UserInterface:
    def __init__(self):

        # Joystick
        self.joy = JoystickInterface()
        self.joy.disable_joy()

        # Blockly Server
        self.blockly_server = BlocklyActionServer()
        self.blockly_server.start()

    def shutdown(self):
        self.blockly_server.shutdown()
Esempio n. 5
0
    def __init__(self):
        
        # Joystick
        self.joy = JoystickInterface()
        self.joy.disable_joy()
    
        # Sequence Manager
        sequences_dir = rospy.get_param("~sequences_dir")
        self.sequence_manager = SequenceManager(sequences_dir)

        # Sequence Action Server
        self.sequence_action_server = SequenceActionServer(self.sequence_manager)
        self.sequence_action_server.start()

        # Sequence Autorun
        self.sequence_autorun = SequenceAutorun()
Esempio n. 6
0
def main(use_imu=False):
    """Main program
    """

    # Create imu handle
    if use_imu:
        imu = IMU(port="/dev/ttyACM0")
        imu.flush_buffer()

    # Create controller and user input handles
    controller = Controller(
        config,
        solver.inverse_kinematics_body,
    )
    state = State()
    print("Creating joystick listener...")
    joystick_interface = JoystickInterface(config)
    print("Done.")

    last_loop = time.time()

    print("Summary of gait parameters:")
    print("overlap time: ", config.overlap_time)
    print("swing time: ", config.swing_time)
    print("z clearance: ", config.z_clearance)
    print("x shift: ", config.x_shift)

    # exit()

    # Wait until the activate button has been pressed
    while True:
        print("Waiting for L1 to activate robot.")
        while True:
            # break
            command = joystick_interface.get_command(state, True)
            # print(command)
            # joystick_interface.set_color(config.ps4_deactivated_color)
            if command.activate_event == 1:
                break
            time.sleep(0.1)
        print("Robot activated.")
        # joystick_interface.set_color(config.ps4_color)

        while True:
            now = time.time()
            if now - last_loop < config.dt:
                time.sleep(config.dt - (now - last_loop))
            last_loop = time.time()

            # Parse the udp joystick commands and then update the robot controller's parameters
            command = joystick_interface.get_command(state)
            if command.activate_event == 1:
                print("Deactivating Robot")
                break

            # Read imu data. Orientation will be None if no data was available
            quat_orientation = (imu.read_orientation()
                                if use_imu else np.array([1, 0, 0, 0]))
            state.quat_orientation = quat_orientation

            # Step the controller forward by dt
            controller.run(state, command)

            # Update the pwm widths going to the servos
            angles = []
            for leg in state.joint_angles:
                for i in leg:
                    angles.append(int(i / math.pi * 180))
            # print(angles)
            # print(angles, state.joint_angles)
            print(hardware_interface.set_actuator_postions(state.joint_angles))