예제 #1
0
    def init_robot_com(self, HOST, ROBOT_PORT):
        logging.basicConfig(level=logging.INFO)

        conf = rtde_config.ConfigFile('record_configuration.xml')
        self.output_names, self.output_types = conf.get_recipe('out')

        self.robot_con = rtde.RTDE(HOST, ROBOT_PORT)

        try:
            self.robot_con.connect()

            # get controller version
            self.robot_con.get_controller_version()

            # setup recipes
            if not self.robot_con.send_output_setup(
                    self.output_names, self.output_types, frequency=500):
                logging.error('Unable to configure output')
                return

            # start data synchronization
            if not self.robot_con.send_start():
                logging.error('Unable to start synchronization')
                return

            self.robot_connected = True

        except:
            logging.error("Can not connect to the robot")
            return
예제 #2
0
def check_grasp():
    con = rtde.RTDE(HOST, 30004)
    con.connect()
    output_names = ['tool_analog_input0']
    output_types = ['DOUBLE']
    con.send_output_setup(output_names, output_types, frequency=125)
    con.send_start()
    state = con.receive(True)
    voltage = struct.unpack('!d', state)
    return voltage[0] > 0.3
예제 #3
0
parser.add_argument('--host', default='192.168.175.128', help='name of host to connect to (localhost)')
parser.add_argument('--port', type=int, default=30004, help='port number (30004)')
parser.add_argument('--samples', type=int, default=0, help='number of samples to record')
parser.add_argument('--frequency', type=int, default=125, help='the sampling frequency in Herz')
parser.add_argument('--config', default='record_configuration.xml', help='data configuration file to use (record_configuration.xml)')
parser.add_argument('--output', default='ursim_movel_x400.csv', help='data output file to write to (robot_data1.csv)')
parser.add_argument("--verbose", help="increase output verbosity", action="store_true")
args = parser.parse_args()

if args.verbose:
    logging.basicConfig(level=logging.INFO)

conf = rtde_config.ConfigFile(args.config)
output_names, output_types = conf.get_recipe('out')

con = rtde.RTDE(HOST, args.port)
con.connect()

# get controller version
con.get_controller_version()

# setup recipes
if not con.send_output_setup(output_names, output_types, frequency = args.frequency):
    logging.error('Unable to configure output')
    sys.exit()

#start data synchronization
if not con.send_start():
    logging.error('Unable to start synchronization')
    sys.exit()
예제 #4
0
        self.send_response(200)
        self.end_headers()

    # Add these headers to all responses
    def end_headers(self):
        self.send_header("Access-Control-Allow-Headers",
                         "Origin, X-Requested-With, Content-Type, Accept")
        self.send_header("Access-Control-Allow-Origin", "*")
        SimpleXMLRPCRequestHandler.end_headers(self)


conf = rtde_config.ConfigFile(
    "/home/administrator/husky_ws/src/ur_pick/node/ur5_interface_configuration.xml"
)
output_names, output_types = conf.get_recipe('out')
rtde_proxy = rtde.RTDE("192.168.1.20", 30004)
rtde_proxy.connect()
if not rtde_proxy.send_output_setup(output_names, output_types):
    print('wrong config file')
    exit()


def get_tcp_pose():
    rtde_proxy.send_start()
    state = rtde_proxy.receive()
    tcp_pose = state.actual_TCP_pose
    rtde_proxy.send_pause()
    print(tcp_pose)
    return tcp_pose

#Initial Values
datarate = 10  # Time interval for data logging in Hz

#######################################################

ROBOT_HOST = 'localhost'  #'192.168.1.103'
ROBOT_PORT = 30004
config_filename = 'control_loop_configuration.xml'

keep_running = True
#Initialize RTDE Connection
logging.getLogger().setLevel(logging.INFO)
conf = rtde_config.ConfigFile(config_filename)
state_names, state_types = conf.get_recipe('state')
watchdog_names, watchdog_types = conf.get_recipe('watchdog')
con = rtde.RTDE(ROBOT_HOST, ROBOT_PORT)
con.connect()
connected = con.is_connected()
if connected == True:
    print('Connected')

# get controller version
con.get_controller_version()

# setup recipes
con.send_output_setup(state_names, state_types)
watchdog = con.send_input_setup(watchdog_names, watchdog_types)

sensor_data = {}
# The function "rtde_set_watchdog" in the "rtde_control_loop.urp" creates a 1 Hz watchdog
watchdog.input_int_register_0 = 0