Parse additional data

44 views
Skip to first unread message

Yves Eric Maxime Robert

unread,
Jun 19, 2022, 4:15:29 AM6/19/22
to ProjectChrono
Hello,

I am using Chrono::GPU and would like to make the simulation more user-friendly by not requiring the user to recompile the code every time a parameter is needed to be changed.

The JSON file is very handy, but it is rather not flexible as the number and names of the parameters are fixed.

Let's say that for instance, the user wants to change regularly the part the '.obj' file to be loaded by the routine, or that I want the to scale this object with a parameter named "scale", etc. How would I do that? Is there any feature allowing for it?

Thank you,
Yves

Ruochun Zhang

unread,
Jun 19, 2022, 5:24:41 AM6/19/22
to ProjectChrono
Hi Yves,

You know, I think the easiest way to achieve what you described, is to write your C++ scripts with input arguments.

Other than that, maybe you can incorporate a third-party JSON parser such as RapidJSON to parse custom JSON files in your scripts, if it is necessary.

Thank you,
Ruochun

Yves Eric Maxime Robert

unread,
Jun 20, 2022, 2:13:47 PM6/20/22
to ProjectChrono
Hello,

Thank you for your answer.

To clarify, if I have like 20 parameters to pass, the second solution (third-party JSON parser) would be way more practical than putting arguments, am I write? 
It is just to check if I understand well the first solution.

Best regards,
Yves Robert

Radu Serban

unread,
Jun 20, 2022, 2:55:30 PM6/20/22
to ProjectChrono

Not necessarily.  You can have defaults for your command line arguments and change only what’s needed.

We use cxxopts in Chrono demos (and provide a convenience wrapper around it, ChCLI.h).

Look at a demo such as demo_ROBOT_RoboSimian_SCM for an example.

 

--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/7fb7189c-a629-468a-a240-d251315e528dn%40googlegroups.com.

Yves Eric Maxime Robert

unread,
Jun 26, 2022, 5:26:06 AM6/26/22
to ProjectChrono
Hello,

Thank you, it is a smart way to do, I will use that then.

Yves

Yves Eric Maxime Robert

unread,
Jun 28, 2022, 3:07:49 AM6/28/22
to ProjectChrono
Hello, 

I am wondering, it seems from other posts that RapidJSON should be included when building Chrono. 
However, I cannot find it anywhere (GPU branch). Do I have to go through a specific process?

Thank you,
Yves

Radu Serban

unread,
Jun 28, 2022, 4:16:01 AM6/28/22
to ProjectChrono
Reply all
Reply to author
Forward
0 new messages