BowlerKernel
WalkingDriveEngine.java
Go to the documentation of this file.
1 package com.neuronrobotics.sdk.addons.kinematics;
2 
3 import java.util.ArrayList;
4 
5 import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR;
6 import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR;
7 import com.neuronrobotics.sdk.util.ThreadUtil;
8 
9 // TODO: Auto-generated Javadoc
13 public class WalkingDriveEngine implements IDriveEngine {
14 
16  double stepOverHeight=5;
17 
18  /* (non-Javadoc)
19  * @see com.neuronrobotics.sdk.addons.kinematics.IDriveEngine#DriveArc(com.neuronrobotics.sdk.addons.kinematics.MobileBase, com.neuronrobotics.sdk.addons.kinematics.math.TransformNR, double)
20  */
21  @Override
22  public void DriveArc(MobileBase source, TransformNR newPose, double seconds) {
23 
24  int numlegs = source.getLegs().size();
25  TransformNR [] feetLocations = new TransformNR[numlegs];
26  TransformNR [] home = new TransformNR[numlegs];
27  ArrayList<DHParameterKinematics> legs = source.getLegs();
28  // Load in the locations of the tips of each of the feet.
29  for(int i=0;i<numlegs;i++){
30  feetLocations[i]=legs.get(i).getCurrentPoseTarget();
31  home[i] = legs.get(i).calcHome();
32  }
33  //Apply transform to each dimention of current pose
35  global.translateX(newPose.getX());
36  global.translateY(newPose.getY());
37  global.translateZ(newPose.getZ());
38  double rotz = newPose.getRotation().getRotationAzimuth() +global.getRotation().getRotationAzimuth() ;
39  double roty = newPose.getRotation().getRotationElevation() ;
40  double rotx = newPose.getRotation().getRotationTilt() ;
41  global.setRotation(new RotationNR( rotx,roty, rotz) );
42  // New target calculated appliaed to global offset
43  source.setGlobalToFiducialTransform(global);
44  for(int i=0;i<numlegs;i++){
45  if(!legs.get(i).checkTaskSpaceTransform(feetLocations[i])){
46  //new leg position is not reachable, reverse course and walk up the line to a better location
47  do{
48  feetLocations[i].translateX(-newPose.getX());
49  feetLocations[i].translateY(-newPose.getY());
50  }while(legs.get(i).checkTaskSpaceTransform(feetLocations[i]));
51  //step back one increment for new location
52  feetLocations[i].translateX(newPose.getX());
53  feetLocations[i].translateY(newPose.getY());
54  //perform the step over
55  home[i].translateZ(stepOverHeight);
56  try {
57  // lift leg above home
58  legs.get(i).setDesiredTaskSpaceTransform(home[i], seconds/10);
59  ThreadUtil.wait((int) (seconds*100));
60  //step to new target
61  legs.get(i).setDesiredTaskSpaceTransform(feetLocations[i], seconds/10);
62  ThreadUtil.wait((int) (seconds*100));
63  //set new target for the coordinated motion step at the end
64  feetLocations[i].translateX(newPose.getX());
65  feetLocations[i].translateY(newPose.getY());
66  } catch (Exception e) {
67  // TODO Auto-generated catch block
68  e.printStackTrace();
69  }
70 
71  }
72 
73  }
74  //all legs have a valid target set, perform coordinated motion
75  for(int i=0;i<numlegs;i++){
76  try {
77  legs.get(i).setDesiredTaskSpaceTransform(feetLocations[i], seconds);
78  } catch (Exception e) {
79  // TODO Auto-generated catch block
80  e.printStackTrace();
81  }
82  }
83 
84 
85  }
86 
87  /* (non-Javadoc)
88  * @see com.neuronrobotics.sdk.addons.kinematics.IDriveEngine#DriveVelocityStraight(com.neuronrobotics.sdk.addons.kinematics.MobileBase, double)
89  */
90  @Override
91  public void DriveVelocityStraight(MobileBase source, double cmPerSecond) {
92  // TODO Auto-generated method stub
93 
94  }
95 
96  /* (non-Javadoc)
97  * @see com.neuronrobotics.sdk.addons.kinematics.IDriveEngine#DriveVelocityArc(com.neuronrobotics.sdk.addons.kinematics.MobileBase, double, double)
98  */
99  @Override
100  public void DriveVelocityArc(MobileBase source, double degreesPerSecond,
101  double cmRadius) {
102  // TODO Auto-generated method stub
103 
104  }
105 
106 
107 
108 }
void setGlobalToFiducialTransform(TransformNR frameToBase, boolean fireUpdate)
ArrayList< DHParameterKinematics > getLegs()
void DriveArc(MobileBase source, TransformNR newPose, double seconds)
void DriveVelocityStraight(MobileBase source, double cmPerSecond)
void DriveVelocityArc(MobileBase source, double degreesPerSecond, double cmRadius)