コード例 #1
0
    void SphereApproximator::generateTetrahedron(GraphData& gd)
    {
        // vertices of a tetrahedron
        float fSqrt3 = sqrtf(3.0);
        Eigen::Vector3f v[4];

        setVec(v[0], fSqrt3, fSqrt3, fSqrt3);
        setVec(v[1], -fSqrt3, -fSqrt3, fSqrt3);
        setVec(v[2], -fSqrt3, fSqrt3, -fSqrt3);
        setVec(v[3], fSqrt3, -fSqrt3, -fSqrt3);

        for (int i = 0 ; i < 4 ; i++)
        {
            gd.vertices.push_back(v[i]);
        }

        // structure describing a tetrahedron
        MathTools::TriangleFace f[4];
        f[0].set(1, 2, 3);
        f[1].set(1, 4, 2);
        f[2].set(3, 2, 4);
        f[3].set(4, 1, 3);

        for (int i = 0 ; i < 4 ; i++)
        {
            f[i].id1--;
            f[i].id2--;
            f[i].id3--;
            gd.faces.push_back(f[i]);
        }
    }
コード例 #2
0
ファイル: graphik.cpp プロジェクト: jonas-amr/IWM_Prakt
// Konstruktor sensor, sensorana, aktor, Wstk, Basis
Graphik::Graphik(QString stlPfad, bool werkstueck)
{   
    this->stlPfad = stlPfad;           //nötig? ->ja
    //stlDateien laden, Werkstück tut dies in eigenem Konstruktor
    if(!werkstueck)
    {
        readSTL(&(this->triangleList), stlPfad);
    }

    setUrsprung(0,0,0);
    setVec(this->lokaleKoordinaten,0,0,0);
    setVec(this->parentKoordinaten,0,0,0);
    setVec(this->globaleKoordinaten,0,0,0);
    setVec(this->kontaktPkt, 0, 0, 0);

    //JH
    setRotAchse(0,0,0);
    setMinMaxDrehwinkel(0,0);
    Drehwinkel = 0;

    setVerschiebungsAchse(0,0,0);
    setMinMaxPos(0,0);
    Verschiebung = 0;
    //HJ

    farbe = 0;
    mitbewegt = false;

    //\todo Initialisierung Children!

    inkr = 0;
    richtung = DIR_STOP;
//    rotDurchgehend = false;
}
コード例 #3
0
ファイル: IO.cpp プロジェクト: jonas-amr/IWM_Prakt
GLfloat* norm(GLfloat *vec, GLfloat *result)
{
    GLfloat abs  = absVec(vec);
    if(abs == 1.0)
        return vec;
    if(abs != 0.0)
    {
        setVec(result, vec[0] / abs, vec[1] / abs, vec[2] / abs);
        return result;
    }
    setVec(result, 0.0, 0.0, 0.0);
    return result;
}
コード例 #4
0
		AngularMatrix::AngularMatrix(const gmtl::Vec3f& center, const float& range, uint32_t size)
		{
			this->center = center;
			this->range = range;
			this->size = size;
	
			matrix.resize(boost::extents[size][size][size][3]);
	
			minimum[0] = center[0]-(range/2.0f);
			minimum[1] = center[1]-(range/2.0f);
			minimum[2] = center[2]-(range/2.0f);

			maximum[0] = center[0]+(range/2.0f);
			maximum[1] = center[1]+(range/2.0f);
			maximum[2] = center[2]+(range/2.0f);
	
			delta = range/size;
	
			minimumPosition[0] = .100;
			minimumPosition[1] = .100;
			minimumPosition[2] = .250;

			maximumPosition[0] = -.100;
			maximumPosition[1] = -.100;
			maximumPosition[2] = 0.050;

			gmtl::Vec3f zero_vec(0,0,0);
			
			for (uint32_t i=0; i<size; i++)
				for (uint32_t j=0; j<size; j++)
					for (uint32_t k=0; k<size; k++)
					{
						setVec(i,j,k,zero_vec);
					}
		}
コード例 #5
0
ファイル: sensorana.cpp プロジェクト: jonas-amr/IWM_Prakt
void SensorAna::checkState()
{
    GLfloat wstUrspr[3];
    GLfloat wstDicke;

    for(int i = 0; i < this->wstkList->size(); i++)
    {
        setVec(wstUrspr,(*this->wstkList)[i]->getUrsprung());
        wstDicke = (*this->wstkList)[i]->getDicke();

        if(wstUrspr[1]+wstDicke-1.1*SPEED_FAHRSTUHL <= this->ursprung[1]+this->auslenkung &&
           wstUrspr[1]+wstDicke+1.1*SPEED_FAHRSTUHL >= this->ursprung[1]+this->auslenkung)
        {
            if(wstUrspr[1]+wstDicke<=this->ursprung[1])
            {
                continue;
            }
            if(pointInCircleXZ(wstUrspr,this->ursprung,(*this->wstkList)[i]->getRadius()))
            {
                this->auslenkung = wstUrspr[1]+wstDicke-this->ursprung[1];
                return;
            }
        }
    }
    this->auslenkung = 0;
}
コード例 #6
0
ファイル: graphik.cpp プロジェクト: jonas-amr/IWM_Prakt
// Parameter: globaleKoordinaten des Parent
void Graphik::aktualisiereKoordinaten(GLfloat *globalParent)
{   
    setVec(this->lokaleKoordinaten, this->VerschiebungsAchse[0] * this->Verschiebung,
                                    this->VerschiebungsAchse[1] * this->Verschiebung,
                                    this->VerschiebungsAchse[2] * this->Verschiebung);
    add(lokaleKoordinaten,ursprung,parentKoordinaten);
    add(globalParent,parentKoordinaten,globaleKoordinaten);
}
コード例 #7
0
ファイル: NConcept.cpp プロジェクト: dardevelin/neu
 void setSet(bool flag){
   if(flag){
     setAttribute_("set", true);
     setVec(true);
   }
   else{
     eraseAttribute_("set");
   }
 }
コード例 #8
0
ファイル: sensorana.cpp プロジェクト: jonas-amr/IWM_Prakt
SensorAna::SensorAna(QString path, QVector<Wstk*> *wstkList)
{
    readSTL(&(this->triangleList), path);
    this->wstkList = wstkList;
    this->auslenkung = 0;
    this->messwert = 0;
    this->uebertragungsFakor = 1;
    setVec(this->ursprung, 0, 0, 0);
}
コード例 #9
0
void StructuredLogEntry::setStackTrace(folly::StringPiece key,
                                       const StackTrace& st) {
  std::vector<folly::StringPiece> stackFrames;
  folly::split("\n", st.toString(), stackFrames);
  for (auto& frame : stackFrames) {
    const char* p = frame.begin();
    while (*p == '#' || *p == ' ' || (*p >= '0' && *p <= '9')) ++p;
    frame = folly::StringPiece(p, frame.end());
  }
  setVec(key, stackFrames);
}
コード例 #10
0
    void SphereApproximator::generateOctahedron(GraphData& gd)
    {
        // Six equidistant points lying on the unit sphere
        Eigen::Vector3f v[6];
        setVec(v[0], 1, 0, 0);
        setVec(v[1], -1, 0, 0);
        setVec(v[2], 0, 1, 0);
        setVec(v[3], 0, -1, 0);
        setVec(v[4], 0, 0, 1);
        setVec(v[5], 0, 0, -1);

        for (int i = 0 ; i < 6 ; i++)
        {
            gd.vertices.push_back(v[i]);
        }

        // Join vertices to create a unit octahedron
        MathTools::TriangleFace f[8];
        f[0].set(1, 5, 3);
        f[1].set(3, 5, 2);
        f[2].set(2, 5, 4);
        f[3].set(4, 5, 1);
        f[4].set(1, 3, 6);
        f[5].set(3, 2, 6);
        f[6].set(2, 4, 6);
        f[7].set(4, 1, 6);

        for (int i = 0 ; i < 8 ; i++)
        {
            f[i].id1--;
            f[i].id2--;
            f[i].id3--;
            gd.faces.push_back(f[i]);
        }
    }
コード例 #11
0
ファイル: sensorana.cpp プロジェクト: jonas-amr/IWM_Prakt
void SensorAna::display()
{
    this->checkState();
    GLfloat ursprung_neu[3];

    glPushMatrix();

    setVec(ursprung_neu, this->ursprung);

    ursprung_neu[0] = this->ursprung[0];
    ursprung_neu[1] = this->ursprung[1] + this->auslenkung;
    ursprung_neu[2] = this->ursprung[2];

    glTranslatef(ursprung_neu[0], ursprung_neu[1], ursprung_neu[2]);

    this->paint(COL_METALL);
    glPopMatrix();
}
コード例 #12
0
ファイル: v3math.cpp プロジェクト: HizWylder/GIS
const LLVector3& LLVector3::transVec(const LLMatrix4& mat)
{
	setVec(
			mV[VX] * mat.mMatrix[VX][VX] + 
			mV[VY] * mat.mMatrix[VX][VY] + 
			mV[VZ] * mat.mMatrix[VX][VZ] +
			mat.mMatrix[VX][VW],
			 
			mV[VX] * mat.mMatrix[VY][VX] + 
			mV[VY] * mat.mMatrix[VY][VY] + 
			mV[VZ] * mat.mMatrix[VY][VZ] +
			mat.mMatrix[VY][VW],

			mV[VX] * mat.mMatrix[VZ][VX] + 
			mV[VY] * mat.mMatrix[VZ][VY] + 
			mV[VZ] * mat.mMatrix[VZ][VZ] +
			mat.mMatrix[VZ][VW]);

	return *this;
}
コード例 #13
0
		bool AngularMatrix::setPosition(const gmtl::Point3f& position)
		{
			Angle allAngle = InverseKinematic::calculate(position);
	
			gmtl::Vec3f angle(allAngle.theta1[0],allAngle.theta1[1],allAngle.theta1[2]);
	
			//std::cout << position[0] << ":" << position[1] << ":" << position[2] << std::endl;
			//std::cout << angle[0] << ":" << angle[1] << ":" << angle[2] << std::endl;
			if (angle[0]>=minimum[0] && angle[0]<=maximum[0] && 
				angle[1]>=minimum[1] && angle[1]<=maximum[1] &&
				angle[2]>=minimum[2] && angle[2]<=maximum[2])
			{
				int a = (int)((angle[0]-minimum[0])/delta);
				int b = (int)((angle[0]-minimum[0])/delta);
				int c = (int)((angle[0]-minimum[0])/delta);
				if (a<0 || b<0 || c<0 || a>size || b>size || c>size) exit(-1);
				setVec((int)((angle[0]-minimum[0])/delta),
					   (int)((angle[1]-minimum[1])/delta),
					   (int)((angle[2]-minimum[2])/delta),
					   position);
		
				if (position[0] < minimumPosition[0]) 
					minimumPosition[0] = position[0];
				if (position[1] < minimumPosition[1]) 
					minimumPosition[1] = position[1];
				if (position[2] < minimumPosition[2]) 
					minimumPosition[2] = position[2];
		
				if (position[0] > maximumPosition[0]) 
					maximumPosition[0] = position[0];
				if (position[1] > maximumPosition[1]) 
					maximumPosition[1] = position[1];
				if (position[2] > maximumPosition[2]) 
					maximumPosition[2] = position[2];

				return true;
			}
			return false;
		}
コード例 #14
0
ファイル: IO.cpp プロジェクト: jonas-amr/IWM_Prakt
GLfloat* diff(GLfloat *v1, GLfloat *v2, GLfloat *result)
{
    setVec(result, v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]);
    return result;
}
コード例 #15
0
ファイル: IO.cpp プロジェクト: jonas-amr/IWM_Prakt
GLfloat* scalMult(GLfloat faktor, GLfloat *v, GLfloat *result)
{
    setVec(result, faktor * v[0], faktor * v[1], faktor * v[2]);
    return result;
}
コード例 #16
0
ファイル: IO.cpp プロジェクト: jonas-amr/IWM_Prakt
GLfloat* vecProd(GLfloat *v1, GLfloat *v2, GLfloat *result)
{
    setVec( result, v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2], v1[0] * v2[1] - v1[1] * v2[0]);
    return result;
}
コード例 #17
0
ファイル: fib.cpp プロジェクト: hsk/docs
 Fib2* newFib2_Int() {
   Fib2 *impl = new Fib2();
   setVec(Fib2_v, Int_classId, (void*)impl);
   impl->fib = &Fib2_Int_fib;
   return impl;
 }
コード例 #18
0
ファイル: fib.cpp プロジェクト: hsk/docs
 Fib3* newFib3_Int3() {
   Fib3 *impl = new Fib3();
   setVec(Fib3_v, Int3_classId, (void*)impl);
   impl->fib = &Fib3_Int3_fib;
   return impl;
 }
コード例 #19
0
ファイル: graphik.cpp プロジェクト: jonas-amr/IWM_Prakt
// Ursprung festlegen
void Graphik::setUrsprung(GLfloat x, GLfloat y, GLfloat z)
{
    setVec(this->ursprung, x, y, z);
}
コード例 #20
0
ファイル: http-server.cpp プロジェクト: shantanusharma/hhvm
void HttpServer::runOrExitProcess() {
  if (StaticContentCache::TheFileCache &&
      StructuredLog::enabled() &&
      StructuredLog::coinflip(RuntimeOption::EvalStaticContentsLogRate)) {
    CacheManager::setLogger([](bool existsCheck, const std::string& name) {
        auto record = StructuredLogEntry{};
        record.setInt("existsCheck", existsCheck);
        record.setStr("file", name);
        bool needsCppStack = true;
        if (!g_context.isNull()) {
          VMRegAnchor _;
          if (vmfp()) {
            auto const bt =
              createBacktrace(BacktraceArgs().withArgValues(false));
            std::vector<std::string> frameStrings;
            std::vector<folly::StringPiece> frames;
            for (int i = 0; i < bt.size(); i++) {
              auto f = bt.rvalAt(i).toArray();
              if (f.exists(s_file)) {
                std::string s = f.rvalAt(s_file).toString().toCppString();
                if (f.exists(s_line)) {
                  s += folly::sformat(":{}", f.rvalAt(s_line).toInt64());
                }
                frameStrings.emplace_back(std::move(s));
                frames.push_back(frameStrings.back());
              }
            }
            record.setVec("stack", frames);
            needsCppStack = false;
          }
        }
        if (needsCppStack) {
          record.setStackTrace("stack", StackTrace{StackTrace::Force{}});
        }
        StructuredLog::log("hhvm_file_cache", record);
      });
  }
  auto startupFailure = [] (const std::string& msg) {
    Logger::Error(msg);
    Logger::Error("Shutting down due to failure(s) to bind in "
                  "HttpServer::runAndExitProcess");
    // Logger flushes itself---we don't need to run any atexit handlers
    // (historically we've mostly just SEGV'd while trying) ...
    _Exit(1);
  };

  if (!RuntimeOption::InstanceId.empty()) {
    std::string msg = "Starting instance " + RuntimeOption::InstanceId;
    if (!RuntimeOption::DeploymentId.empty()) {
      msg += " from deployment " + RuntimeOption::DeploymentId;
    }
    Logger::Info(msg);
  }

  m_watchDog.start();

  if (RuntimeOption::ServerPort) {
    if (!startServer(true)) {
      startupFailure("Unable to start page server");
      not_reached();
    }
    Logger::Info("page server started");
  }

  StartTime = time(nullptr);

  if (RuntimeOption::AdminServerPort) {
    if (!startServer(false)) {
      startupFailure("Unable to start admin server");
      not_reached();
    }
    Logger::Info("admin server started");
  }

  for (unsigned int i = 0; i < m_satellites.size(); i++) {
    std::string name = m_satellites[i]->getName();
    try {
      m_satellites[i]->start();
      Logger::Info("satellite server %s started", name.c_str());
    } catch (Exception &e) {
      startupFailure(
        folly::format("Unable to start satellite server {}: {}",
                      name, e.getMessage()).str()
      );
      not_reached();
    }
  }

  if (!Eval::Debugger::StartServer()) {
    startupFailure("Unable to start debugger server");
    not_reached();
  } else if (RuntimeOption::EnableDebuggerServer) {
    Logger::Info("debugger server started");
  }

  try {
    InitFiniNode::ServerInit();
  } catch (std::exception &e) {
    startupFailure(
      folly::sformat("Exception in InitFiniNode::ServerInit(): {}",
                     e.what()));
  }

  {
    BootStats::mark("servers started");
    Logger::Info("all servers started");
    createPid();
    Lock lock(this);
    BootStats::done();
    // continously running until /stop is received on admin server, or
    // takeover is requested.
    while (!m_stopped) {
      wait();
    }
    if (m_stopReason) {
      Logger::Warning("Server stopping with reason: %s\n", m_stopReason);
    }
    // if we were killed, bail out immediately
    if (m_killed) {
      Logger::Info("page server killed");
      return;
    }
  }

  if (RuntimeOption::ServerPort) {
    Logger::Info("stopping page server");
    m_pageServer->stop();
  }
  onServerShutdown();

  EvictFileCache();

  waitForServers();
  m_watchDog.waitForEnd();
  playShutdownRequest(RuntimeOption::ServerCleanupRequest);
  hphp_process_exit();
  Logger::Info("all servers stopped");
}
コード例 #21
0
ファイル: graphik.cpp プロジェクト: jonas-amr/IWM_Prakt
// Lege die rotatorische Bewegungsrichtung fest
void Graphik::setRotAchse(GLfloat x, GLfloat y, GLfloat z)
{
    setVec(RotAchse,x,y,z);
    norm(this->RotAchse, this->RotAchse);       //aus wstk.cpp übernommen
}
コード例 #22
0
ファイル: graphik.cpp プロジェクト: jonas-amr/IWM_Prakt
//überhaupt nötig?
void Graphik::aktualisiereDrehung()
{
    setVec(lokaleDrehung,RotAchse[0]*Drehwinkel,
                         RotAchse[1]*Drehwinkel,
                         RotAchse[2]*Drehwinkel);
}
コード例 #23
0
ファイル: test.cpp プロジェクト: nealseegmiller/wmrde
void test_simulate() {

	//options
	bool do_dyn = true; //do dynamic simulation, else kinematic
	bool ideal_actuators = true;
	bool do_anim = true; //do animation
	bool do_time = false;

	const Real dt = .04;
	const int nsteps = (int) floor(10.0/dt);
	Real time = 0;

	//for allocation
	const int MAXNS = NUMSTATE(WmrModel::MAXNF);
	const int MAXNV = NUMQVEL(WmrModel::MAXNF);
	const int MAXNY = MAXNS+MAXNV+WmrModel::MAXNA; //for dynamic sim

	//make WmrModel object
	WmrModel mdl;
	Real state[MAXNS];
	Real qvel[MAXNV]; //for dynamic sim

	//uncomment one of the following:
	//for animation, must also uncomment the corresponding scene function below
//	zoe(mdl,state,qvel);
	rocky(mdl,state,qvel);
//	talon(mdl,state,qvel);

	//also uncomment the corresponding scene function below!

	//initialize wheel-ground contact model
	mdl.wheelGroundContactModel(0, mdl.wgc_p, 0, 0, 0, //inputs
		0, 0); //outputs

	if (ideal_actuators)
		mdl.actuatorModel=0;

	//get from WmrModel
	const int nf = mdl.get_nf();
	const int nw = mdl.get_nw();
	const int nt = mdl.get_nt();
	const int ns = NUMSTATE(nf); //number of states
	//for dynamic sim
	const int nv = NUMQVEL(nf); //size of joint space vel
	const int na = mdl.get_na(); 
	int ny;

	//terrain
	SurfaceVector surfs;

	//flat(surfs);
	//ramp(surfs); //must also uncomment flat

	grid(surfs, ResourceDir() + std::string("gridsurfdata.txt") );

	//init contact geometry
	WheelContactGeom wcontacts[WmrModel::MAXNW];
	TrackContactGeom tcontacts[WmrModel::MAXNW];
	ContactGeom* contacts =0; //base class

	if (nw > 0) {
		contacts = static_cast<ContactGeom*>(wcontacts);
	} else if (nt > 0) {
		sub_initTrackContactGeom(mdl, tcontacts);
		contacts = static_cast<ContactGeom*>(tcontacts);
	}

	initTerrainContact(mdl, surfs, contacts, state); //DEBUGGING

	//allocate
	Real y[MAXNY];
	Real ydot[MAXNY];

	//init y
	if (do_dyn) { //dynamic sim
		copyVec(ns,state,y);
		copyVec(nv,qvel,y+ns);
		setVec(na,0.0,y+ns+nv); //interr
		ny = ns + nv + na;
	} else {
		copyVec(ns,state,y);
		ny = ns;
	}

	//backup
	Real y0[MAXNY];
	copyVec(ny,y,y0); 

	//allocate
	HomogeneousTransform HT_parent[WmrModel::MAXNF];

#if WMRSIM_ENABLE_ANIMATION
	WmrAnimation anim;
	if (do_anim) { //animate
		anim.start();

		//uncomment the scene function that corresponds to the model function above

//		zoeScene(mdl, anim);
		rockyScene(mdl, anim);
//		talonScene(mdl, tcontacts, anim);

		for (int i=0; i<surfs.size(); i++)
			anim.addEntitySurface(surfs[i].get());
	}
#endif

	std::cout << "state(" << time << ")=\n"; printMatReal(ns,1,y,-1,-1); std::cout << std::endl;

	for (int i=0; i<nsteps; i++) {

		if (do_dyn) {
			odeDyn(time, y, mdl, surfs, contacts, dt, ydot, HT_parent);
		} else {
			odeKin(time, y, mdl, surfs, contacts, ydot, HT_parent);
		}
		addmVec(ny,ydot,dt,y);
		time += dt;

#if WMRSIM_ENABLE_ANIMATION
		if (do_anim) {
			anim.updateNodesLines(nf, HT_parent, nw + nt, contacts);

			if (!anim.updateRender())
				goto stop;

			while (anim.get_mPause()) {
				if (!anim.updateRender())
					goto stop;
			}
		}
#endif
	}

	std::cout << "state(" << time << ")=\n"; printMatReal(ns,1,y,-1,-1); std::cout << std::endl;

#if WMRSIM_ENABLE_ANIMATION
	if (do_anim) {
		//DEBUGGING, wait for escape key before exiting
		while (1) {
			if (!anim.updateRender())
				goto stop;
		}
	}
	stop: //goto
#endif
	
	if (do_time) {
		//time it
		int n= (int) 100;
		timeval t0, t1;

		time = 0;

	  gettimeofday(&t0, NULL);
		for (int iter=0; iter<n; iter++) {
			copyVec(ny,y0,y); //reset to backup

			for (int i=0; i<nsteps; i++) {
				if (do_dyn) {
					odeDyn(time, y, mdl, surfs, contacts, dt, ydot, HT_parent);
				} else {
					odeKin(time, y, mdl, surfs, contacts, ydot, HT_parent);
				}
				addmVec(ny,ydot,dt,y);
				time += dt;
			}
			//std::cout << "state(" << time << ")=\n"; printMatReal(ns,1,y,-1,-1); std::cout << std::endl;
		}
    gettimeofday(&t1, NULL);

		std::cout << "simulate\n";
		std::cout << "iterations: " << (Real) n << std::endl;
		std::cout << "clock (sec): " << tosec(t1)-tosec(t0) << std::endl;
	}

}
コード例 #24
0
ファイル: test.cpp プロジェクト: nealseegmiller/wmrde
void test_forwardDyn() {

	const int MAXNS = NUMSTATE(WmrModel::MAXNF);
	const int MAXNV = NUMQVEL(WmrModel::MAXNF);

	//make WmrModel object
	WmrModel mdl;
	Real state[MAXNS];
	Real qvel[MAXNV];
	
	zoe(mdl,state,qvel);
	//rocky(mdl,state,qvel);
	//talon(mdl,state,qvel); //TODO

	//setVec(nv,0.0,qvel); //DEBUGGING
	mdl.actuatorModel=0; //ideal actuators

	//get from WmrModel
	const int nf = mdl.get_nf();
	const int ns = NUMSTATE(nf);
	const int nv = NUMQVEL(nf);

	const int nw = mdl.get_nw();
	const int nt = mdl.get_nt();

	//terrain
	SurfaceVector surfs;

	flat(surfs);
	//ramp(surfs);
	//grid(surfs, ResourceDir() + std::string("gridsurfdata.txt") );

	//init contact geometry
	WheelContactGeom wcontacts[WmrModel::MAXNW];
	TrackContactGeom tcontacts[WmrModel::MAXNW];
	ContactGeom* contacts = 0;

	if (nw > 0) {
		contacts = static_cast<ContactGeom*>(wcontacts);
	} else if (nt > 0) {
		sub_initTrackContactGeom(mdl, tcontacts);
		contacts = static_cast<ContactGeom*>(tcontacts);
	}

	//initTerrainContact(mdl, surfs, contacts, state); //DEBUGGING

	//convert state to Homogeneous Transforms
	HomogeneousTransform HT_parent[WmrModel::MAXNF + WmrModel::MAXNW];
	HomogeneousTransform HT_world[WmrModel::MAXNF + WmrModel::MAXNW];
	stateToHT(mdl,state,HT_parent,HT_world);

	//update contact geometry
	updateModelContactGeom(mdl, surfs, HT_world, 0, contacts);

	//controller inputs
	ControllerIO u;
	Real time = 0;
	
	mdl.controller(mdl, 0, state, u.cmd, 0);

	//additional inputs
	setVec(mdl.get_na(),0.0,u.interr);

	Real dt = .04; //time step

	//outputs
	Real qacc[MAXNV];

	forwardDyn(mdl, state, qvel, u, HT_parent, HT_world, contacts, dt, qacc);

	//DEBUGGING, print
	std::cout << "state=\n"; printMatReal(ns,1,state,-1,-1); std::cout << std::endl;
	std::cout << "qvel=\n"; printMatReal(nv,1,qvel,-1,-1); std::cout << std::endl;
	std::cout << "qacc=\n"; printMatReal(nv,1,qacc,-1,-1); std::cout << std::endl;


	if (1) {
		//time it
		int n= (int) 1e4;
		timeval t0, t1;

		gettimeofday(&t0, NULL);
		for (int i=0; i<n; i++) {
			forwardDyn(mdl, state, qvel, u, HT_parent, HT_world, contacts, dt, qacc);
		}
		gettimeofday(&t1, NULL);
		std::cout << "forwardDyn()\n";
		std::cout << "iterations: " << (Real) n << std::endl;
		std::cout << "clock (sec): " << tosec(t1)-tosec(t0) << std::endl;
	}
}
コード例 #25
0
ファイル: IO.cpp プロジェクト: jonas-amr/IWM_Prakt
GLfloat* add(GLfloat *v1, GLfloat *v2, GLfloat *result)
{
    setVec(result, v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]);
    return result;
}
コード例 #26
0
ファイル: sensorana.cpp プロジェクト: jonas-amr/IWM_Prakt
void SensorAna::setUrsprung(GLfloat x, GLfloat y, GLfloat z)
{
    setVec(this->ursprung, x, y, z);
}
コード例 #27
0
    void SphereApproximator::generateIcosahedron(GraphData& gd)
    {
        // Twelve vertices of icosahedron on unit sphere
        float tau = 0.8506508084f;
        float one = 0.5257311121f;

        Eigen::Vector3f v[12];

        setVec(v[0], tau, one, 0);
        setVec(v[1], -tau, one, 0);
        setVec(v[2], -tau, -one, 0);
        setVec(v[3], tau, -one, 0);
        setVec(v[4], one, 0, tau);
        setVec(v[5], one, 0, -tau);
        setVec(v[6], -one, 0, -tau);
        setVec(v[7], -one, 0, tau);
        setVec(v[8], 0, tau, one);
        setVec(v[9], 0, -tau, one);
        setVec(v[10], 0, -tau, -one);
        setVec(v[11], 0, tau, -one);

        for (int i = 0 ; i < 12 ; i++)
        {
            gd.vertices.push_back(v[i]);
        }


        // Structure for unit icosahedron
        MathTools::TriangleFace f[20];
        f[0].set(5,  8,  9);
        f[1].set(5, 10,  8);
        f[2].set(6, 12,  7);
        f[3].set(6,  7, 11);
        f[4].set(1,  4,  5);
        f[5].set(1,  6,  4);
        f[6].set(3,  2,  8);
        f[7].set(3,  7,  2);
        f[8].set(9, 12,  1);
        f[9].set(9,  2, 12);
        f[10].set(10,  4, 11);
        f[11].set(10, 11, 3);
        f[12].set(9,  1,  5);
        f[13].set(12,  6,  1);
        f[14].set(5,  4, 10);
        f[15].set(6, 11,  4);
        f[16].set(8,  2,  9);
        f[17].set(7, 12,  2);
        f[18].set(8, 10, 3);
        f[19].set(7,  3, 11);

        for (int i = 0 ; i < 20 ; i++)
        {
            f[i].id1--;
            f[i].id2--;
            f[i].id3--;
            gd.faces.push_back(f[i]);
        }
    }