public static MotionPath readMotionPath(HierarchicalConfiguration config){ String name = XMLConfigUtils.getStringAttribute(config, MOTION_PATH_NAME, null); InterpolatorFactory factory = readInterpolatorVersion(config); MotionPath path = new MotionPath(factory); path.setName(name); HierarchicalConfiguration pointsConfig = config.configurationAt(CONTROL_POINTS); if(pointsConfig != null && !pointsConfig.isEmpty()){ path.addPoints(readControlPoints(pointsConfig)); } return path; }
/** * * @param xs * @param mp * @throws IOException */ public static void writeMotionPath(XmlSerializer xs, MotionPath mp) throws IOException{ xs.startTag(NAMESPACE, MOTION_PATH); String name = mp.getName(); if(name != null && !name.isEmpty()){ xs.attribute(NAMESPACE, MOTION_PATH_NAME, name); } XMLUtils.writeVersionProperty(xs, mp.getInterpolatorVersion(), INTERPOLATION_VERSION_TYPE); writeControlPoints(xs, mp.getControlPoints()); xs.endTag(NAMESPACE, MOTION_PATH); }
private static MotionPath unpackMotionPath(MotionPathRecord pathRec){ String interpName = pathRec.getInterpolator().getName(); String interpNumber = pathRec.getInterpolator().getVersionNumber(); VersionProperty interp = new VersionProperty(interpName, interpNumber); InterpolatorFactory fact = InterpolatorDirectory.instance().getFactory(interp); MotionPath path = new MotionPath(fact); path.setName(pathRec.getName()); int pointCount = pathRec.getControlPoints().size(); List<Point2D> points = new ArrayList<Point2D>(pointCount); for(ControlPointRecord pr : pathRec.getControlPoints()){ points.add(unpackControlPoint(pr)); } path.addPoints(points); if(pathRec.getStartTime() != null){ path.setStartTime(pathRec.getStartTime()); } if(pathRec.getStopTime() != null){ path.setStopTime(pathRec.getStopTime()); } return path; }
continue; MotionPath rampPath = new MotionPath(linearFact); rampPath.addPoint(0.0, cur); rampPath.addPoint(myRampTimeMillisec, start); CompiledPath ramp = rampPath.compilePath( 0, myRampTimeMillisec, myStepLengthMillisec); path.addAll(0, ramp);
private static MotionPathRecord packMotionPath(MotionPath path, int id){ MotionPathRecord pathRec = new MotionPathRecord(); pathRec.setName(path.getName()); pathRec.setMotionPathId(id); pathRec.setStartTime(path.getStartTime()); pathRec.setStopTime(path.getStopTime()); VersionProperty interpVersion = path.getInterpolatorVersion(); pathRec.setInterpolator(packInterpolatorType(interpVersion)); Schema arraySchema = Schema.createArray(ControlPointRecord.SCHEMA$); List<Point2D> pointList = path.getControlPoints(); GenericArray<ControlPointRecord> points = new Array<ControlPointRecord>(pointList.size(), arraySchema); for(Point2D p : pointList){ points.add(packControlPoint(p)); } pathRec.setControlPoints(points); return pathRec; }
getLogger().debug("Creating MotionPath for channel jointNum={}, name={}", jointNum, name); MotionPath path = new MotionPath(); path.addPoint(gotoRampMsec, defaultPosNorm.getValue()); break; case BAK_DANGER_YOGA: path.addPoint(500, defaultPosNorm.getValue()); path.addPoint(1500, 1.0); path.addPoint(2500, 0.0); path.addPoint(3500, defaultPosNorm.getValue()); break;
public static ConfigurationNode writeMotionPath(MotionPath mp){ if(mp == null){ return null; } ConfigurationNode node = XMLConfigUtils.node(MOTION_PATH); String name = mp.getName(); if(name != null && !name.isEmpty()){ node.addAttribute(XMLConfigUtils.node(MOTION_PATH_NAME, name)); } node.addChild(XMLConfigUtils.writeVersion(mp.getInterpolatorVersion(), INTERPOLATION_VERSION_TYPE)); node.addChild(writeControlPoints(mp.getControlPoints())); return node; }