本文整理汇总了C++中ChSharedPtr::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ChSharedPtr::Initialize方法的具体用法?C++ ChSharedPtr::Initialize怎么用?C++ ChSharedPtr::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChSharedPtr
的用法示例。
在下文中一共展示了ChSharedPtr::Initialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
FinalizeObject(ANCHOR, (ChSystemParallel *) system_gpu);
FinalizeObject(REFERENCE, (ChSystemParallel *) system_gpu);
// real vol = ((ChCollisionModelParallel *) ANCHOR->GetCollisionModel())->getVolume();
// real den = .00785;
// anchor_mass = den*vol;
// cout<<vol<<" "<<anchor_mass<<endl;
// ANCHOR->SetMass(anchor_mass);
ANCHOR->SetInertiaXX(ChVector<>(12668786.72, 5637598.31, 12682519.69));
REFERENCE->SetInertiaXX(ChVector<>(12668786.72, 5637598.31, 12682519.69));
// ANCHOR->SetInertiaXX(
// ChVector<>(
// 1 / 12.0 * anchor_mass * (1 * 1 + anchor_R * anchor_R),
// 1 / 12.0 * anchor_mass * (anchor_R * anchor_R + anchor_R * anchor_R),
// 1 / 12.0 * anchor_mass * (anchor_R * anchor_R + 1 * 1)));
//BLOCK = ChSharedBodyPtr(new ChBody(new ChCollisionModelParallel));
//InitObject(BLOCK, anchor_mass/2, Vector(0, 300, 0), Quaternion(1, 0, 0, 0), material, false, false, -20, -20);
//AddCollisionGeometry(BLOCK, BOX, ChVector<>(1, 1, 1), Vector(0, 0, 0), Quaternion(1, 0, 0, 0));
//FinalizeObject(BLOCK, (ChSystemParallel *) system_gpu);
//actuator_anchor = ChSharedPtr<ChLinkLockLock>(new ChLinkLockLock());
//actuator_anchor->Initialize(CONTAINER, BLOCK, ChCoordsys<>(ChVector<>(0, 0, 0), QUNIT));
//system_gpu->AddLink(actuator_anchor);
// apply motion
//motionFunc1 = new ChFunction_Ramp(0, -anchor_vel);
//actuator_anchor->SetMotion_Y(motionFunc1);
//actuator_anchor->SetMotion_axis(ChVector<>(0, 1, 0));
engine_anchor = ChSharedPtr<ChLinkEngine>(new ChLinkEngine);
engine_anchor->Initialize(CONTAINER, ANCHOR, ChCoordsys<>(ANCHOR->GetPos(), chrono::Q_from_AngAxis(CH_C_PI / 2, VECT_X)));
engine_anchor->Set_shaft_mode(ChLinkEngine::ENG_SHAFT_PRISM); // also works as revolute support
engine_anchor->Set_eng_mode(ChLinkEngine::ENG_MODE_SPEED);
system_gpu->AddLink(engine_anchor);
reference_engine = ChSharedPtr<ChLinkEngine>(new ChLinkEngine);
reference_engine->Initialize(CONTAINER, REFERENCE, ChCoordsys<>(REFERENCE->GetPos(), chrono::Q_from_AngAxis(CH_C_PI / 2, VECT_X)));
reference_engine->Set_shaft_mode(ChLinkEngine::ENG_SHAFT_PRISM); // also works as revolute support
reference_engine->Set_eng_mode(ChLinkEngine::ENG_MODE_SPEED);
system_gpu->AddLink(reference_engine);
if (ChFunction_Const* mfun = dynamic_cast<ChFunction_Const*>(engine_anchor->Get_spe_funct())) {
mfun->Set_yconst(anchor_rot * 1 / 60.0 * 2 * CH_C_PI); // rad/s angular speed
}
if (ChFunction_Const* mfun = dynamic_cast<ChFunction_Const*>(reference_engine->Get_spe_funct())) {
mfun->Set_yconst(anchor_rot * 1 / 60.0 * 2 * CH_C_PI); // rad/s angular speed
}
ReadAllObjectsWithGeometryChrono(system_gpu, "data/anchor/anchor.dat");
ChSharedPtr<ChMaterialSurface> material_read;
material_read = ChSharedPtr<ChMaterialSurface>(new ChMaterialSurface);
material_read->SetFriction(particle_slide_friction);
material_read->SetRollingFriction(particle_roll_friction);
material_read->SetSpinningFriction(particle_roll_friction);
material_read->SetCompliance(0);
material_read->SetCohesion(particle_cohesion * timestep);
for (int i = 0; i < system_gpu->Get_bodylist()->size(); i++) {
system_gpu->Get_bodylist()->at(i)->SetMaterialSurface(material_read);
}
示例2: addChBodySceneNode
// Build and initialize the tank, creating all bodies corresponding to
// the various parts and adding them to the physical system - also creating
// and adding constraints to the system.
MySimpleTank(ChSystem& my_system, ///< the chrono::engine physical system
ISceneManager* msceneManager, ///< the Irrlicht scene manager for 3d shapes
IVideoDriver* mdriver ///< the Irrlicht video driver
)
{
throttleL = throttleR = 0; // initially, gas throttle is 0.
max_motor_speed = 10;
double my = 0.5; // left back hub pos
double mx = 0;
double shoelength = 0.2;
double shoethickness = 0.06;
double shoewidth = 0.3;
double shoemass = 2;
double radiustrack = 0.31;
double wheeldiameter = 0.280*2;
int nwrap = 6;
int ntiles = 7;
double rlwidth = 1.20;
double passo = (ntiles+1)*shoelength;
ChVector<> cyl_displA(0, 0.075+0.02,0);
ChVector<> cyl_displB(0, -0.075-0.02,0);
double cyl_hthickness = 0.045;
// --- The tank body ---
IAnimatedMesh* bulldozer_bodyMesh = msceneManager->getMesh("../data/bulldozerB10.obj");
truss = (ChBodySceneNode*)addChBodySceneNode(
&my_system, msceneManager, bulldozer_bodyMesh,
350.0,
ChVector<>(mx + passo/2, my + radiustrack , rlwidth/2),
QUNIT);
truss->GetBody()->SetInertiaXX(ChVector<>(13.8, 13.5, 10));
truss->GetBody()->SetBodyFixed(false);
//truss->addShadowVolumeSceneNode();
// --- Right Front suspension ---
// Load a triangle mesh for wheel visualization
IAnimatedMesh* irmesh_wheel_view = msceneManager->getMesh("../data/wheel_view.obj");
// ..the tank right-front wheel
wheelRF = (ChBodySceneNode*) addChBodySceneNode(
&my_system, msceneManager, irmesh_wheel_view,
9.0,
ChVector<>(mx + passo, my+ radiustrack , 0),
chrono::Q_from_AngAxis(CH_C_PI/2, VECT_X) );
wheelRF->GetBody()->GetCollisionModel()->ClearModel();
wheelRF->GetBody()->GetCollisionModel()->AddCylinder(wheeldiameter/2,wheeldiameter/2, cyl_hthickness, &cyl_displA);
wheelRF->GetBody()->GetCollisionModel()->AddCylinder(wheeldiameter/2,wheeldiameter/2, cyl_hthickness, &cyl_displB);
wheelRF->GetBody()->GetCollisionModel()->BuildModel(); // Creates the collision model
wheelRF->GetBody()->SetCollide(true);
wheelRF->GetBody()->SetInertiaXX(ChVector<>(1.2, 1.2, 1.2));
wheelRF->GetBody()->SetFriction(1.0);
video::ITexture* cylinderMap = mdriver->getTexture("../data/bluwhite.png");
wheelRF->setMaterialTexture(0, cylinderMap);
wheelRF->addShadowVolumeSceneNode();
// .. create the revolute joint between the wheel and the truss
link_revoluteRF = ChSharedPtr<ChLinkLockRevolute>(new ChLinkLockRevolute); // right, front, upper, 1
link_revoluteRF->Initialize(wheelRF->GetBody(), truss->GetBody(),
ChCoordsys<>(ChVector<>(mx + passo, my+ radiustrack , 0) , QUNIT ) );
my_system.AddLink(link_revoluteRF);
// --- Left Front suspension ---
// ..the tank left-front wheel
wheelLF = (ChBodySceneNode*) addChBodySceneNode(
&my_system, msceneManager, irmesh_wheel_view,
9.0,
ChVector<>(mx + passo, my+ radiustrack , rlwidth),
chrono::Q_from_AngAxis(CH_C_PI/2, VECT_X) );
wheelLF->GetBody()->GetCollisionModel()->ClearModel();
wheelLF->GetBody()->GetCollisionModel()->AddCylinder(wheeldiameter/2,wheeldiameter/2, cyl_hthickness, &cyl_displA);
wheelLF->GetBody()->GetCollisionModel()->AddCylinder(wheeldiameter/2,wheeldiameter/2, cyl_hthickness, &cyl_displB);
wheelLF->GetBody()->GetCollisionModel()->BuildModel(); // Creates the collision model
wheelLF->GetBody()->SetCollide(true);
wheelLF->GetBody()->SetInertiaXX(ChVector<>(1.2, 1.2, 1.2));
wheelLF->GetBody()->SetFriction(1.0);
wheelLF->setMaterialTexture(0, cylinderMap);
wheelLF->addShadowVolumeSceneNode();
// .. create the revolute joint between the wheel and the truss
link_revoluteLF = ChSharedPtr<ChLinkLockRevolute>(new ChLinkLockRevolute); // left, front, upper, 1
link_revoluteLF->Initialize(wheelLF->GetBody(), truss->GetBody(),
ChCoordsys<>(ChVector<>(mx + passo, my+ radiustrack , rlwidth) , QUNIT ) );
my_system.AddLink(link_revoluteLF);
// --- Right Back suspension ---
//.........这里部分代码省略.........
示例3: mesh
// Build and initialize the forklift, creating all bodies corresponding to
// the various parts and adding them to the physical system - also creating
// and adding constraints to the system.
MySimpleForklift(ChIrrAppInterface* app, ChVector<> offset = ChVector<>(0,0,0))
{
throttle = 0; // initially, gas throttle is 0.
steer = 0;
lift =0;
ChVector<> COG_truss(0, 0.4, 0.5);
ChVector<> COG_wheelRF( 0.566, 0.282, 1.608);
ChVector<> COG_wheelLF(-0.566, 0.282, 1.608);
ChVector<> COG_arm(0, 1.300, 1.855);
ChVector<> COG_fork(0, 0.362, 2.100);
ChVector<> COG_wheelB(0, 0.282, 0.003);
ChVector<> POS_pivotarm(0, 0.150, 1.855);
ChVector<> POS_prismatic(0, 0.150, 1.855);
double RAD_back_wheel =0.28;
double RAD_front_wheel = 0.28;
forkliftTiremap = app->GetVideoDriver()->getTexture("../data/tire_truck.png");
// --- The car body ---
IAnimatedMesh* forklift_bodyMesh = app->GetSceneManager()->getMesh("../data/forklift_body.obj");
truss = (ChBodySceneNode*)addChBodySceneNode(
app->GetSystem(), app->GetSceneManager(), forklift_bodyMesh,
200.0,
COG_truss,
QUNIT);
truss->GetBody()->SetInertiaXX(ChVector<>(100, 100, 100));
truss->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, true);
truss->setMaterialTexture(0, forkliftTiremap);
truss->GetChildMesh()->setPosition(-vector3df(COG_truss.x, COG_truss.y, COG_truss.z));// offset the mesh
truss->addShadowVolumeSceneNode();
truss->GetBody()->GetCollisionModel()->ClearModel();
truss->GetBody()->GetCollisionModel()->AddBox(1.227/2., 1.621/2., 1.864/2., &ChVector<>(-0.003, 1.019, 0.192));
truss->GetBody()->GetCollisionModel()->AddBox(0.187/2., 0.773/2., 1.201/2., &ChVector<>( 0.486 , 0.153,-0.047));
truss->GetBody()->GetCollisionModel()->AddBox(0.187/2., 0.773/2., 1.201/2., &ChVector<>(-0.486 , 0.153,-0.047));
truss->GetBody()->GetCollisionModel()->BuildModel();
truss->GetBody()->SetCollide(true);
// ..the right-front wheel
IAnimatedMesh* forklift_wheelMesh = app->GetSceneManager()->getMesh("../data/wheel.obj");
wheelRF = (ChBodySceneNode*)addChBodySceneNode(
app->GetSystem(), app->GetSceneManager(), forklift_wheelMesh,
20.0,
COG_wheelRF,
QUNIT);
wheelRF->GetBody()->SetInertiaXX(ChVector<>(2, 2, 2));
wheelRF->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, true);
wheelRF->setMaterialTexture(0, forkliftTiremap);
wheelRF->GetChildMesh()->setPosition(-vector3df(COG_wheelRF.x, COG_wheelRF.y, COG_wheelRF.z));// offset the mesh
// Describe the (invisible) colliding shape
ChMatrix33<>Arot(chrono::Q_from_AngAxis(CH_C_PI/2, VECT_Z));
wheelRF->GetBody()->GetCollisionModel()->ClearModel();
wheelRF->GetBody()->GetCollisionModel()->AddCylinder(RAD_front_wheel,RAD_front_wheel, 0.1, &ChVector<>(0,0,0), &Arot);
wheelRF->GetBody()->GetCollisionModel()->BuildModel();
wheelRF->GetBody()->SetCollide(true);
// .. create the revolute joint between the wheel and the truss
link_revoluteRF = ChSharedPtr<ChLinkLockRevolute>(new ChLinkLockRevolute); // right, front, upper, 1
link_revoluteRF->Initialize(wheelRF->GetBody(), truss->GetBody(),
ChCoordsys<>(COG_wheelRF , chrono::Q_from_AngAxis(CH_C_PI/2, VECT_Y)) );
app->GetSystem()->AddLink(link_revoluteRF);
// ..the left-front wheel
wheelLF = (ChBodySceneNode*)addChBodySceneNode(
app->GetSystem(), app->GetSceneManager(), forklift_wheelMesh,
20.0,
COG_wheelLF,
chrono::Q_from_AngAxis(CH_C_PI, VECT_Y)); // reuse RF wheel shape, flipped
wheelLF->GetBody()->SetInertiaXX(ChVector<>(2, 2, 2));
wheelLF->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, true);
wheelLF->setMaterialTexture(0, forkliftTiremap);
wheelLF->GetChildMesh()->setPosition(-vector3df(COG_wheelRF.x, COG_wheelRF.y, COG_wheelRF.z));// offset the mesh (reuse RF)
// Describe the (invisible) colliding shape
wheelLF->GetBody()->GetCollisionModel()->ClearModel();
wheelLF->GetBody()->GetCollisionModel()->AddCylinder(RAD_front_wheel,RAD_front_wheel, 0.1, &ChVector<>(0,0,0), &Arot);
wheelLF->GetBody()->GetCollisionModel()->BuildModel();
wheelLF->GetBody()->SetCollide(true);
// .. create the revolute joint between the wheel and the truss
link_revoluteLF = ChSharedPtr<ChLinkLockRevolute>(new ChLinkLockRevolute); // right, front, upper, 1
link_revoluteLF->Initialize(wheelLF->GetBody(), truss->GetBody(),
ChCoordsys<>(COG_wheelLF , chrono::Q_from_AngAxis(CH_C_PI/2, VECT_Y)) );
app->GetSystem()->AddLink(link_revoluteLF);
// ..the back steering spindle (invisible, no mesh)
spindleB = (ChBodySceneNode*)addChBodySceneNode(
app->GetSystem(), app->GetSceneManager(), 0,
10.0,
COG_wheelB,
QUNIT);
//.........这里部分代码省略.........