Skip to content

Commit

Permalink
home links recoursivly to get follower links
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Mar 22, 2024
1 parent f883383 commit 016e116
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public CreaturePhysicsWidget(MobileBase base){

@Override
public void onDisconnect(BowlerAbstractDevice arg0) {
//BowlerStudio.runLater(()->{
stop();
//});
BowlerStudio.runLater(()->{
stopPhysics();
});
}

@Override
Expand Down Expand Up @@ -86,7 +86,7 @@ public void onConnect(BowlerAbstractDevice arg0) {}
});
runstop.setOnAction(event->{
if(isRun()){
stop();
stopPhysics();
// new Thread(){
// public void run(){
// ThreadUtil.wait(50);
Expand Down Expand Up @@ -134,7 +134,7 @@ public void run(){
mujoco.generateNewModel();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
e.printStackTrace(System.out);
close();
return;
} // generate model before start counting time
Expand Down Expand Up @@ -167,6 +167,7 @@ private void close() {
if(mujoco!=null)
mujoco.close();
mujoco=null;
stopPhysics();
}
}.start();

Expand All @@ -175,7 +176,7 @@ private void close() {
});

}
private void stop() {
private void stopPhysics() {
runstop.setGraphic(AssetFactory.loadIcon("Run.png"));
runstop.setText("Run");
if(physicsThread!=null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,23 @@ private void handle(final Button button) {
public void home() {

getMobilebase().setGlobalToFiducialTransform(new TransformNR());
for (DHParameterKinematics c : getMobilebase().getAllDHChains()) {
homeBase( getMobilebase());

}

private void homeBase(MobileBase mb) {
for (DHParameterKinematics c : mb.getAllDHChains()) {
homeLimb(c);
}
}

private void homeLimb(AbstractKinematicsNR c) {
private void homeLimb(DHParameterKinematics c) {
double[] joints = c.getCurrentJointSpaceVector();
for (int i = 0; i < c.getNumberOfLinks(); i++) {
joints[i] = 0;
if(c.getFollowerMobileBase(i)!=null) {
homeBase(c.getFollowerMobileBase(i));
}
}
try {
c.setDesiredJointSpaceVector(joints, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,27 @@ public void home() {
}).start();
}

private void homeLimb(AbstractKinematicsNR c) {
private void homeBase(MobileBase mb) {
for (DHParameterKinematics c : mb.getAllDHChains()) {
homeLimb(c);
}
}

TransformNR t = c.calcHome();
private void homeLimb(DHParameterKinematics c) {
double[] joints = c.getCurrentJointSpaceVector();
for (int i = 0; i < c.getNumberOfLinks(); i++) {
joints[i] = 0;
if(c.getFollowerMobileBase(i)!=null) {
homeBase(c.getFollowerMobileBase(i));
}
}
try {
c.setDesiredTaskSpaceTransform(t, 0);
c.setDesiredJointSpaceVector(joints, 0);
} catch (Exception e) {
double[] joints = c.getCurrentJointSpaceVector();
for (int i = 0; i < c.getNumberOfLinks(); i++) {
joints[i] = 0;
}
try {
c.setDesiredJointSpaceVector(joints, 0);
} catch (Exception ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
// TODO Auto-generated catch block
e.printStackTrace();
}

}

@Override
Expand Down

0 comments on commit 016e116

Please sign in to comment.