Marcel is correct. When running a Chrono-based program from a location other
than where the distribution demos are, you must point to the correct path for
the various data files.
Assuming you use the CMake Chrono project configuration script to link to the
Chrono libraries either in a build directory or an install directory, you have
access to a CMake variable (CHRONO_DATA_DIR) which contains the relevant
information. You must ensure this variable can be used from within your C++
code and then make a call such as
SetChronoDataPath(CHRONO_DATA_DIR);
At the top of your main function.
See the example in the
template_project<https://github.com/projectchrono/chrono/tree/develop/template_project>
and look at how (1) the CMake variable is used in CMakeLists.txt to define a
C++ macro and (2) how that is used in the call to SetChronoDataPath in
my_example.cpp.
--Radu
From: [email protected] <[email protected]> On Behalf
Of Marcel Offermans
Sent: Thursday, June 30, 2022 9:20 AM
To: ProjectChrono <[email protected]>
Subject: [chrono] Re: CityBus Demo : path to CityBus_Vis.obj
The obvious answer is that it is probably looking in the wrong place. That
said, working out what the "current directory" is when running an executable
can be a bit tricky depending on how you run it. So if you've built and
executable for this demo, go to a command line and:
1. Change directory to the folder where the executable lives.
2. Make sure that from that folder, if you go one folder up, you see your
"data" directory (and it actually contains the files you need to run this demo).
3. Run the demo. It should now find the files.
Now if you're running inside the IDE (Visual Studio or whatever you are using)
you can set this current directory to be whatever you want. What I have done to
make my life a bit easier, is to add a few lines of code to the start of the
main() of such demos that will print this directory:
// Output the current directory, just to make sure we understand where we're
running.
#define PATH_MAX 1024
char buff[PATH_MAX];
_getcwd(buff, PATH_MAX);
std::string current_working_dir(buff);
GetLog() << "Working dir = " << current_working_dir << "\n\n";
Another thing that might help you is to explicitly set the data path. This was
mentioned on the forum before, and you can do it somewhat like this (also do
this at the start of main()):
// This can be used to point to different data paths (for core and vehicle
modules):
chrono::SetChronoDataPath("../data/");
vehicle::SetDataPath("../data/vehicle/");
Hope this helps!
Greetings, Marcel
On Thursday, June 30, 2022 at 9:02:14 AM UTC+2
[email protected]<mailto:[email protected]> wrote:
Dear all,
I am trying to build a single project chrono demo:
https://github.com/projectchrono/chrono/blob/develop/src/demos/vehicle/wheeled_models/demo_VEH_CityBus.cpp
I can create the executable, but when I run it, there is an error:
Error Loading OBJ file ../data/vehicle/citybus/CityBus_Vis.obj
segmentation fault.
If I compile the whole chrono, then of course demo_VEH_CityBus is working. I
just want to try to compile single demo. Why it can't find the path to the
CityBus object?
Thank You.
--
С наилучшими пожеланиями, Богиня Фрейя
Atenciosamente, Freya the Goddess
Meilleurs voeux, Freya the Goddess
Liebe Grüße, Freya the Goddess
Best wishes, Freya the Goddess
よろしくお願いします、Freya the Goddess
最好的祝福,Freya the Goddess
Matakwa mema, Freya the Goddess
مع أطيب التمنيات ، فريا الإلهة
--
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]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/projectchrono/679fcb35-b782-4e3b-b787-f81c2b1665b6n%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/679fcb35-b782-4e3b-b787-f81c2b1665b6n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
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/PH0PR06MB82372459EFA5EC0F889C540DA7BA9%40PH0PR06MB8237.namprd06.prod.outlook.com.