All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cogchar.api.animoid.protocol.JPRRFrame Maven / Gradle / Ivy

There is a newer version: 1.1.4
Show newest version
/*
 *  Copyright 2011 by The Cogchar Project (www.cogchar.org).
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.cogchar.api.animoid.protocol;

import java.util.List;

/**
 *
 * @author Stu B. 
 */
public class JPRRFrame extends Frame {

	public JVFrame makeVelFrame(double moveDurationSec) {
		JVFrame velFrame = new JVFrame();
		for (JointPositionRROM jprr : getAllPositions()) {
			double relPos = jprr.getPosRelROM();
			double vel = relPos / moveDurationSec;
			JointVelocityAROMPS jointVel = new JointVelocityAROMPS(jprr.getJoint(), vel);
			velFrame.addPosition(jointVel);
		}
		return velFrame;
	}

	public static JPRRFrame make(Frame f) {
		if (f instanceof JPRRFrame) {
			return (JPRRFrame) f;
		}
		JPRRFrame jprrf = new JPRRFrame();
		List jplist = f.getAllPositions();
		for(JointPosition jp : jplist) {
			JointPositionRROM jprr;
			if (jp instanceof JointPositionRROM) {
				jprr = (JointPositionRROM) jp;
			} else {
				jprr = new JointPositionRROM(jp);
			}
			jprrf.addPosition(jprr);
		}
		return jprrf;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy