com.neuronrobotics.sdk.addons.kinematics.ServoPrismaticLink Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-bowler Show documentation
Show all versions of java-bowler Show documentation
A command line utility for accesing the bowler framework.
package com.neuronrobotics.sdk.addons.kinematics;
import com.neuronrobotics.sdk.common.Log;
import com.neuronrobotics.sdk.dyio.peripherals.IServoPositionUpdateListener;
import com.neuronrobotics.sdk.dyio.peripherals.ServoChannel;
// TODO: Auto-generated Javadoc
/**
* The Class ServoPrismaticLink.
*/
public class ServoPrismaticLink extends AbstractPrismaticLink{
/** The srv. */
private ServoChannel srv;
/**
* Instantiates a new servo prismatic link.
*
* @param srv the srv
* @param conf the conf
*/
public ServoPrismaticLink(ServoChannel srv,LinkConfiguration conf) {
super(conf);
setServoChannel(srv);
}
/**
* Sets the servo channel.
*
* @param srv the new servo channel
*/
public void setServoChannel(ServoChannel srv) {
//System.out.println("Setting new servo channel: "+srv.getChannel().getNumber());
srv.getChannel().setCachedMode(true);
srv.addIServoPositionUpdateListener(new IServoPositionUpdateListener() {
@Override
public void onServoPositionUpdate(ServoChannel srv, int position,double time) {
fireLinkListener(position);
}
});
this.srv = srv;
}
/**
* Gets the servo channel.
*
* @return the servo channel
*/
public ServoChannel getServoChannel() {
return srv;
}
/**
* Save.
*/
public void save() {
getServoChannel().SavePosition((int)getTargetValue());
}
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#cacheTargetValueDevice()
*/
@Override
public void cacheTargetValueDevice() {
Log.debug("Caching servo value="+getTargetValue());
getServoChannel().SetPosition((int)getTargetValue());
}
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#flush(double)
*/
@Override
public void flushDevice(double time) {
getServoChannel().SetPosition((int)getTargetValue(),(float) time);
getServoChannel().getChannel().flush();
fireLinkListener((int)getTargetValue());
}
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public double getCurrentPosition() {
int val = getServoChannel().getValue();
fireLinkListener(val);
return val;
}
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#flushAll(double)
*/
@Override
public void flushAllDevice(double time) {
// TODO Auto-generated method stub
getServoChannel().SetPosition((int)getTargetValue(),(float) time);
getServoChannel().getChannel().getDevice().flushCache((float)time);
fireLinkListener((int)getTargetValue());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy