Hi ,
I want to simulate something like Cubli (
https://www.wevolver.com/specs/cubli) but keeping it simple by considering
it is happening in free floating .
So I stated with the torque free motion .
Please find the code for it ,
-----Start of code ---
// 1- Create a Chrono physical system
// ChSystemNSC my_system;
ChSystemNSC my_system;
my_system.SetTimestepperType(ChTimestepper::Type::EULER_EXPLICIT);
my_system.SetMaxiter(200);
my_system.SetSolverType(ChSolver::Type::APGD);
my_system.SetSolverMaxIterations(200);
my_system.SetSolverTolerance(1e-16);
my_system.Set_G_acc(ChVector<>(0,0,0));
// .. chassis:
std::shared_ptr<ChBody> chassis;
auto chassis_mat = chrono_types::make_shared<ChMaterialSurfaceNSC>();
chassis = chrono_types::make_shared<ChBody>();
chassis->SetMass(1);
chassis->SetPos(ChVector<>(0, 0, 0));
auto applied_torque_x = chrono_types::make_shared<ChForce>();
chassis->AddForce(applied_torque_x);
applied_torque_x->SetMode(chrono::ChForce::TORQUE);
applied_torque_x->SetMforce(0.0);
applied_torque_x->SetRelDir(VECT_X);
auto applied_torque_y = chrono_types::make_shared<ChForce>();
chassis->AddForce(applied_torque_y);
applied_torque_y->SetMode(chrono::ChForce::TORQUE);
applied_torque_y->SetMforce(0.0);
applied_torque_y->SetRelDir(VECT_Y);
auto applied_torque_z = chrono_types::make_shared<ChForce>();
chassis->AddForce(applied_torque_z);
applied_torque_z->SetMode(chrono::ChForce::TORQUE);
applied_torque_z->SetMforce(0.0);
applied_torque_z->SetRelDir(VECT_Z);
ChMatrix33<> rot(ChVector<>(1.0, 1.0, 1.0));
ChQuaternion<> Qb(1,ChVector<>(0,0,0));
chassis->SetRot(Qb);
// Add MOI
ChVector<> moiXX(0.33,0.33 ,0.34);
ChVector<> moiXY(0, 0,0);
chassis->SetInertiaXX(moiXX);
chassis->SetInertiaXY(moiXY);
std::cout<<"MOI"<<chassis->GetInertia()<<'\n';
chassis->SetBodyFixed(false);
// Adding initial angular velocity
chassis->SetWvel_loc(ChVector<>(50, 50,1));
my_system.Add(chassis);
double t =1;
int total_time = (int)24*60*60/t;
int momemt_counter = 1 ;
std::ofstream MyFile;
MyFile.open("angularvel_01.csv", std::ios::out);
MyFile
<<"time,ang_loc_x_rad_per_Sec,ang_loc_y_rad_per_Sec,ang_loc_z_rad_per_Sec,"
<<"ang_par_x_rad_per_Sec,ang_par_y_rad_per_Sec,ang_par_z_rad_per_Sec"
<<'\n';
for (int i = 0; i <total_time ; ++i) {
my_system.DoStepDynamics(t);
auto angvel = chassis->GetWvel_par();
auto angvel2 = chassis->GetWvel_loc();
double timenow = my_system.GetChTime();
MyFile <<timenow<<","<<angvel[0] <<","<<angvel[1] <<","<<angvel[2] <<","
<<angvel2[0]<<","<<angvel2[1]<<","<<angvel2[2]
<<'\n';
std::cout<<timenow<<","<<angvel[0]<<","<<angvel[1]<<","<<angvel[2]<<","<<angvel2[0]<<","<<angvel2[1]<<","<<angvel2[2]<<'\n';
}
-----End of code ---
it gives Nana for EULER_EXPLICIT .
For the EULER_IMPLICIT it gives wrong soltion
matlab_angvel.jpg
Which is wrong ,
When i use Rungakutta45 as time stepper , then i find correct ans
matlab2.jpg
But when i attach motor and use rk45 as timestepper . I always get "Nan" .
Can you help which timestepper can be used in both the scenario .
let me know if you need anyfuther things from my side .
--
You received this message because you are subscribed to the Google Groups
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/projectchrono/b1c95ca8-0f38-4f5c-bfd2-6f1dfdde0a2fn%40googlegroups.com.