CityBus Demo : path to CityBus_Vis.obj

27 views
Skip to first unread message

Freya the Goddess

unread,
Jun 30, 2022, 3:02:14 AM6/30/22
to ProjectChrono
Dear all,

I am trying to build a single project chrono demo:

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 voeuxFreya the Goddess
Liebe Grüße, Freya the Goddess
Best wishes, Freya the Goddess
よろしくお願いします、Freya the Goddess
最好的祝福,Freya the Goddess
Matakwa mema, Freya the Goddess
مع أطيب التمنيات ، فريا الإلهة

Marcel Offermans

unread,
Jun 30, 2022, 3:19:47 AM6/30/22
to ProjectChrono
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

Radu Serban

unread,
Jun 30, 2022, 4:47:42 AM6/30/22
to ProjectChrono

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 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

--
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 projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/679fcb35-b782-4e3b-b787-f81c2b1665b6n%40googlegroups.com.

Freya the Goddess

unread,
Jul 2, 2022, 3:27:04 AM7/2/22
to ProjectChrono
Thanks Marcel and Radu, I add the line :
SetChronoDataPath(CHRONO_DATA_DIR);
inside the main() of the

Then the error changes. segmentation fault.

The build directory of Project Chrono is: /opt/hamzstlib/Physics/chrono2, where the data folder is there and the CityBus_Vis.obj is there too. You can see from my screenshot along with the newest error to run the executable.

Capture d’écran_2022-07-02_14-23-29.png

Freya the Goddess

unread,
Jul 2, 2022, 4:42:54 AM7/2/22
to ProjectChrono
 /opt/hamzstlib/Physics/chrono2/build/citybus

 the distribution demos are in
 /opt/hamzstlib/Physics/chrono2/build/bin

still the same error
Capture d’écran_2022-07-02_15-40-15.png

Radu Serban

unread,
Jul 2, 2022, 5:17:02 AM7/2/22
to ProjectChrono

You also need to properly set the data path to Chrono::Vehicle data file.

Look at the https://github.com/projectchrono/chrono-projects repository.  I just added an example of building the CityBus demo as an external project in https://github.com/projectchrono/chrono-projects/tree/develop/configuration_tests/vehicle.  This should be exactly what you are trying to do.

 

--Radu

Radu Serban

unread,
Jul 2, 2022, 9:22:44 AM7/2/22
to ProjectChrono

I am confused as to what you are doing / trying to do.  
Also, these snapshots do not help at all. If anything, they make things even more confusing.  Please explain what you are doing and, if needed, attach relevant files or else copy text output to your messages.

 

Were you able to clone, configure, and build chrono-projects?  If yes, can you successfully run demo_VEF_CityBus from *within* chrono-projects?

If you were able to do the above, then look in the directory https://github.com/projectchrono/chrono-projects/tree/develop/configuration_tests/vehicle to see how the CMakeLists.txt is written and how demo_VEH_CityBus is modified and reproduce that in your own test. 

 

--Radu

 

 

 

From: Freya the Goddess <zaqhie...@gmail.com>
Sent: Saturday, July 2, 2022 11:43 AM
To: Radu Serban <ser...@wisc.edu>
Subject: Re: [chrono] Re: CityBus Demo : path to CityBus_Vis.obj

 

I try the external project:

 

There is this error when I run make  after I run cmake (see the screenshots)

 

Reply all
Reply to author
Forward
0 new messages