def filter_CSV(filter_field, value): reader = CSV_Manager("./articles.csv") articles = reader.get_csv_as_dicts() manipulator = Manipulator(articles) filtered = manipulator.filter_by(filter_field, value) return list(filtered)
def __init__(self, sim, iktype=openravepy.IkParameterization.Type.Transform6D): Manipulator.__init__(self) self.simulated = sim self.iktype = iktype robot = self.GetRobot() env = robot.GetEnv() with env: dof_indices = self.GetIndices() accel_limits = robot.GetDOFAccelerationLimits() accel_limits[dof_indices[0:3]] = 1.2 accel_limits[dof_indices[3:6]] = 1.0 robot.SetDOFAccelerationLimits(accel_limits) # Load or_nlopt_ik as the IK solver. Unfortunately, IKFast doesn't work # on the Mico. if iktype is not None: self.iksolver = openravepy.RaveCreateIkSolver(env, 'NloptIK') self.SetIKSolver(self.iksolver) # Load simulation controllers. if sim: from prpy.simulation import ServoSimulator self.controller = robot.AttachController( self.GetName(), '', self.GetArmIndices(), 0, True) self.servo_simulator = ServoSimulator(self, rate=20, watchdog_timeout=0.1)
def test_input_11(self): man = Manipulator("integration.conf.json") man.generateSource() comp = CompilationEngine("integration.conf.json") comp.createExes() self.assertTrue(os.path.exists("./gcc/a.out")) comp.clear()
def run(filter_field, value): reader = CSV_Manager("./articles.csv") articles = reader.get_csv_as_dicts() manipulator = Manipulator(articles) filtered = manipulator.filter_by(filter_field, value) print(json.dumps(filtered, indent=2))
def checkRun(e, p, w): from gui import Gui if not os.path.exists(e.get()): Gui.alertErr("Error", "Configuration file not found", w) return try: conf = e.get() ce = CompilationEngine(conf) m = Manipulator(conf) p['value'] = 20 w.update_idletasks() m.generateSource() p['value'] = 40 w.update_idletasks() ce.createExes() p['value'] = 60 w.update_idletasks() complist = ce.getReport() vt = VirusTotal() p['value'] = 80 w.update_idletasks() report = vt.getScore(complist) p['value'] = 100 w.update_idletasks() str = "" i = 0 for x,y in complist.items(): str += "<{} : {}>\n".format(x,report[i]) i+=1 Gui.alertInfo("Result", str, w) except Exception as err: p['value'] = 0 w.update_idletasks() Gui.alertErr("Error", err, w)
def run(filter_field, value=None): reader = CSV_Manager("./articles.csv") if value != None: articles = reader.get_csv_as_dicts() manipulator = Manipulator(articles) filtered = manipulator.filter_by(filter_field, value) print(json.dumps(filtered, indent=2)) else: a = reader.map_author() print(json.dumps(a[filter_field], indent=2))
def map_author(self): with open(self.filename) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') rows = [row for row in csv_reader] articles = self.get_csv_as_dicts() manipulator = Manipulator(articles) a = {} b = rows.pop(0) for x in range(4): for j in rows: a[j[x]] = manipulator.filter_by(b[x], j[x]) return a
def run_avevasion(self, hexed_filename, config_filename, path): #pickup config file based on hexed_filename and execute shell #conf = Path("C:\\Users\\ozne2\\Desktop\\Tesi\\AVevasion\\Wrapper\\AVevasion\\app\\uploads\\"+hexed_filename+"\\config\\"+config_filename) conf = Path(path + "\\" + hexed_filename + "\\config\\" + config_filename) ce = CompilationEngine(conf) m = Manipulator(conf) m.generateSource() ce.createExes() complist = ce.getReport() print(os.path) global vt report = vt.getScore(complist) print(complist) print(report) return report
def register_controller(self, controller): blob_family = BlobFamily(self, len(self.controllers)) blob = Blob(self, self.__random_position(100), len(self.controllers), blob_family) blob_family.add_blob(blob) controller.set_manipulator(Manipulator(blob_family, self)) self.controllers.append(controller) self.blobs.append(blob) self.blob_families.append(blob_family)
def __init__(self, sim, owd_namespace, iktype=openravepy.IkParameterization.Type.Transform6D): Manipulator.__init__(self) self.simulated = sim self._iktype = iktype if iktype is not None: self._SetupIK(iktype) # Enable servo motions in simulation mode. self.controller = self.GetRobot().AttachController(name=self.GetName(), args='OWDController {0:s} {1:s}'.format('prpy', owd_namespace), dof_indices=self.GetArmIndices(), affine_dofs=0, simulated=sim ) if sim: from prpy.simulation import ServoSimulator self.servo_simulator = ServoSimulator( self, rate=20, watchdog_timeout=0.1)
def run(filter_field, value=False): reader = CSV_Manager("./articles.csv") if value: articles = reader.get_csv_as_dicts() manipulator = Manipulator(articles) filtered = manipulator.filter_by(filter_field, value) print(json.dumps(filtered, indent=2)) else: reader.read() manipulator = Manipulator(reader.mapped_dict) manipulator.relevant(filter_field)
def collect_items(show_video=True, record_video=False): manipulator = Manipulator() # set up items to be collected items = [{'size': 30, 'place': (210, EARTH_LEVEL), 'name': 'red', 'color': (35, 35, 215)}, {'size': 40, 'place': (250, EARTH_LEVEL), 'name': 'green', 'color': (50, 150, 0)}, {'size': 50, 'place': (300, EARTH_LEVEL), 'name': 'yellow', 'color': (25, 220, 230)}] dest_range = (350, 640) # generate random positions within dest_range # To make items not to be overlapping, first point positions in [0, free_size) interval are # generated, then every point expands to the required size (with spaces between points saved) range_size = dest_range[1] - dest_range[0] sum_size = sum(item['size'] for item in items) free_size = range_size - sum_size x_positions = dest_range[0] + np.random.randint(free_size, size=len(items)) for i, (item, pos) in enumerate(zip(items, x_positions)): x_positions[x_positions > pos] += item['size'] x_positions[i] += item['size'] // 2 for x, item in zip(x_positions, items): item['position'] = (x, EARTH_LEVEL - item['size'] // 2) # set up video showing and recording window = "collect items demo" if show_video else None writer = cv2.VideoWriter("collect items demo.avi", VIDEO_FOURCC, VIDEO_FPS, FRAME_RES) if record_video else None # collect items picker = Picker(manipulator, items, window, writer) picker.collect() if show_video: cv2.destroyWindow(window) if record_video: writer.release()
def test_input2(self): man = Manipulator("man-err2.conf.json") with self.assertRaises(ValueError): man.generateSource()
def test_input5(self): man = Manipulator("man-obbligatori1.conf.json") man.generateSource() self.assertTrue(os.path.exists("out.c")) os.remove("out.c")
def __init__(self, name, buffers, clusters, representative_buffers=None, colors=None, vol_shape=None, representatives_line_width=5.0, streamlines_line_width=2.0, representatives_alpha=1.0, streamlines_alpha=1.0, affine=None, verbose=False, clustering_parameter=None, clustering_parameter_max=None, full_dissimilarity_matrix=None): """StreamlineLabeler is meant to explore and select subsets of the streamlines. The exploration occurs through clustering in order to simplify the scene. """ # super(StreamlineLabeler, self).__init__(name) Actor.__init__(self, name) # direct call of the __init__ seems better in case of multiple inheritance if affine is None: self.affine = np.eye(4, dtype = np.float32) else: self.affine = affine if vol_shape is not None: I, J, K = vol_shape centershift = img_to_ras_coords(np.array([[I/2., J/2., K/2.]]), affine) centeraffine = from_matvec(np.eye(3), centershift.squeeze()) affine[:3,3] = affine[:3, 3] - centeraffine[:3, 3] self.glaffine = (GLfloat * 16)(*tuple(affine.T.ravel())) self.glaff = affine self.mouse_x=None self.mouse_y=None self.buffers = buffers self.clusters = clusters self.save_init_set = True # MBKM: Manipulator.__init__(self, initial_clusters=clusters, clustering_function=mbkm_wrapper) # We keep the representative_ids as list to preserve order, # which is necessary for presentation purposes: self.representative_ids_ordered = sorted(self.clusters.keys()) self.representatives_alpha = representatives_alpha # representative buffers: if representative_buffers is None: representative_buffers = compute_buffers_representatives(buffers, self.representative_ids_ordered) self.representatives_buffer = representative_buffers['buffer'] self.representatives_colors = representative_buffers['colors'] self.representatives_first = representative_buffers['first'] self.representatives_count = representative_buffers['count'] self.representatives = buffer2coordinates(self.representatives_buffer, self.representatives_first, self.representatives_count) # full tractography buffers: self.streamlines_buffer = buffers['buffer'] self.streamlines_colors = buffers['colors'] self.streamlines_first = buffers['first'] self.streamlines_count = buffers['count'] print('MBytes %f' % (self.streamlines_buffer.nbytes/2.**20,)) self.hide_representatives = False self.expand = False self.knnreset = False self.representatives_line_width = representatives_line_width self.streamlines_line_width = streamlines_line_width self.vertices = self.streamlines_buffer # this is apparently requested by Actor self.color_storage = {} # This is the color of a selected representative. self.color_selected = np.array([1.0, 1.0, 1.0, 1.0], dtype='f4') # This are the visualized streamlines. # (Note: maybe a copy is not strictly necessary here) self.streamlines_visualized_first = self.streamlines_first.copy() self.streamlines_visualized_count = self.streamlines_count.copy() # Clustering: self.clustering_parameter = clustering_parameter self.clustering_parameter_max = clustering_parameter_max self.full_dissimilarity_matrix = full_dissimilarity_matrix self.cantroi = 0
def test_input1(self): man = Manipulator("man-err1.conf.json") with self.assertRaises(KeyError): man.generateSource()
print("*** Position %d of %d ***" % (i, len(poss)-1)) m.move(poss[i].pos) time.sleep(1) while True: img = cam.read() retval, _, img2 = pose.find_chessboard(img, draw_axes=True) if retval: utils.imshow2(img2) utils.save(img) print("# chessboard found!") break else: utils.imshow2(img) print("# chessboard is not found, retrying ...") # ------------------------------------------------------ cam = Camera() pose = Pose() cal_scenario = Scenario(scenario_file) poss = cal_scenario.positions m = Manipulator(homing=False, dry_run=True) try: move_n_capture(m, poss, cam, pose): finally: # return to zero position m.move(poss[0].pos)
parse.add_argument('-i', '--init_pcap', type=str, default='./_empty.pcap', help="preparatory traffic (ignore this if you don't need)") parse.add_argument('-o', '--sta_file', type=str, default='./example/statistics.pkl', help="file saving the final statistics (.pkl)") arg = parse.parse_args() m = Manipulator(arg.mal_pcap, arg.mimic_set, arg.normalizer, arg.init_pcap) max_iter, particle_num, local_grp_size = 3, 6, 3 # max_iter,particle_num,local_grp_size = 4,8,4 # max_iter,particle_num,local_grp_size = 5,10,5 # max_iter,particle_num,local_grp_size = 3,10,5 m.change_particle_params(w=0.7298, c1=1.49618, c2=1.49618) m.change_pso_params(max_iter=max_iter, particle_num=particle_num, grp_size=local_grp_size) m.change_manipulator_params(grp_size=100, min_time_extend=3., max_time_extend=6., max_cft_pkt=1, max_crafted_pkt_prob=0.01)
import os from tools import init_logger, env_variable_to_int from manipulator import Manipulator MANIPULATOR_HOST = os.getenv('MANIPULATOR_HOST') MANIPULATOR_PORT = env_variable_to_int('MANIPULATOR_PORT') DEBUG_LOG = True if env_variable_to_int('DEBUG') else False if __name__ == '__main__': logger = init_logger('manipulator', '/var/log/manipulator/info.log', '/var/log/manipulator/debug.log', '/var/log/manipulator/error.log', DEBUG_LOG) logger.info('Manipulator app starting with the following params:' '\nMANIPULATOR_HOST: {}' '\nMANIPULATOR_PORT: {}' '\nDEBUG: {}'.format(MANIPULATOR_HOST, MANIPULATOR_PORT, DEBUG_LOG)) a = Manipulator(MANIPULATOR_HOST, MANIPULATOR_PORT, logger=logger) a.run_server()
# fall-through from axis movement commands return ('move', [axis, delta]) # def measure(scenario, m): # m.move(scenario.get_first_pos()) # for pos in scenario.positions[1:]: # pos.timing1 = m.measure1(pos.pos) # m.move(scenario.get_first_pos()) # for pos in scenario.positions[1:]: # pos.timing2 = m.measure2(pos.pos) # m.move(scenario.get_first_pos()) kb = KBHit() m = Manipulator(homing=False, dry_run=False) scenarios = [ Scenario('scenario-1.csv'), Scenario('scenario-2.csv'), Scenario('scenario-3.csv') ] curr_scenario = 0 scenario = scenarios[curr_scenario] pos = scenario.get_first_pos() m.move(pos.pos) while True: print("# %s line %d %s" % (scenario.file, pos.nline, pos.pos)) while not kb.kbhit():
def main(): sys.argv.append("robot_description:=panda/robot_description") sys.argv.append("joint_states:=panda/joint_states") sys.argv.append("move_group:=panda/move_group") sys.argv.append("pickup:=panda/pickup") sys.argv.append("place:=panda/place") sys.argv.append("execute_trajectory:=panda/execute_trajectory") #sys.argv.append("trajectory_execution_event:=panda/trajectory_execution_event") #sys.argv.append("collision_object:=panda/collision_object") #sys.argv.append("attached_collision_object:=panda/attached_collision_object") #sys.argv.append("error_recovery:=panda/error_recovery") #sys.argv.append("franka_gripper_node:=panda/franka_gripper_node") #sys.argv.append("joint_state_controller:=panda/franka_state_controller") #sys.argv.append("planning_scene:=panda/planning_scene") #sys.argv.append("planning_scene_world:=panda/planning_scene_world") #sys.argv.append("joint_trajectory_controller:=panda/position_joint_trajectory_controller") moveit_commander.roscpp_initialize(sys.argv) rospy.init_node('panda_shell', anonymous=True) manipulator = Manipulator() push_action = Push(manipulator) while True: raw = raw_input('panda@shell:$ ') if len(raw) == 0: continue cmd_input = raw.split(' ') cmd = cmd_input[0] if cmd == 'exit': break elif cmd == 'get_pose': print manipulator.arm.get_pose() elif cmd == 'get_rotation': print manipulator.arm.get_rotation() elif cmd == 'change_arm_joint_angles': args = cmd_input[1] angles = [float(num) for num in args.split(',')] manipulator.arm.change_joint_angles(angles) manipulator.arm.ang_cmd(angles, 5.0) elif cmd == 'test': manipulator.arm.test_joint_plan() elif cmd == 'get_joints': print manipulator.arm.get_joints(ik=False) elif cmd == 'go_home': manipulator.arm.go_home() elif cmd == 'execute_trajectory': args = cmd_input[1] angles = [float(num) for num in args.split(',')] manipulator.arm.execute_trajectory(angles, [1.0]) elif cmd == 'close_gripper': manipulator.hand.close_gripper() elif cmd == 'open_gripper': manipulator.hand.open_gripper() elif cmd == 'get_state': print manipulator.arm.get_state() elif cmd == 'test_poses_plan': p1 = [ 0.109784330654, -0.201825250008, 0.927634606574, 0.953892131709, -0.259908849954, 0.112249454584, 0.0996857598901 ] manipulator.arm.plan_poses([p1]) elif cmd == 'test_jt': # EXERCISE WITH CAUTION manipulator.arm.execute_trajectory( [[ -0.0029068310484290124, -0.5389024951798576, -0.32719744423457553, -1.0994862112317767, -0.46650070729425974, 0.8834752980981554, 0.6584624329124178 ], [ 0.6360157456696034, -0.1287396351950509, -0.854471571615764, -1.1812223290034702, -0.2326772375021662, 1.8844526242188044, 0.6579868964978627 ], [ 0.6102343267330101, 0.15414944928033011, -0.8639917395796095, -0.8486092205047607, -0.23309919845206398, 1.9201719971043723, 0.6168578206987253 ], [0, 0, 0, 0, 0, 0, 0.75]], [2, 4, 6, 9]) elif cmd == 'get_fk': print manipulator.arm.get_FK() elif cmd == 'get_ik': print manipulator.arm.get_joints(ik=True) elif cmd == 'home': manipulator.arm.execute_trajectory([[0, 0, 0, 0, 0, 0, 0.75]], [5]) elif cmd == 'gc': manipulator.arm.gravity_compensation() elif cmd == 'exit_gc': manipulator.arm.exit_gravity_compensation() elif cmd == 'close_gripper': manipulator.hand.close_gripper() elif cmd == 'open_gripper': manipulator.hand.open_gripper()
from yaml import safe_load from sys import exit from frontend import Frontend from manipulator import Manipulator from udp_comms import UDPComms if __name__ == "__main__": # TODO: XInput doesn't work with *nix devices, so we need to look into a different module try: with open("config/config.yml") as f: config = safe_load(f) except: print("Please copy config/template.yml to config/config.yml") exit(0) comms = UDPComms(config, debug=True) frontend = Frontend() manipulator = Manipulator() manipulator.start() frontend.start()
from werkzeug.wrappers import Request, Response from werkzeug.serving import run_simple from jsonrpc import JSONRPCResponseManager, dispatcher from manipulator import Manipulator from log import logger import logging from action.send_wx_message import send_wx_message from pyautogui import screenshot werkzeug_log = logging.getLogger("werkzeug") werkzeug_log.info = werkzeug_log.debug # 我的机械手 manipulator = Manipulator() @dispatcher.add_method def foobar(**kwargs): return kwargs["foo"] + kwargs["bar"] # 设置机械助手位置 def set_position(x, y): print('debug: 设置窗口位置', x, y) # 获取机械助手位置 def get_position(): return {
] objects = [ p.loadURDF("cube_small.urdf", 0.950000, -0.100000, 0.700000, 0.000000, 0.000000, 0.707107, 0.707107) ] objects = [ p.loadURDF("sphere_small.urdf", 0.850000, -0.400000, 0.700000, 0.000000, 0.000000, 0.707107, 0.707107) ] objects = [ p.loadURDF("duck_vhacd.urdf", 0.850000, -0.400000, 0.900000, 0.000000, 0.000000, 0.707107, 0.707107) ] # Initialize the manipulator class manipulator = Manipulator(jaco, cid, endEffectorIndex, 'p', [6, 7, 8]) #jointPositions=[ 0, 3.14, 3.14/2, -3.14/2, -3.14/2, 0, 0, 0, 0] #set joint position goal jointPositions = [0, 3.14, 3.14 / 2, -3.14 / 2, 0, 0, 0, 0, 0] # set joint position goal manipulator.set_joint_position_goal(jointPositions) manipulator.update() #update joint position time.sleep(1) pose = manipulator.get_end_effector_pose() goal_pos = pose[0:3] goal_rot = pose[3:7] while (1): # Check key press cmd = update_keys()
from pbm import Pbm from mask import Mask from manipulator import Manipulator from text import Text # Exemplo: Imagens/grupo_07_imagem_1_linhas_30_colunas_2_palavras_277.pbm path = input('Digite o caminho do arquivo: ') pbm = Pbm(path) mask = Mask('Mascaras/mask-dilation.txt') manipulator = Manipulator(pbm) manipulator.applyMedian() manipulator.applyDilation(mask) text = Text(pbm) text.markWords() text.showInfo() name = path.split('.')[0].split('/')[1] pbm.save(name)
p.configureDebugVisualizer(p.COV_ENABLE_SHADOWS, 0) p.setGravity(0, 0, -10) p.setRealTimeSimulation(1) # Get the current directory currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # get current directory # Spawn the Jaco manipulator armStartPos = [1, 0, 0.1] armStartOrientation = p.getQuaternionFromEuler([0, 0, 0]) endEffectorIndex = 8 jaco = [p.loadURDF(currentdir + "/models/urdf/jaco.urdf")] # load arm p.resetBasePositionAndOrientation(jaco[0], armStartPos, armStartOrientation) # Initialize the manipulator class manipulator = Manipulator(jaco, cid, endEffectorIndex, 'p') jointPositions = [0, 3.14, 3.14 / 2, -3.14 / 2, 0, 0, 0, 0, 0] # set joint position goal manipulator.set_joint_position_goal(jointPositions) manipulator.update() # update joint position time.sleep(1) # Spawn environment p.loadURDF("plane.urdf", 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000) # load plane #p.loadURDF("table/table.urdf", 0.500000,-0.200000,0.000000,0.000000,0.000000,0,1) #objects = [p.loadURDF("jenga/jenga.urdf", 1.300000,-0.700000,0.750000,0.000000,0.707107,0.000000,0.707107)] #objects = [p.loadURDF("jenga/jenga.urdf", 1.200000,-0.700000,0.750000,0.000000,0.707107,0.000000,0.707107)] #objects = [p.loadURDF("jenga/jenga.urdf", 1.100000,-0.700000,0.750000,0.000000,0.707107,0.000000,0.707107)] #objects = [p.loadURDF("jenga/jenga.urdf", 1.000000,-0.700000,0.750000,0.000000,0.707107,0.000000,0.707107)] #objects = [p.loadURDF("jenga/jenga.urdf", 0.900000,-0.700000,0.750000,0.000000,0.707107,0.000000,0.707107)] #objects = [p.loadSDF("kiva_shelf/model.sdf")] p.loadURDF("sphere2.urdf", 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000)
clear = True i += 1 elif sys.argv[i] == "--gui" or sys.argv[i] == "-G": some = True gui = True i += 1 if not some: usage() #main manageFlag() if gui: g = Gui() elif conf != "": ce = CompilationEngine(conf) m = Manipulator(conf) if clear: ce.clear() else: m.generateSource() ce.createExes() complist = ce.getReport() vt = VirusTotal() report = vt.getScore(complist) print(complist) print(report) else: usage()
def create_manipulator(urdf_path, ee_ind, base_pos, base_rot): jaco = [p.loadURDF(urdf_path)] # load arm p.resetBasePositionAndOrientation(jaco[0], base_pos, base_rot) manipulator = Manipulator(jaco, cid, ee_ind, 'p') return manipulator
import sys import os from manipulator import Manipulator # pylint: disable=no-name-in-module if __name__ == '__main__': for arg in sys.argv[1:]: if arg.find('--getdir') == 0: print Manipulator().get_data_path() run_test = False elif arg.find('--start') == 0: Manipulator().start() run_test = False elif arg.find('--stop') == 0: Manipulator().stop() run_test = False