Skip to content

Commit b4ba399

Browse files
committed
addin helper functions
1 parent 6f64eb8 commit b4ba399

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

src/main/java/com/neuronrobotics/sdk/addons/kinematics/DHParameterKinematics.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class DHParameterKinematics extends AbstractKinematicsNR
5454
public void onDisconnect(BowlerAbstractDevice source) {
5555
if (!disconnecting) {
5656
disconnecting = true;
57-
disconnect();
57+
//disconnect();
5858
}
5959

6060
}
@@ -703,4 +703,28 @@ public void onJointSpaceLimit(AbstractKinematicsNR source, int axis, JointLimit
703703

704704
}
705705

706+
// New helper functions
707+
708+
public TransformNR linkCoM( double linkAngleToClaculate ,int linkIndex) {
709+
//int linkIndex=1
710+
for(int i=0;i<5;i++) {
711+
try {
712+
double [] vectortail = getCurrentJointSpaceVector();
713+
vectortail[linkIndex]=linkAngleToClaculate;
714+
return getChain().getChain(vectortail).get(linkIndex).
715+
times(getLinkConfiguration(linkIndex).getCenterOfMassFromCentroid());
716+
}catch (Exception e) {
717+
try {
718+
Thread.sleep(0,20);
719+
} catch (InterruptedException e1) {
720+
// TODO Auto-generated catch block
721+
e1.printStackTrace();
722+
}
723+
}
724+
}
725+
throw new RuntimeException("Failed to compute CoM");
726+
}
727+
public TransformNR linkCoM(int linkIndex) {
728+
return linkCoM(getCurrentJointSpaceVector()[linkIndex],linkIndex);
729+
}
706730
}

0 commit comments

Comments
 (0)