Changeset 375 in flair-src
- Timestamp:
- Dec 9, 2020, 2:32:49 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/TwoWheelRobotCircleFollower/simulator/src/main.cpp
r371 r375 102 102 103 103 #ifdef GL 104 man = new Man("target",1);104 //man = new Man("target",1); 105 105 #endif 106 106 -
trunk/lib/FlairSimulator/src/Model_impl.cpp
r361 r375 229 229 // TODO: setEllipsoidRadius should be called in Model::setScale 230 230 // but we need to call recalculateBoundingBox 231 231 232 anim->setEllipsoidRadius(getTransformedBoundingBox().getExtent()); 232 233 233 234 if (anim->collisionOccurred() == true) { 234 235 vector3df pos; … … 238 239 nodePosition = getPosition(); 239 240 pos_rel = pos - nodePosition; 240 //printf("collision %f %f %f\n",pos.X,pos.Y,pos.Z);241 //printf("object %f %f %f\n",nodePosition.X,nodePosition.Y,nodePosition.Z);242 //printf("rel %f %f %f\n",pos_rel.X,pos_rel.Z,pos_rel.Y);241 //printf("collision %f %f %f\n",pos.X,pos.Y,pos.Z); 242 //printf("object %f %f %f\n",nodePosition.X,nodePosition.Y,nodePosition.Z); 243 //printf("rel %f %f %f\n",pos_rel.X,pos_rel.Z,pos_rel.Y); 243 244 244 245 collision_mutex->GetMutex(); -
trunk/lib/FlairSimulator/src/TwoWheelRobot.cpp
r372 r375 22 22 #include <GroupBox.h> 23 23 #include <math.h> 24 #include <SimuUgvControls.h> 24 25 #ifdef GL 25 26 #include <ISceneManager.h> … … 56 57 bodyColorB = new SpinBox(visual_tab->LastRowLastCol(), "arm color (B):", 0, 255, 1,0); 57 58 59 controls = new SimuUgvControls(this, name, modelId,0); 60 58 61 SetIsReady(true); 59 62 } 60 63 61 64 TwoWheelRobot::~TwoWheelRobot() { 62 // les objets irrlicht seront automatiquement detruits (moteurs, helices, 63 // pales) par parenté 65 // les objets irrlicht seront automatiquement detruits par parenté 64 66 } 65 67 … … 75 77 76 78 colored_body = geo->createCubeMesh(vector3df(100,100,100)); 79 colored_body->setBoundingBox(aabbox3df(0,0,0,1,1,1));//bug with bounding box? workaround is to reduce it... we use only wheel box 77 80 MeshSceneNode* mesh= new MeshSceneNode(this, colored_body); 78 81 … … 80 83 MeshSceneNode *l_wheel = new MeshSceneNode(this, wheel, vector3df(0, 50, -30),vector3df(0, 0, 0)); 81 84 MeshSceneNode *r_wheel = new MeshSceneNode(this, wheel, vector3df(0, -50-10, -30),vector3df(0, 0, 0)); 82 ExtraDraw(); 85 86 ExtraDraw(); 83 87 } 84 88 … … 147 151 // z down 148 152 void TwoWheelRobot::CalcModel(void) { 149 state[0].Pos.x=state[-1].Pos.x; 150 state[0].Pos.y=state[-1].Pos.y; 151 state[0].Vel.x = (state[0].Pos.x - state[-1].Pos.x) / dT(); 152 state[0].Vel.y = (state[0].Pos.y - state[-1].Pos.y) / dT(); 153 float speed=0.4, turn=0; 154 Time motorTime; 155 156 controls->GetControls(&speed,&turn,&motorTime); 157 158 // compute quaternion from W 159 // Quaternion derivative: dQ = 0.5*( Q*Qw) 160 state[0].W.x=0; 161 state[0].W.y=0; 162 state[0].W.z=turn; 163 Quaternion dQ = state[-1].Quat.GetDerivative(state[0].W); 164 165 // Quaternion integration 166 state[0].Quat = state[-1].Quat + dQ * dT(); 167 state[0].Quat.Normalize(); 168 169 Vector3D<double> dir = Vector3D<double>(speed,0,0); 170 dir.Rotate(state[0].Quat); 171 state[0].Pos = state[-1].Pos + dT() * dir; 172 153 173 154 //Printf("%f %f %f\n",state[0].Pos.x,state[-1].Pos.x,state[-2].Pos.x);155 174 /* 156 175 ** =================================================================== … … 159 178 ** =================================================================== 160 179 */ 161 state[0].Pos.z = 162 (dT() * dT() / m->Value()) * ( m->Value() * G) + 2 * state[-1].Pos.z - state[-2].Pos.z; 163 state[0].Vel.z = (state[0].Pos.z - state[-1].Pos.z) / dT(); 164 //Printf("%f %f %f\n",state[0].Pos.z,state[-1].Pos.z,state[-2].Pos.z); 165 #ifndef GL 166 if (state[0].Pos.z < 0) 167 state[0].Pos.z = 0; 168 #endif 180 state[0].Pos.z = (dT() * dT() / m->Value()) * ( m->Value() * G) + 2 * state[-1].Pos.z - state[-2].Pos.z; 169 181 state[0].Vel.z = (state[0].Pos.z - state[-1].Pos.z) / dT(); 170 182 } -
trunk/lib/FlairSimulator/src/TwoWheelRobot.h
r372 r375 29 29 } 30 30 namespace actuator { 31 class Simu Bldc;31 class SimuUgvControls; 32 32 } 33 33 } … … 65 65 gui::SpinBox *bodyColorR,*bodyColorG,*bodyColorB; 66 66 gui::DoubleSpinBox *size,*m; 67 actuator::SimuUgvControls *controls; 67 68 68 69
Note:
See TracChangeset
for help on using the changeset viewer.