00001 #include "SIGEL_RobotIO/SIG_RobotCompilerObjects.h"
00002 #include "SIGEL_RobotIO/SIG_RobotIOExceptions.h"
00003 #include "SIGEL_Robot/SIG_Body.h"
00004
00005 using SIGEL_Robot::SIG_Body;
00006
00007 namespace SIGEL_RobotIO {
00008 SIG_RobotCompilerObjects::SIG_RobotCompilerObjects
00009 (SIG_RobotScanner &sc, SIG_Robot *tg, QString homepath)
00010 : SIG_RobotCompiler (sc, tg, homepath),
00011 linknumber (0),
00012 jointnumber (0),
00013 drivenumber (0),
00014 sensornumber (0)
00015 { }
00016
00017 SIG_RobotCompilerObjects::~SIG_RobotCompilerObjects (void)
00018 { }
00019
00020 SIG_Material *SIG_RobotCompilerObjects::materialFind (QString name)
00021 {
00022 if (target->lookupMaterial (name))
00023 throw SIG_SemanticError (__FILE__, __LINE__,
00024 "Duplicate material name '"+name+"'");
00025 SIG_Material *m = new SIG_Material (target, name);
00026 target->addMaterial (m);
00027 return m;
00028 }
00029
00030 void SIG_RobotCompilerObjects::materialDensity (SIG_Material *material,
00031 DL_Scalar density)
00032 {
00033 material->setDensity (density);
00034 }
00035
00036 void SIG_RobotCompilerObjects::materialFriction (SIG_Material *material,
00037 QString otherSide,
00038 DL_Scalar frictionconst)
00039 {
00040
00041 }
00042
00043 void SIG_RobotCompilerObjects::materialElasticity (SIG_Material *material,
00044 DL_Scalar elasconst)
00045 {
00046 material->setElasticity (elasconst);
00047 }
00048
00049 void SIG_RobotCompilerObjects::materialColour (SIG_Material *material,
00050 DL_Scalar red,
00051 DL_Scalar green,
00052 DL_Scalar blue)
00053 {
00054 material->setColour (DL_vector (red, green, blue));
00055 }
00056
00057 void SIG_RobotCompilerObjects::materialFinish (SIG_Material *material)
00058 {
00059
00060 }
00061
00062 SIG_Link *SIG_RobotCompilerObjects::linkFind (QString name)
00063 {
00064 if (target->lookupLink (name))
00065 throw SIG_SemanticError (__FILE__, __LINE__,
00066 "Duplicate link name '"+name+"'");
00067 SIG_Link *l = new SIG_Link (target, name, linknumber++);
00068 target->addLink (l);
00069 return l;
00070 }
00071
00072 void SIG_RobotCompilerObjects::linkIsTorso (SIG_Link *link)
00073 {
00074 if ((target->getRootLink () != 0) &&
00075 (target->getRootLink () != link))
00076 throw SIG_SemanticError (__FILE__, __LINE__,
00077 "Two different links are marked as torsos");
00078 target->setRootLink (link);
00079 }
00080
00081 void SIG_RobotCompilerObjects::linkGeometryFile (SIG_Link *link,
00082 QString geometryfile)
00083 {
00084 SIG_Body *b;
00085 if ((b = target->lookupBody (geometryfile)) == 0) {
00086 b = new SIG_Body (target, geometryfile, dirprefix);
00087 target->addBody (b);
00088 }
00089 link->setBody (b);
00090 b->addUsingLink (link);
00091 }
00092
00093 void SIG_RobotCompilerObjects::linkMaterial (SIG_Link *link,
00094 QString material)
00095 {
00096
00097 }
00098
00099 void SIG_RobotCompilerObjects::linkPoint (SIG_Link *link,
00100 QString pointname,
00101 DL_Scalar x,
00102 DL_Scalar y,
00103 DL_Scalar z)
00104 {
00105 link->addPoint (pointname, DL_vector (x, y, z));
00106 }
00107
00108 void SIG_RobotCompilerObjects::linkNoCollide (SIG_Link *link,
00109 QString nocollide)
00110 {
00111
00112 }
00113
00114 void SIG_RobotCompilerObjects::linkFinish (SIG_Link *link)
00115 {
00116
00117 }
00118
00119 SIG_RotationalJoint *SIG_RobotCompilerObjects::rjointFind (QString name)
00120 {
00121 if (target->lookupJoint (name))
00122 throw SIG_SemanticError (__FILE__, __LINE__,
00123 "Duplicate joint name '"+name+"'");
00124 SIG_RotationalJoint *j = new SIG_RotationalJoint (target, name,
00125 jointnumber++);
00126 target->addJoint (j);
00127 return j;
00128 }
00129
00130 void SIG_RobotCompilerObjects::rjointLinking (SIG_RotationalJoint *rj,
00131 QString Alink, QString AB, QString AD, QString AH,
00132 QString Blink, QString BB, QString BD, QString BH)
00133 {
00134
00135 }
00136
00137 void SIG_RobotCompilerObjects::rjointExtents (SIG_RotationalJoint *rj,
00138 DL_Scalar mn, DL_Scalar mx, DL_Scalar ii)
00139 {
00140 rj->setRange (mn, mx, ii);
00141 }
00142
00143 void SIG_RobotCompilerObjects::rjointFinish (SIG_RotationalJoint *rj)
00144 {
00145
00146 }
00147
00148 SIG_TranslationalJoint *SIG_RobotCompilerObjects::tjointFind (QString name)
00149 {
00150 if (target->lookupJoint (name))
00151 throw SIG_SemanticError (__FILE__, __LINE__,
00152 "Duplicate joint name '"+name+"'");
00153 SIG_TranslationalJoint *j = new SIG_TranslationalJoint (target, name,
00154 jointnumber++);
00155 target->addJoint (j);
00156 return j;
00157 }
00158
00159 void SIG_RobotCompilerObjects::tjointLinking (SIG_TranslationalJoint *tj,
00160 QString Alink, QString AB, QString AD, QString AF,
00161 QString Blink, QString BB, QString BD, QString BF)
00162 {
00163
00164 }
00165
00166 void SIG_RobotCompilerObjects::tjointExtents (SIG_TranslationalJoint *tj,
00167 DL_Scalar mn, DL_Scalar mx, DL_Scalar ii)
00168 {
00169 tj->setRange (mn, mx, ii);
00170 }
00171
00172 void SIG_RobotCompilerObjects::tjointFinish (SIG_TranslationalJoint *tj)
00173 {
00174
00175 }
00176
00177 SIG_CylindricalJoint *SIG_RobotCompilerObjects::cjointFind (QString name)
00178 {
00179 if (target->lookupJoint (name))
00180 throw SIG_SemanticError (__FILE__, __LINE__,
00181 "Duplicate joint name '"+name+"'");
00182 SIG_CylindricalJoint *cj = new SIG_CylindricalJoint (target, name,
00183 jointnumber++);
00184 target->addJoint (cj);
00185 return cj;
00186 }
00187
00188 void SIG_RobotCompilerObjects::cjointLinking (SIG_CylindricalJoint *cj,
00189 QString Alink, QString AB, QString AD, QString AH,
00190 QString Blink, QString BB, QString BD, QString BH)
00191 {
00192
00193 }
00194
00195 void SIG_RobotCompilerObjects::cjointRotExtents (SIG_CylindricalJoint *cj,
00196 DL_Scalar mn, DL_Scalar mx, DL_Scalar ii)
00197 {
00198 cj->setRotationalRange (mn, mx, ii);
00199 }
00200
00201 void SIG_RobotCompilerObjects::cjointTraExtents (SIG_CylindricalJoint *cj,
00202 DL_Scalar mn, DL_Scalar mx, DL_Scalar ii)
00203 {
00204 cj->setTranslationalRange (mn, mx, ii);
00205 }
00206
00207 void SIG_RobotCompilerObjects::cjointFinish (SIG_CylindricalJoint *cj)
00208 {
00209
00210 }
00211
00212 SIG_GlueJoint *SIG_RobotCompilerObjects::glueFind (QString name)
00213 {
00214 if (target->lookupJoint (name))
00215 throw SIG_SemanticError (__FILE__, __LINE__,
00216 "Duplicate joint name '"+name+"'");
00217 SIG_GlueJoint *gj = new SIG_GlueJoint (target, name, jointnumber++);
00218 target->addJoint (gj);
00219 return gj;
00220 }
00221
00222 void SIG_RobotCompilerObjects::glueLinking (SIG_GlueJoint *glue,
00223 QString Alink, QString AA, QString AB, QString AC,
00224 QString Blink, QString BP, QString BQ, QString BR)
00225 {
00226
00227 }
00228
00229 void SIG_RobotCompilerObjects::glueFinish (SIG_GlueJoint *glue)
00230 {
00231
00232 }
00233
00234 SIG_Drive *SIG_RobotCompilerObjects::driveFind (QString name)
00235 {
00236 if (target->lookupDrive (name))
00237 throw SIG_SemanticError (__FILE__, __LINE__,
00238 "Duplicate drive name '"+name+"'");
00239 SIG_Drive *d = new SIG_Drive (target, name, drivenumber++);
00240 target->addDrive (d);
00241 return d;
00242 }
00243
00244 void SIG_RobotCompilerObjects::driveMode (SIG_Drive *d, QString mode)
00245 {
00246 if (mode == "force")
00247 d->setMode (SIG_Drive::tForceMode);
00248 else if (mode == "relative")
00249 d->setMode (SIG_Drive::tRelativeMode);
00250 else if (mode == "absolute")
00251 d->setMode (SIG_Drive::tAbsoluteMode);
00252 else
00253 throw SIG_SemanticError (__FILE__, __LINE__,
00254 "Can't interpret drive mode '"+mode+"'");
00255 }
00256
00257 void SIG_RobotCompilerObjects::driveJoint (SIG_Drive *d, QString jointname)
00258 {
00259
00260 }
00261
00262 void SIG_RobotCompilerObjects::driveMinMaxForce (SIG_Drive *d,
00263 DL_Scalar minf, DL_Scalar maxf)
00264 {
00265 d->setForces (minf, maxf);
00266 }
00267
00268 void SIG_RobotCompilerObjects::driveFinish (SIG_Drive *d)
00269 {
00270
00271 }
00272
00273 SIG_JointSensor *SIG_RobotCompilerObjects::jointSensorFind (QString name)
00274 {
00275 if (target->lookupSensor (name))
00276 throw SIG_SemanticError (__FILE__, __LINE__,
00277 "Duplicate sensor name '"+name+"'");
00278 SIG_JointSensor *js = new SIG_JointSensor (target, name, sensornumber++);
00279 target->addSensor (js);
00280 return js;
00281 }
00282
00283 void SIG_RobotCompilerObjects::jointSensorJoint (SIG_JointSensor *js, QString jointname)
00284 {
00285
00286 }
00287
00288 void SIG_RobotCompilerObjects::jointSensorFinish (SIG_JointSensor *js)
00289 {
00290
00291 }
00292
00293 SIG_Geometry *SIG_RobotCompilerObjects::surfaceFind (QString name)
00294 {
00295 return new SIG_Geometry ();
00296 }
00297
00298 SIG_Polygon *SIG_RobotCompilerObjects::surfaceNewPoly (SIG_Geometry *g)
00299 {
00300 return new SIG_Polygon (g);
00301 }
00302
00303 void SIG_RobotCompilerObjects::surfaceNewPoint (SIG_Polygon *p,
00304 DL_Scalar x,
00305 DL_Scalar y,
00306 DL_Scalar z)
00307 {
00308 p->appendVertex (DL_vector (x, y, z));
00309 }
00310
00311 void SIG_RobotCompilerObjects::surfaceFinish (SIG_Geometry *g, QString name)
00312 {
00313 SIG_Body *b = target->lookupBody (name);
00314 if (!b)
00315 throw SIG_SemanticError (__FILE__, __LINE__,
00316 "There is no body with file \"" + name + "\"");
00317 b->setGeometry (g);
00318 }
00319
00320 void SIG_RobotCompilerObjects::modifierScaleall (DL_Scalar scalingFactor)
00321 {
00322
00323 }
00324 }