Skip to content

Commit

Permalink
forcing the Abstract link to use doubles as its base unit to deal with
Browse files Browse the repository at this point in the history
the gcode devices needing to be in mm #26
  • Loading branch information
madhephaestus committed May 14, 2016
1 parent 9d6b256 commit c0ab54d
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 1,355 deletions.
46 changes: 0 additions & 46 deletions examples/java/src/com/neuronrobotics/test/nrdk/HexapodSimple.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import javafx.scene.transform.Affine;

import com.neuronrobotics.sdk.addons.kinematics.gcodebridge.IGcodeExecuter;
import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR;
import com.neuronrobotics.sdk.common.IFlushable;
import com.neuronrobotics.sdk.common.Log;
import com.neuronrobotics.sdk.pid.PIDLimitEvent;
import com.neuronrobotics.sdk.pid.PIDLimitEventType;
Expand All @@ -14,10 +16,10 @@
* The Class AbstractLink.
*/
// Kevin Shouldn't the Link's channel be kept in this level of Abstraction? The way I designg AbstractCartesianPositonDevice Requires this
public abstract class AbstractLink {
public abstract class AbstractLink implements IFlushable{

/** The target value. */
private int targetValue=0;
private double targetValue=0;

/** The target engineering units. */
private double targetEngineeringUnits=0;
Expand Down Expand Up @@ -122,15 +124,15 @@ public void flushAll(double time){
*
* @return the current position of the link
*/
public abstract int getCurrentPosition();
public abstract double getCurrentPosition();

/**
* To engineering units.
*
* @param value the value
* @return the double
*/
public double toEngineeringUnits(int value){
public double toEngineeringUnits(double value){
return ((value-getHome())*getScale());
}

Expand Down Expand Up @@ -236,7 +238,7 @@ public void setCurrentEngineeringUnits(double angle) {
* @return the current engineering units
*/
public double getCurrentEngineeringUnits(){
int link = getCurrentPosition();
double link = getCurrentPosition();
double back = toEngineeringUnits(link);
//Log.info("Link space: "+link+" Joint space: "+back);
return back;
Expand Down Expand Up @@ -323,7 +325,7 @@ protected void setPosition(int val) {
*
* @param val the new target value
*/
protected void setTargetValue(int val) {
protected void setTargetValue(double val) {
Log.info("Setting cached value :"+val);
this.targetValue = val;
for(LinkConfiguration c:slaveLinks){
Expand Down Expand Up @@ -383,7 +385,7 @@ protected void setTargetValue(int val) {
*
* @return the target value
*/
public int getTargetValue() {
public double getTargetValue() {
return targetValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void flushAllDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val=getChannel().getValue();
fireLinkListener(val);
return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void flushAllDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val=getChannel().getValue();
fireLinkListener(val);
return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void flushAllDevice(double time) {
}

@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.neuronrobotics.imageprovider.AbstractImageProvider;
import com.neuronrobotics.imageprovider.VirtualCameraFactory;
import com.neuronrobotics.sdk.addons.kinematics.gcodebridge.GcodeDevice;
import com.neuronrobotics.sdk.addons.kinematics.gcodebridge.GcodePrismatic;
import com.neuronrobotics.sdk.common.BowlerAbstractDevice;
import com.neuronrobotics.sdk.common.DeviceManager;
import com.neuronrobotics.sdk.common.IFlushable;
Expand Down Expand Up @@ -140,6 +141,31 @@ private AbstractLink getLinkLocal(LinkConfiguration c){

AbstractLink tmp=null;
Log.info("Loading link: "+c.getName()+" type = "+c.getType()+" device= "+c.getDeviceScriptingName());
String gcodeAxis = "";
switch(c.getType()){
case GCODE_STEPPER_PRISMATIC:
case GCODE_STEPPER_ROTORY:
case GCODE_STEPPER_TOOL:
switch(c.getHardwareIndex()){
case 0:
gcodeAxis=("X");
break;
case 1:
gcodeAxis=("Y");
break;
case 2:
gcodeAxis=("Z");
break;
case 3:
gcodeAxis=("E");
break;
default:
throw new RuntimeException("Gcode devices only support 4 axis");
}
break;
default:
break;
}
switch(c.getType()){


Expand Down Expand Up @@ -221,6 +247,9 @@ private AbstractLink getLinkLocal(LinkConfiguration c){
case GCODE_HEATER_TOOL:
break;
case GCODE_STEPPER_PRISMATIC:
if(getGCODE(c)!=null){
tmp = new GcodePrismatic(c,getGCODE(c),gcodeAxis);
}
break;
case GCODE_STEPPER_ROTORY:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class MockRotoryLink extends AbstractRotoryLink {

/** The val. */
int val=0;
double val=0;

/**
* Instantiates a new mock rotory link.
Expand Down Expand Up @@ -45,7 +45,7 @@ public void flushDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
// TODO Auto-generated method stub
return 35;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PidPrismaticLink(PIDChannel c,LinkConfiguration conf) {
*/
@Override
public void cacheTargetValueDevice() {
channel.setCachedTargetValue(getTargetValue());
channel.setCachedTargetValue((int)getTargetValue());
}

/* (non-Javadoc)
Expand All @@ -54,7 +54,7 @@ public void flushAllDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val=channel.GetPIDPosition();
fireLinkListener(val);
return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PidRotoryLink(PIDChannel c,LinkConfiguration conf) {
*/
@Override
public void cacheTargetValueDevice() {
channel.setCachedTargetValue(getTargetValue());
channel.setCachedTargetValue((int)getTargetValue());
}

/* (non-Javadoc)
Expand All @@ -53,7 +53,7 @@ public void flushAllDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val=channel.GetPIDPosition();
fireLinkListener(val);
return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ServoChannel getServoChannel() {
* Save.
*/
public void save() {
getServoChannel().SavePosition(getTargetValue());
getServoChannel().SavePosition((int)getTargetValue());
}


Expand All @@ -64,24 +64,24 @@ public void save() {
@Override
public void cacheTargetValueDevice() {
Log.debug("Caching servo value="+getTargetValue());
getServoChannel().SetPosition(getTargetValue());
getServoChannel().SetPosition((int)getTargetValue());
}

/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#flush(double)
*/
@Override
public void flushDevice(double time) {
getServoChannel().SetPosition(getTargetValue(),(float) time);
getServoChannel().SetPosition((int)getTargetValue(),(float) time);
getServoChannel().getChannel().flush();
fireLinkListener(getTargetValue());
fireLinkListener((int)getTargetValue());
}

/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val = getServoChannel().getValue();
fireLinkListener(val);
return val;
Expand All @@ -93,9 +93,9 @@ public int getCurrentPosition() {
@Override
public void flushAllDevice(double time) {
// TODO Auto-generated method stub
getServoChannel().SetPosition(getTargetValue(),(float) time);
getServoChannel().SetPosition((int)getTargetValue(),(float) time);
getServoChannel().getChannel().getDevice().flushCache((float)time);
fireLinkListener(getTargetValue());
fireLinkListener((int)getTargetValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ServoChannel getServoChannel() {
* Save.
*/
public void save() {
getServoChannel().SavePosition(getTargetValue());
getServoChannel().SavePosition((int)getTargetValue());
}


Expand All @@ -64,24 +64,24 @@ public void save() {
@Override
public void cacheTargetValueDevice() {
Log.debug("Caching servo value="+getTargetValue());
getServoChannel().SetPosition(getTargetValue());
getServoChannel().SetPosition((int)getTargetValue());
}

/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#flush(double)
*/
@Override
public void flushDevice(double time) {
getServoChannel().SetPosition(getTargetValue(),(float) time);
getServoChannel().SetPosition((int)getTargetValue(),(float) time);
getServoChannel().getChannel().flush();
fireLinkListener(getTargetValue());
fireLinkListener((int)getTargetValue());
}

/* (non-Javadoc)
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val = getServoChannel().getValue();
fireLinkListener(val);
return val;
Expand All @@ -93,9 +93,9 @@ public int getCurrentPosition() {
@Override
public void flushAllDevice(double time) {
// TODO Auto-generated method stub
getServoChannel().SetPosition(getTargetValue(),(float) time);
getServoChannel().SetPosition((int)getTargetValue(),(float) time);
getServoChannel().getChannel().getDevice().flushCache((float)time);
fireLinkListener(getTargetValue());
fireLinkListener((int)getTargetValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public StepperPrismaticLink(CounterOutputChannel chan, LinkConfiguration conf) {
*/
@Override
public void cacheTargetValueDevice() {
channel.setValue(getTargetValue());
channel.setValue((int)getTargetValue());
}

/* (non-Javadoc)
Expand All @@ -53,7 +53,7 @@ public void flushAllDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val=channel.getValue();
fireLinkListener(val);
return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public StepperRotoryLink(CounterOutputChannel chan, LinkConfiguration conf) {
*/
@Override
public void cacheTargetValueDevice() {
channel.setValue(getTargetValue());
channel.setValue((int)getTargetValue());
}

/* (non-Javadoc)
Expand All @@ -53,7 +53,7 @@ public void flushAllDevice(double time) {
* @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
*/
@Override
public int getCurrentPosition() {
public double getCurrentPosition() {
int val=channel.getValue();
fireLinkListener(val);
return val;
Expand Down
Loading

0 comments on commit c0ab54d

Please sign in to comment.