Skip to content

Commit c3b6946

Browse files
committed
add a recursive connect and a zero method
1 parent 4107124 commit c3b6946

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,4 +896,28 @@ public void removeVitamin(int index,VitaminLocation loc) {
896896
public IVitaminHolder getVitaminHolder(int index) {
897897
return getLinkConfiguration(index);
898898
}
899+
900+
@Override
901+
public boolean connect() {
902+
boolean back = super.connect();
903+
for(int i=0;i<getNumberOfLinks();i++) {
904+
MobileBase mb =getFollowerMobileBase(i);
905+
if(mb!=null) {
906+
mb.connect();
907+
}
908+
}
909+
return back;
910+
}
911+
912+
public void zero() throws Exception {
913+
double[] vect = getCurrentJointSpaceTarget();
914+
for(int i=0;i<getNumberOfLinks();i++) {
915+
vect[i]=0;
916+
MobileBase mb =getFollowerMobileBase(i);
917+
if(mb!=null) {
918+
mb.zero();
919+
}
920+
}
921+
setDesiredJointSpaceVector(vect,0);
922+
}
899923
}

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,4 +1146,49 @@ public void setConfigurationUpdate(Runnable configurationUpdate) {
11461146
this.configurationUpdate = configurationUpdate;
11471147
}
11481148

1149+
public DHParameterKinematics getLimbByName(String name) {
1150+
for(DHParameterKinematics d:getAllDHChains()) {
1151+
if(d.getScriptingName().contentEquals(name))
1152+
return d;
1153+
for(int i=0;i<d.getNumberOfLinks();i++) {
1154+
MobileBase mb= d.getSlaveMobileBase(i);
1155+
if(mb!=null) {
1156+
DHParameterKinematics test = mb.getLimbByName(name);
1157+
if(test!=null)
1158+
return test;
1159+
}
1160+
}
1161+
}
1162+
return null;
1163+
}
1164+
public void deleteLimbByName(String name) {
1165+
ArrayList<DHParameterKinematics> allDHChains = getAllDHChains();
1166+
for (int j = 0; j < allDHChains.size(); j++) {
1167+
DHParameterKinematics d = allDHChains.get(j);
1168+
if(d.getScriptingName().contentEquals(name)) {
1169+
if(legs.contains(d))
1170+
legs.remove(d);
1171+
if(appendages.contains(d))
1172+
appendages.remove(d);
1173+
if(drivable.contains(d))
1174+
drivable.remove(d);
1175+
if(steerable.contains(d))
1176+
steerable.remove(d);
1177+
return ;
1178+
}
1179+
for(int i=0;i<d.getNumberOfLinks();i++) {
1180+
MobileBase mb= d.getSlaveMobileBase(i);
1181+
if(mb!=null) {
1182+
mb.deleteLimbByName(name);
1183+
return;
1184+
}
1185+
}
1186+
}
1187+
}
1188+
1189+
public void zero() throws Exception {
1190+
for(DHParameterKinematics k:getAllDHChains()) {
1191+
k.zero();
1192+
}
1193+
}
11491194
}

0 commit comments

Comments
 (0)