Skip to content

Commit 7ea3139

Browse files
authored
Update to Chrono v9.0.1 (#59)
* Updated to Chrono v9.0.1 * Set CHRONO_DATA_DIR in demos * Fix sphere_decay test * Remove set of max iterations for demos with direct solver * Properly export CHRONO_DATA_DIR definition
1 parent 3a191dc commit 7ea3139

24 files changed

+396
-395
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#--------------------------------------------------------------
66

77
cmake_minimum_required(VERSION 3.18.2)
8+
cmake_policy(SET CMP0091 NEW)
9+
810

911
# guard against in-source builds
1012
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
@@ -41,6 +43,14 @@ project(HydroChrono
4143
# Add the cmake folder so the FindSphinx module is found
4244
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
4345

46+
#--------------------------------------------------------------
47+
# Important! To ensure ABI compatibility, use the same C++ standard
48+
# as the one used to build the Chrono libraries.
49+
#--------------------------------------------------------------
50+
51+
set(CXX_STANDARD_REQUIRED ON)
52+
set(CMAKE_CXX_STANDARD ${CHRONO_CXX_STANDARD})
53+
4454
# ===================
4555
# OPTIONS
4656
# ===================
@@ -125,9 +135,9 @@ target_include_directories(
125135
target_compile_definitions(HydroChrono
126136

127137
PUBLIC
128-
129-
PRIVATE
130138
CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"
139+
PRIVATE
140+
131141
)
132142

133143
target_compile_options(HydroChrono BEFORE

demos/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
1414
target_compile_definitions(demo_sphere_decay
1515
PRIVATE
1616
HYDROCHRONO_HAVE_IRRLICHT=1
17+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
1718
)
1819
endif()
1920

@@ -49,6 +50,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
4950
target_compile_definitions(demo_sphere_reg_waves
5051
PRIVATE
5152
HYDROCHRONO_HAVE_IRRLICHT=1
53+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
5254
)
5355
endif()
5456

@@ -83,6 +85,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
8385
target_compile_definitions(demo_sphere_irreg_waves
8486
PRIVATE
8587
HYDROCHRONO_HAVE_IRRLICHT=1
88+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
8689
)
8790
endif()
8891

@@ -116,6 +119,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
116119
target_compile_definitions(demo_sphere_irreg_waves_eta_import
117120
PRIVATE
118121
HYDROCHRONO_HAVE_IRRLICHT=1
122+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
119123
)
120124
endif()
121125

@@ -148,6 +152,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
148152
target_compile_definitions(demo_rm3_decay
149153
PRIVATE
150154
HYDROCHRONO_HAVE_IRRLICHT=1
155+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
151156
)
152157
endif()
153158

@@ -182,6 +187,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
182187
target_compile_definitions(demo_rm3_reg_waves
183188
PRIVATE
184189
HYDROCHRONO_HAVE_IRRLICHT=1
190+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
185191
)
186192
endif()
187193

@@ -216,6 +222,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
216222
target_compile_definitions(demo_oswec_decay
217223
PRIVATE
218224
HYDROCHRONO_HAVE_IRRLICHT=1
225+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
219226
)
220227
endif()
221228

@@ -249,6 +256,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
249256
target_compile_definitions(demo_oswec_reg_waves
250257
PRIVATE
251258
HYDROCHRONO_HAVE_IRRLICHT=1
259+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
252260
)
253261
endif()
254262

@@ -282,6 +290,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
282290
target_compile_definitions(demo_f3of_DT1
283291
PRIVATE
284292
HYDROCHRONO_HAVE_IRRLICHT=1
293+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
285294
)
286295
endif()
287296

@@ -315,6 +324,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
315324
target_compile_definitions(demo_f3of_DT2
316325
PRIVATE
317326
HYDROCHRONO_HAVE_IRRLICHT=1
327+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
318328
)
319329
endif()
320330

@@ -347,6 +357,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
347357
target_compile_definitions(demo_f3of_DT3
348358
PRIVATE
349359
HYDROCHRONO_HAVE_IRRLICHT=1
360+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
350361
)
351362
endif()
352363

@@ -380,6 +391,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT)
380391
target_compile_definitions(demo_DeepCWind_decay
381392
PRIVATE
382393
HYDROCHRONO_HAVE_IRRLICHT=1
394+
"CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\""
383395
)
384396
endif()
385397

demos/DeepCWind/demo_DeepCWind_decay.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6-
#include <chrono/physics/ChLinkMate.h>
76

87
#include <chrono> // std::chrono::high_resolution_clock::now
98
#include <iomanip> // std::setprecision
109
#include <vector> // std::vector<double>
1110

1211
// Use the namespaces of Chrono
1312
using namespace chrono;
14-
using namespace chrono::geometry;
1513

1614
// usage: ./sphere_deca.exe [DATADIR] [--nogui]
1715
//
@@ -20,7 +18,9 @@ using namespace chrono::geometry;
2018
//
2119
int main(int argc, char* argv[]) {
2220
// auto start = std::chrono::high_resolution_clock::now();
23-
GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n";
21+
std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n";
22+
23+
SetChronoDataPath(CHRONO_DATA_DIR);
2424

2525
if (hydroc::SetInitialEnvironment(argc, argv) != 0) {
2626
return 1;
@@ -39,21 +39,21 @@ int main(int argc, char* argv[]) {
3939

4040
// system/solver settings
4141
ChSystemSMC system;
42-
system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81));
42+
system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81));
4343
double timestep = 0.08;
4444
system.SetTimestepperType(ChTimestepper::Type::HHT);
4545
system.SetSolverType(ChSolver::Type::GMRES);
46-
system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied.
47-
system.SetStep(timestep);
46+
system.GetSolver()->AsIterative()->SetMaxIterations(
47+
300); // the higher, the easier to keep the constraints satisfied.
4848
double simulationDuration = 1000.0;
4949

5050
// Create user interface
5151
std::shared_ptr<hydroc::gui::UI> pui = hydroc::gui::CreateUI(visualizationOn);
52-
hydroc::gui::UI& ui = *pui.get();
52+
hydroc::gui::UI& ui = *pui.get();
5353

5454
// some io/viz options
55-
bool profilingOn = true;
56-
bool saveDataOn = true;
55+
bool profilingOn = true;
56+
bool saveDataOn = true;
5757
std::vector<double> time_vector;
5858
std::vector<double> base_pitch;
5959
std::vector<double> base_surge;
@@ -70,33 +70,33 @@ int main(int argc, char* argv[]) {
7070

7171
// define the base's initial conditions
7272
system.Add(base);
73-
base->SetNameString("body1");
74-
auto cg = ChVector<>(0.0, 0.0, -7.53);
73+
base->SetName("body1");
74+
auto cg = ChVector3d(0.0, 0.0, -7.53);
7575
// offset used for heave/surge decay test
76-
auto offset = ChVector<>(0.0, 0.0, 0.0);
76+
auto offset = ChVector3d(0.0, 0.0, 0.0);
7777
base->SetPos(cg + offset);
7878
// Use for pitch decay test
79-
double ang_rad = -3.95 * CH_C_PI / 180.0;
80-
base->SetRot(Q_from_AngAxis(ang_rad, VECT_Y));
79+
double ang_rad = -3.95 * CH_PI / 180.0;
80+
base->SetRot(QuatFromAngleY(ang_rad));
8181
base->SetMass(1.419625e7);
82-
base->SetInertiaXX(ChVector<>(1.2898e10, 1.2851e10, 1.4189e10));
82+
base->SetInertiaXX(ChVector3d(1.2898e10, 1.2851e10, 1.4189e10));
8383

8484
// add fixed ground for linear damping (surge or pitch)
8585
auto ground = chrono_types::make_shared<ChBody>();
8686
system.AddBody(ground);
8787
ground->SetPos(cg);
88-
ground->SetRot(Q_from_AngAxis(CH_C_PI / 2.0, VECT_X));
89-
ground->SetIdentifier(-1);
90-
ground->SetBodyFixed(true);
91-
ground->SetCollide(false);
88+
ground->SetRot(QuatFromAngleX(CH_PI / 2.0));
89+
ground->SetTag(-1);
90+
ground->SetFixed(true);
91+
ground->EnableCollision(false);
9292

9393
// define damping in pitch
9494
auto rot_damp = chrono_types::make_shared<ChLinkRSDA>();
9595
// need to set damping to 31 MN-m/(rad/s)
9696
rot_damp->SetDampingCoefficient(31e6);
9797
// puts Z axis for link into screen, keeping x axis the same (to the right)
98-
ChQuaternion<> rev_rot = Q_from_AngAxis(CH_C_PI / 2.0, VECT_X); // do not change
99-
rot_damp->Initialize(base, ground, false, ChCoordsys(cg, rev_rot), ChCoordsys(cg, rev_rot));
98+
ChQuaternion<> rev_rot = QuatFromAngleX(CH_PI / 2.0); // do not change
99+
rot_damp->Initialize(base, ground, false, ChFramed(cg, rev_rot), ChFramed(cg, rev_rot));
100100
system.AddLink(rot_damp);
101101

102102
// set up hydro forces
@@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
120120
// append data to output vector
121121
time_vector.push_back(system.GetChTime());
122122
base_surge.push_back(base->GetPos().x());
123-
base_pitch.push_back(base->GetRot().Q_to_Euler123().y());
123+
base_pitch.push_back(base->GetRot().GetCardanAnglesXYZ().y());
124124
}
125125
}
126126

@@ -153,8 +153,8 @@ int main(int argc, char* argv[]) {
153153
outputFile.open("./results/DeepCWind_decay.txt");
154154
if (!outputFile.is_open()) {
155155
if (!std::filesystem::exists("./results")) {
156-
std::cout << "Path " << std::filesystem::absolute("./results")
157-
<< " does not exist, creating it now..." << std::endl;
156+
std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..."
157+
<< std::endl;
158158
std::filesystem::create_directory("./results");
159159
outputFile.open("./results/DeepCWind_decay.txt");
160160
if (!outputFile.is_open()) {

demos/Test/Test_1.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class MyEventReceiver : public IEventReceiver {
9494
// wheel and the many radial rollers, already lined to the wheel with revolute joints.)
9595
// The function returns the pointer to the central wheel.
9696
std::shared_ptr<ChBody> create_mecanum_wheel(ChSystemNSC& sys,
97-
ChVector<> shaft_position,
97+
ChVector3d shaft_position,
9898
ChQuaternion<> shaft_alignment,
9999
double wheel_radius,
100100
double wheel_width,
@@ -122,7 +122,7 @@ std::shared_ptr<ChBody> create_mecanum_wheel(ChSystemNSC& sys,
122122
double roller_elliptical_rad_Vert = wheel_radius * 1.0 / (cos(roller_angle));
123123

124124
for (int iroller = 0; iroller < n_rollers; iroller++) {
125-
double pitch = CH_C_2PI * ((double)iroller / (double)n_rollers);
125+
double pitch = CH_2PI * ((double)iroller / (double)n_rollers);
126126

127127
double Roffset = -(wheel_radius - roller_midradius);
128128

@@ -131,9 +131,9 @@ std::shared_ptr<ChBody> create_mecanum_wheel(ChSystemNSC& sys,
131131
sys.Add(roller);
132132

133133
// move it to slanted aligment
134-
ChFrameMoving<> f1(ChVector<>(0, 0, -(wheel_radius - roller_midradius)),
135-
Q_from_AngAxis(roller_angle, ChVector<>(0, 0, 1)));
136-
ChFrameMoving<> f2(ChVector<>(0, 0, 0), Q_from_AngAxis(pitch, ChVector<>(0, 1, 0)));
134+
ChFrameMoving<> f1(ChVector3d(0, 0, -(wheel_radius - roller_midradius)),
135+
QuatFromAngleZ(roller_angle));
136+
ChFrameMoving<> f2(ChVector3d(0, 0, 0), QuatFromAngleY(pitch));
137137
ChFrameMoving<> f3 = f1 >> f2 >> ftot;
138138
roller->ConcatenatePreTransformation(f3);
139139

@@ -150,7 +150,7 @@ std::shared_ptr<ChBody> create_mecanum_wheel(ChSystemNSC& sys,
150150
roller_elliptical_rad_Vert, roller_elliptical_rad_Hor, //
151151
Roffset);
152152
roller->GetCollisionModel()->BuildModel();
153-
roller->SetCollide(true);
153+
roller->EnableCollision(true);
154154

155155
// add visualization shape
156156
auto rollershape =
@@ -161,7 +161,7 @@ std::shared_ptr<ChBody> create_mecanum_wheel(ChSystemNSC& sys,
161161

162162
// Make the revolute joint between the roller and the central wheel
163163
// (preconcatenate rotation 90 degrees on X, to set axis of revolute joint)
164-
ChFrameMoving<> fr(ChVector<>(0, 0, 0), Q_from_AngAxis(CH_C_PI / 2.0, ChVector<>(1, 0, 0)));
164+
ChFrameMoving<> fr(ChVector3d(0, 0, 0), QuatFromAngleX(CH_PI / 2.0));
165165
ChFrameMoving<> frabs = fr >> f3;
166166
auto link_roller = chrono_types::make_shared<ChLinkLockRevolute>();
167167
link_roller->Initialize(roller, centralWheel, frabs.GetCoord());
@@ -172,14 +172,14 @@ std::shared_ptr<ChBody> create_mecanum_wheel(ChSystemNSC& sys,
172172
}
173173

174174
int main(int argc, char* argv[]) {
175-
GetLog() << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n";
175+
std::cout << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n";
176176

177177
// Create a ChronoENGINE physical system
178178
ChSystemNSC sys;
179179

180180
double platform_radius = 8;
181181
double wheel_radius = 3;
182-
double roller_angle = CH_C_PI / 4;
182+
double roller_angle = CH_PI / 4;
183183

184184
// Create the robot truss, as a circular platform
185185
auto platform = chrono_types::make_shared<ChBodyEasyCylinder>(platform_radius * 0.7, 2, // radius, height
@@ -193,11 +193,11 @@ int main(int argc, char* argv[]) {
193193

194194
// create the wheels and link them to the platform
195195

196-
ChFrame<> f0(ChVector<>(0, 0, 0), Q_from_AngAxis(CH_C_PI / 2.0, ChVector<>(1, 0, 0)));
197-
ChFrame<> f1(ChVector<>(0, 0, platform_radius), QUNIT);
198-
ChFrame<> f2_wA(VNULL, Q_from_AngAxis(0 * (CH_C_2PI / 3.0), ChVector<>(0, 1, 0)));
199-
ChFrame<> f2_wB(VNULL, Q_from_AngAxis(1 * (CH_C_2PI / 3.0), ChVector<>(0, 1, 0)));
200-
ChFrame<> f2_wC(VNULL, Q_from_AngAxis(2 * (CH_C_2PI / 3.0), ChVector<>(0, 1, 0)));
196+
ChFrame<> f0(ChVector3d(0, 0, 0), QuatFromAngleX(CH_PI / 2.0));
197+
ChFrame<> f1(ChVector3d(0, 0, platform_radius), QUNIT);
198+
ChFrame<> f2_wA(VNULL, QuatFromAngleY(0 * (CH_2PI / 3.0)));
199+
ChFrame<> f2_wB(VNULL, QuatFromAngleY(1 * (CH_2PI / 3.0)));
200+
ChFrame<> f2_wC(VNULL, QuatFromAngleY(2 * (CH_2PI / 3.0)));
201201
ChFrame<> ftot_wA = f0 >> f1 >> f2_wA;
202202
ChFrame<> ftot_wB = f0 >> f1 >> f2_wB;
203203
ChFrame<> ftot_wC = f0 >> f1 >> f2_wC;
@@ -259,8 +259,8 @@ int main(int argc, char* argv[]) {
259259
true, // visualize
260260
true, // collide
261261
ground_mat); // contact material
262-
ground->SetPos(ChVector<>(0, -5, 0));
263-
ground->SetBodyFixed(true);
262+
ground->SetPos(ChVector3d(0, -5, 0));
263+
ground->SetFixed(true);
264264
ground->GetVisualShape(0)->SetTexture(GetChronoDataFile("textures/concrete.jpg"), 100, 100);
265265
sys.Add(ground);
266266

@@ -272,7 +272,7 @@ int main(int argc, char* argv[]) {
272272
vis->Initialize();
273273
vis->AddLogo();
274274
vis->AddSkyBox();
275-
vis->AddCamera(ChVector<>(0, 14, -20));
275+
vis->AddCamera(ChVector3d(0, 14, -20));
276276
vis->AddTypicalLights();
277277

278278
vis->GetGUIEnvironment()->addStaticText(L"Use keys Q,W, A,Z, E,R to move the robot", rect<s32>(150, 10, 430, 40),
@@ -286,7 +286,7 @@ int main(int argc, char* argv[]) {
286286
sys.SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_PROJECTED);
287287

288288
sys.SetSolverType(ChSolver::Type::PSOR);
289-
sys.SetSolverMaxIterations(30);
289+
sys.GetSolver()->AsIterative()->SetMaxIterations(30);
290290

291291
// Simulation loop
292292

@@ -303,8 +303,8 @@ int main(int argc, char* argv[]) {
303303

304304
// change motor speeds depending on user setpoints from GUI
305305

306-
ChVector<> imposed_speed(STATIC_x_speed, 0, STATIC_z_speed);
307-
ChFrame<> roll_twist(ChVector<>(0, -wheel_radius, 0), Q_from_AngAxis(-roller_angle, ChVector<>(0, 1, 0)));
306+
ChVector3d imposed_speed(STATIC_x_speed, 0, STATIC_z_speed);
307+
ChFrame<> roll_twist(ChVector3d(0, -wheel_radius, 0), QuatFromAngleY(-roller_angle));
308308

309309
ChFrame<> abs_roll_wA = roll_twist >> f2_wA >> ChFrame<>(platform->GetCoord());
310310
double wheel_A_rotspeed =

0 commit comments

Comments
 (0)