def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create required services base = BaseClient(router) base_cyclic = BaseCyclicClient(router) # Example core success = True success &= example_move_to_home_position(base) success &= example_cartesian_action_movement(base, base_cyclic) success &= example_angular_action_movement(base) success &= example_move_to_home_position(base) success &= example_cartesian_trajectory_movement(base, base_cyclic) success &= example_angular_trajectory_movement(base) return 0 if success else 1
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: device_manager = DeviceManagerClient(router) device_config = DeviceConfigClient(router) vision_config = VisionConfigClient(router) # example core vision_device_id = example_vision_get_device_id(device_manager) if vision_device_id != 0: example_routed_vision_get_option_information( vision_config, vision_device_id) example_routed_vision_get_sensor_options_values( vision_config, vision_device_id) example_routed_vision_set_sensor_options_values( vision_config, vision_device_id) example_routed_vision_confirm_saved_sensor_options_values( vision_config, device_config, vision_device_id)
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() parser.add_argument("--cyclic_time", type=float, help="delay, in seconds, between cylic control call", default=0.001) parser.add_argument("--duration", type=int, help="example duration, in seconds (0 means infinite)", default=30) parser.add_argument("--print_stats", default=True, help="print stats in command line or not (0 to disable)", type=lambda x: (str(x).lower() not in ['false', '0', 'no'])) args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: with utilities.DeviceConnection.createUdpConnection(args) as router_real_time: example = TorqueExample(router, router_real_time) success = example.InitCyclic(args.cyclic_time, args.duration, args.print_stats) if success: while example.cyclic_running: try: time.sleep(0.5) except KeyboardInterrupt: break example.StopCyclic()
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() parser.add_argument( "--interface_name", type=str, help="Name of the network interface connected to the arm") parser.add_argument( "--device_ip_address", type=str, help= "IP address of the device connected to the arm (must be in sub-network 10.20.0.0/24" ) args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: example = EthernetBridgeConfigurationExample(router) example.EnableEthernetBridge()
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create required services base = BaseClient(router) base_cyclic = BaseCyclicClient(router) # Example core success = True success &= example_move_to_home_position(base) success &= example_cartesian_action_movement(base, base_cyclic) success &= example_angular_action_movement(base) # You can also refer to the 110-Waypoints examples if you want to execute # a trajectory defined by a series of waypoints in joint space or in Cartesian space return 0 if success else 1
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create the gpio bridge object. It implements kortex methods used # configure and use interconnect's expansion I2C bridge = I2CBridge(router) # This has to match the device's slave address (see data sheet) slave_address = 0x20 # Configure I2C bridge bridge.Configure(True, InterconnectConfig_pb2.I2C_MODE_FAST, InterconnectConfig_pb2.I2C_DEVICE_ADDRESSING_7_BITS) time.sleep(1) print("I2C bridge object initialized") # Read the state of the pins in bank 0 print("Reading byte array from interconnect I2C bus...") try: bytes_to_read = 1 bridge.ReadValue(slave_address, bytes_to_read, 100) time.sleep(0.5) except Exception as ex: print("Error : {}".format(ex)) # Send byte array to inverse polarity on half the pins print("Sending byte array to interconnect I2C bus...") try: # By looking at the data sheet, we see that to write to the polarity register, # we have to send command register 0x10 as the first byte, then our data byte buf = bytes([0x10, 0xAA]) bridge.WriteValue(slave_address, buf, 100) time.sleep(0.5) except Exception as ex: print("Error : {}".format(ex)) # Read the state of the pins in bank 0 # Half of them should be inverted now print("Reading byte array from interconnect I2C bus...") try: bytes_to_read = 1 bridge.ReadValue(slave_address, bytes_to_read, 100) time.sleep(0.5) except Exception as ex: print("Error : {}".format(ex))
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Example core example_api_creation(args)
def main(): sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) rospy.init_node("kinova_controller", anonymous=True) parser = argparse.ArgumentParser() parser.add_argument("--cyclic_time", type=float, help="delay, in seconds, between cylic control call", default=0.001) parser.add_argument("--duration", type=int, help="example duration, in seconds (0 means infinite)", default=30) parser.add_argument( "--print_stats", default=True, help="print stats in command line or not (0 to disable)", type=lambda x: (str(x).lower() not in ['false', '0', 'no'])) args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: with utilities.DeviceConnection.createUdpConnection( args) as router_real_time: myKinovaController = KinovaController(router, router_real_time) hover_shift = np.array([0, 0, 0.1]) usb_pos = np.array([0.5, 0, 0.1]) pcb_pos = np.array([0.3, 0, 0.1]) home = [0.3, 0, 0.2] #We are using single level servoing for arm control and low level servoing for gripper control #Switching between servoing mode causes robot viberating. We should change the servoing mode of gripper to single level servoing either. #TODO: Fix the servoing mode inconsistency before running this code. Current code may cause robot self-collision. myKinovaController.move_arm([home]) myKinovaController.gripper.open_gripper() myKinovaController.move_arm([usb_pos + hover_shift, usb_pos]) myKinovaController.gripper.close_gripper() myKinovaController.move_arm([ usb_pos + hover_shift, pcb_pos + hover_shift, pcb_pos + (hover_shift / 2) ]) myKinovaController.gripper.open_gripper() myKinovaController.move_arm([home]) print("Complete") exit() rospy.spin()
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: example = GripperCommandExample(router) example.ExampleSendGripperCommands()
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create required services base = BaseClient(router) # Example core example_call_rpc_using_options(base)
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create required services device_manager = DeviceManagerClient(router) device_config = DeviceConfigClient(router) # Example core example_routed_device_config(device_manager, device_config)
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create required services base = BaseClient(router) # Example core # Move to initial position move_to_home_position(base) # Move without the protection zone print_protection_zones(base) move_in_front_of_protection_zone(base) move_to_protection_zone(base) move_to_home_position(base) # Move with the protection zone print_protection_zones(base) move_in_front_of_protection_zone(base) # Add the protection zone handle = create_protection_zone(base) move_to_protection_zone(base) move_to_home_position(base) # Delete the protection zone base.DeleteProtectionZone(handle) # Print final protection zones # The example protection zone should be removed print_protection_zones(base)
def main(): # Import the utilities helper module sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments args = utilities.parseConnectionArguments() # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create required services base = BaseClient(router) # Example core success = True success &= example_forward_kinematics(base) success &= example_inverse_kinematics(base) return 0 if success else 1
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() parser.add_argument("--proportional_gain", type=float, help="proportional gain used in control loop", default=2.0) args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: with utilities.DeviceConnection.createUdpConnection( args) as router_real_time: kbhit = KBHit() example = GripperLowLevelExample(router, router_real_time, args.proportional_gain) print( "Press keys '0' to '9' to change gripper position. Press ESC to quit." ) while True: if kbhit.kbhit(): ch = kbhit.getch() if ord(ch) == 27: break elif ch >= '0' and ch <= '9': target_position = (float(ch) + 1) * 10.0 print("Going to position %i" % (target_position)) example.Goto(target_position) print("Target reached") time.sleep(0.2) example.Cleanup()
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create the gpio bridge object. It implements kortex methods used # configure and use interconnect's expansion GPIO bridge = GpioBridge(router) # Configure all interconnect's GPIO as push pull outputs bridge.InitGpioInputsAndOutputs() print ("GPIO bridge object initialized") # Example core bridge.ExampleSetAndReadValues()
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: # Create the bridge object. UARTBridge object implements kortex methods used # to create a TCP port bridge (port forwarding) between a port opened # on external adapter and the port opened on the interconnect. bridge = UARTBridge(router, args.ip) # Configure the expansion IO bridge.Configure(InterconnectConfig_pb2.UART_PORT_EXPANSION, True, Common_pb2.UART_SPEED_115200, Common_pb2.UART_WORD_LENGTH_8, Common_pb2.UART_STOP_BITS_1, Common_pb2.UART_PARITY_NONE) time.sleep(1) # Example core bridge.ExampleSendDataAndReadItBack() # Disable bridge on interconnect bridge.Configure(InterconnectConfig_pb2.UART_PORT_EXPANSION, False, Common_pb2.UART_SPEED_115200, Common_pb2.UART_WORD_LENGTH_8, Common_pb2.UART_STOP_BITS_1, Common_pb2.UART_PARITY_NONE)