Retrieving the rotation of a box container in Multicore

50 views
Skip to first unread message

Gianni Curti

unread,
Aug 4, 2024, 5:07:04 PM8/4/24
to ProjectChrono
Hi,
I have an object in Chrono::Multicore created with the command "AddBoxContainer", and I need to obtain the quaternion describing its rotation at each timestep. I tried with "GetRot" but all I obtain is a 1x4 vector full of "-nan(ind)" and I cannot understand why since from the graphical interface I can clearly see that the body is rotating.
I have also tried to add a marker to the body but I did not get any result. Can you please help me?

Another question regards saving the box container in a csv file to be read by another simulation. When I start the second simulation, the box appears to be like "disassembled" with all the walls far from each other. Am I missing something?

The last doubt is about how the box containers are created. Do the three dimesions describe the inner or the outer envelope of the box?

Thank you for your kindness.

Gianni

Radu Serban

unread,
Aug 5, 2024, 8:01:54 AM8/5/24
to ProjectChrono

Gianni,

 

I am a bit confused.  Assuming you are talking about the function chrono::utils::AddBoxContainer, note that this functions does *not* create a body but rather just attaches collision (and optionally visualization) geometry to an existing body.  As such, what is relevant here is the rotation of the body (which you must have created prior to invoking AddBoxContainer).  If you have specified a non-identity frame (transform) for the box container relative to the parent body, you will then need to concatenate the two rotations.

 

I cannot help with your question about the “disassembled” container, since I have no idea how/what you save to that CSV file, nor do I know how you try to reconstruct the container from data read from that file.

 

Finally, the dimensions passed to AddBoxContainer represent the *interior* size of the container.  That is clearly indicated in the documentation (also, you can always look at the implementation).

 

--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/7e241951-99b3-4995-8cbc-cf42f432bca0n%40googlegroups.com.

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Gianni Curti

unread,
Aug 5, 2024, 7:19:14 PM8/5/24
to ProjectChrono
Hi Radu, 
thank you so much for your kindness and patience.
I am answering to the two points in different messages as when I try to combine them in a single one the post gets cancelled.

1. Below, you can find the code in which I create the ChBody "lander", and then I apply the box shape through the function chrono::utils::AddBoxContainer as you said. As you can see, my reference system has the axes oriented as the global one, while I applied a translation to the center.
Screenshot 2024-08-05 203728.png
This code is contained within a function called "CreateLander" which is used in the main. Then, I try to retrieve the body as follows:
Screenshot 2024-08-05 212514.png
Finally, I use "GetRot" to obtain the queternion but the result is [-nan(ind) -nan(ind) -nan(ind) -nan(ind)].
Screenshot 2024-08-05 212434.png
On the other hand, the object "link_actuator" works perfectly as expected.

Gianni Curti

unread,
Aug 5, 2024, 7:19:52 PM8/5/24
to ProjectChrono
2. The two images below help to clarify what I mean by "disassembled":
Before:Screenshot 2024-08-05 213247.png
After:
Screenshot 2024-08-05 213523.png
The procedure I am following is the one reported in the demo "demo_MCORE_cratering".
In particular, here I save all the objects I created:
Screenshot 2024-08-05 213835.png
The, with these commands I read the csv file:
Screenshot 2024-08-05 213923.png
The only solution I found up to now is to manually cancel the corrupted objects from the csv file and create them again in the new simulation, but this is unpractical when dealing with more complex cases.

Please, let me know if you need any other information. Thank you again.

Gianni

Radu Serban

unread,
Aug 6, 2024, 8:06:59 AM8/6/24
to ProjectChrono

Gianni,

 

I’m answering both questions in the same place.

 

  1. I am not sure what is happening in your code, and you do not provide enough information to be able to tell that (for example, I don’t know what the signature of your CreateLander() function is).  In any case, this looks like a memory issue. Something that can easily be figured out with a debugger: step through the code and inspect the list of bodies in the system, making sure the 1st one is indeed your “lander” body.  Note also that you are setting both “lander” and “sam_acq” to the same body in the system (namely the 1st body that was added to the system).  Again, I don’t know what you intend to do from the limited information you provided.
  2. This was in fact a bug in the Chrono utility functions WriteCheckpoint and ReadCheckpoint (which were not properly updated when we changed the definition of dimensions for various primitive collision shapes). I pushed a fix. You can check that the container collision geometry is reconstructed properly from the checkpointing file in demo_MCORE_cratering.

 

--Radu

 

From: projec...@googlegroups.com <projec...@googlegroups.com> On Behalf Of Gianni Curti
Sent: Tuesday, August 6, 2024 1:20 AM
To: ProjectChrono <projec...@googlegroups.com>
Subject: Re: [chrono] Retrieving the rotation of a box container in Multicore

 

2. The two images below help to clarify what I mean by "disassembled":

Before:

After:

The procedure I am following is the one reported in the demo "demo_MCORE_cratering".

In particular, here I save all the objects I created:

The, with these commands I read the csv file:

The only solution I found up to now is to manually cancel the corrupted objects from the csv file and create them again in the new simulation, but this is unpractical when dealing with more complex cases.

 

Please, let me know if you need any other information. Thank you again.

 

Gianni

 

Il giorno martedì 6 agosto 2024 alle 01:19:14 UTC+2 Gianni Curti ha scritto:

Hi Radu, 

thank you so much for your kindness and patience.

I am answering to the two points in different messages as when I try to combine them in a single one the post gets cancelled.

 

1. Below, you can find the code in which I create the ChBody "lander", and then I apply the box shape through the function chrono::utils::AddBoxContainer as you said. As you can see, my reference system has the axes oriented as the global one, while I applied a translation to the center.


This code is contained within a function called "CreateLander" which is used in the main. Then, I try to retrieve the body as follows:

Finally, I use "GetRot" to obtain the queternion but the result is [-nan(ind) -nan(ind) -nan(ind) -nan(ind)].

On the other hand, the object "link_actuator" works perfectly as expected.

 

--

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.

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Gianni Curti

unread,
Aug 6, 2024, 3:38:47 PM8/6/24
to ProjectChrono
Hi Radu,
thank you for your suggestions, now everything is working fine! 
Regarding the first issue, the problem was in the object index, while I will pull the latest release to solve the second one.
Thank you again.

Gianni

Reply all
Reply to author
Forward
0 new messages