00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ROBOT_SIM_IKORTEST_
00026 #define _ROBOT_SIM_IKORTEST_
00027
00028 #include <robot/sim/sim>
00029
00030 #include <base/Externalizable>
00031 #include <base/Named>
00032 #include <base/Vector>
00033 #include <base/Time>
00034 #include <base/Trajectory>
00035 #include <base/PathName>
00036
00037 #include <robot/KinematicChain>
00038 #include <robot/sim/TestBasicEnvironment>
00039 #include <robot/sim/SimulatedBasicEnvironment>
00040 #include <robot/control/kinematics/InverseKinematicsSolver>
00041 #include <robot/control/kinematics/FullSpaceSolver>
00042 #include <robot/control/kinematics/BetaFormConstraints>
00043 #include <robot/control/kinematics/IKOR>
00044
00045 #include <set>
00046
00047
00048 namespace robot {
00049 namespace sim {
00050
00051
00052
00053
00054
00055
00056
00057
00058 class IKORTest : public base::Named, public base::Externalizable, public base::ReferencedObject
00059 {
00060 public:
00061 IKORTest(ref<base::VFile> testSpecification,
00062 ref<base::VFileSystem> fs, ref<base::Cache> cache);
00063
00064 virtual String className() const { return String("IKORTest"); }
00065
00066
00067
00068
00069
00070 class Test : public base::Named, public base::Externalizable
00071 {
00072 public:
00073 Test(const String& name = "");
00074
00075 virtual String className() const { return String("Test"); }
00076
00077
00078 bool initialConfigSpecified;
00079 base::Vector initq;
00080 base::Trajectory traj;
00081
00082 bool toolAttached;
00083 String toolName;
00084
00085 Robot::CoordFrame frame;
00086 bool timeIntervalSpecified;
00087 Vector timeInterval;
00088
00089 bool maxdxSpecified;
00090 Real maxdx;
00091
00092 bool orientationControl;
00093
00094 bool jointWeightsSpecified;
00095 base::Vector jointWeights;
00096
00097
00098 enum SolutionMethod { PseudoInverse, FullSpace };
00099
00100 SolutionMethod solutionMethod;
00101 robot::control::kinematics::InverseKinematicsSolver::OptimizationMethod optMethod;
00102 robot::control::kinematics::InverseKinematicsSolver::OptimizationCriterion optCriteria;
00103 robot::control::kinematics::InverseKinematicsSolver::OptimizationConstraints optConstraints;
00104
00105 bool resultsPresent;
00106
00107
00108 array<base::Vector> qs;
00109 array<base::Vector> xs;
00110 array<base::Vector> dxs;
00111 array<base::Vector> dqs;
00112 array<base::Time> times;
00113 array<base::Matrix> Js;
00114
00115 ManipulatorJointTrajectory jtraj;
00116
00117 bool testCompleted;
00118 String failureString;
00119
00120 base::PathName outputFileName;
00121 base::PathName inputFilePath;
00122
00123
00124
00125
00126 bool displayRangeSpecified;
00127 Int displayStartIndex , displayEndIndex;
00128
00129
00130
00131
00132 void saveResult(ref<base::VFileSystem> filesystem, base::PathName alternateOutputFileName = base::PathName());
00133
00134
00135 virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00136 { return ( (format=="xml") && (version==1.0) ); }
00137
00138 virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00139
00140 };
00141
00142
00143
00144
00145 ref<BasicEnvironment> getEnvironment() { return env; }
00146 ref<const BasicEnvironment> getEnvironment() const { return env; }
00147 void setEnvironment(ref<BasicEnvironment> env);
00148
00149
00150 ref<Robot> getRobot() { return narrow_ref<Robot>(env->getRobot(testRobotIndex)); }
00151 ref<const Robot> getRobot() const { return narrow_ref<const Robot>(env->getRobot(testRobotIndex)); }
00152
00153
00154 Int getManipulatorIndex() const { return testManipulatorIndex; }
00155
00156 Int numTests() const { return tests.size(); }
00157 Test& getTest(Int index) { Assert(index < numTests()); return tests[index]; }
00158
00159
00160 base::PathName getTestInputPath() const { return inputPath; }
00161
00162
00163
00164
00165
00166 void saveResults(bool saveTrajFiles = true, base::PathName alternateOutputFileName = base::PathName());
00167
00168
00169
00170
00171 bool displayObstacles;
00172 bool displayAxes;
00173 bool displayPlatform;
00174 bool displayEEPath;
00175 Int displayStepMod;
00176
00177
00178 base::Point3 lookAtTarget;
00179 Real alpha, theta, d;
00180
00181
00182
00183 virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00184 { return ( (format=="xml") && (version==1.0) ); }
00185
00186 virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00187
00188 protected:
00189 ref<base::VFileSystem> filesystem;
00190 ref<base::Cache> cache;
00191 ref<SimulatedBasicEnvironment> env;
00192 Int testRobotIndex;
00193 Int testManipulatorIndex;
00194
00195
00196 array<Test> tests;
00197 base::PathName inputPath;
00198
00199 };
00200
00201
00202 }
00203 }
00204
00205 #endif