Hi Mohammad,
1. The prerequisite is to know that C::GPU works in center-of-mass frames,
like Chrono in general. The accompanying vector and matrix that you specify
during *AddMesh *are intended to be used as some sort of pre-processing for
your mesh file. To cut to the chase, if your mesh file is created such that
the mesh is already in its center-of-mass frame, then for all purposes, you
should always call *gpu_sys.AddMesh("../Screw_CM.obj", ChVector<float>(0,0,0),
ChMatrix33<float>(1),
screw_mass);*
If your mesh is not already in its center-of-mass frame, or you want to
scale it before loading it, then you can supply those arguments.
*ChMatrix33<float>(1)* would create an identity matrix, and this matrix
will be applied to every point in your mesh (as a side note, the matrix is
applied before the vector is also applied to every point in your mesh), as
a part of the pre-processing. Obviously, the identity matrix does nothing
to your mesh. If it was a diagonal matrix, it would "scale" your mesh; if
it was a unitary matrix, it would rotate your mesh; if it was a general
matrix the it would "rotate and scale" your mesh, hence its name.
Because of what I said, I do not recommend using this *ChVector *argument
to set the initial CoM (I just want to be more specific; you can call it
initial position, too) of the mesh in simulation, it is against its design
purpose. I said not recommend, but it can functionally work as a initial
position specifier: think about it and you'll figure out why. Also, while
other things may work fine, you will get strange torque readings from the
mesh if you do that: again you can figure out why.
In principal, use *ApplyMeshMotion *to control mesh position/velocity in
simulation, including the initial position.
2. As you can see, this is managing a ChBody and has nothing to do with the
mesh in your gpu_sys. *SetPos *just sets the position of that ChBody.
Because it has nothing to do with *gpu_sys*, if you need it to be at a
location, you need to set it separately. In this co-simulation example, the
mesh you loaded is the proxy in DEM simulation for this ChBody. The *gpu_sys
*will collect the contact force on the mesh, feed this info to the ChBody,
and the ChBody will use this force info to update this body's location, and
then the new location is used to update the mesh location in *gpu_sys*.
ChBody can manage more complex rigid body motions such as those involving
joints, so it is used to help manage external objects in the DEM simulation.
3. If you now understand the above, then you can see you are really just
setting the mesh position (in *gpu_sys*) for the very first time here.
*ApplyMeshMotion
*is called at every time step, so every quantity here is not just some
initial value, but the values throughout the simulation. Some of the values
are changing every step (because *t *changes), such as *mesh_rot*; others
such as velocities happen to be constants in this simulation. *mesh_rot* is
a quaternion which represents the rotation status of the mesh (or
specifically, the mesh's local coordinate system). If that sounds
unfamiliar then it is probably helpful to read a bit more about quaternions.
Hope it answers your questions!
Ruochun
On Saturday, September 3, 2022 at 5:23:44 PM UTC-5 [email protected]
wrote:
> Hi Ruochun,
>
> Thank you so much for your help. This actually helped a lot. I have some
> questions that I hope you could answer. I am trying to control the mesh
> motion using *ApplyMeshMotion *as you mentioned. However, I feel like I
> do not fully understand everything related to that so I wanted to ask some
> questions and hopefully, this will help others as well. I have looked at
> the documentation and they are really brief so I hope you could answer some
> of these questions here. I will use examples from my code(attached here). I
> might be using some stuff incorrectly so I think it would be a good way to
> see if what I am doing is correct or not.
>
> 1- gpu_sys.AddMesh("../Screw_CM.obj", *ChVector<float>(0,0,-90)*,
> *ChMatrix33<float>(1)*, screw_mass);
>
> - *ChVector<float>(0,0,-90): *does this represent the
> initial position where the mesh is initiated, and does it affect other
> parts of the simulation?
> - *ChMatrix33<float>(1): *what does this represent? I
> looked through the documentation and it says that this is the rotscale.
> Could you give a little more explanation as to
> what that is?
>
> 2- ChVector<> ball_initial_pos(0, 0, 0);
> std::shared_ptr<ChBody> screw_body(sys_screw.NewBody());
> screw_body->SetMass(screw_mass);
> screw_body->SetInertiaXX(ChVector<>(screw_inertia_x,
> screw_inertia_y, screw_inertia_z));
> screw_body->*SetPos(ball_initial_pos)*;
> screw_body->SetBodyFixed(false);
> sys_screw.AddBody(screw_body);
>
> - When creating a system using the imported mesh, what does
> screw_body->*SetPos(ball_initial_pos) *do? Clearly, it is a way to set
> the position of the mesh. However, since the
> *ChVector<float>(0,0,-90)
> *was used before when adding the mesh, is there a need to use *SetPos?*
>
> *3- * ChVector<float> *mesh_pos(0, 0, 0); *
> float rev_per_sec = 10.f;
> float ang_vel_Z = rev_per_sec * 2 * (float)CH_C_PI;
> ChVector<> *mesh_lin_vel*(0);
> ChQuaternion<> *mesh_rot *= Q_from_AngZ(t * ang_vel_Z);
> ChVector<> *mesh_ang_vel*(0, 0, ang_vel_Z);
> gpu_sys.ApplyMeshMotion(0, mesh_pos, mesh_rot, mesh_lin_vel,
> mesh_ang_vel);
>
> - *mesh_pos(0, 0, 0):* to me, it seems that we are
> setting the position of the mesh a third time. could you explain how this
> affects the simulation?
> - *mesh_lin_vel*(0): does this represent the initial
> velocity of the mesh? or is it applying a constant velocity throughout the
> entire simulation?
> - *mesh_rot : *Could you explain what this exactly
> is and how changing it affects the simulation?
> * - **mesh_ang_vel*(0, 0, ang_vel_Z): is this the
> initial rotational speed or it is a constant rotational speed that the mesh
> will have throughout the entire
> simulation?
>
>
> Thank you so much in advance for taking the time to help us with
> everything,
>
>
>
>
> On Saturday, September 3, 2022 at 12:09:24 PM UTC-7 Ruochun Zhang wrote:
>
>> Hi Mohammad,
>>
>> I think that *demo_GPU_mixer.cpp* demo does exactly what you needed.
>> While you are looking into this demo, I just want to mention one thing to
>> avoid confusion: in terms of controlling the mesh motion in C::GPU, the
>> *Transform
>> *call before *AddMesh *should only be used to "align" the mesh with its
>> CoM before the simulation starts, so that when the mesh is loaded it is
>> expressed in its centroid and principal frame; it should not be used to set
>> the initial location of the mesh. Instead, like in the demo, use
>> *ApplyMeshMotion
>> *to control the mesh motion throughout the simulation.
>>
>> Hope it helps!
>> Ruochun
>>
>> On Saturday, September 3, 2022 at 10:58:19 AM UTC-5 [email protected]
>> wrote:
>>
>>> Hello there,
>>>
>>> I am trying to perform a simulation using the gpu module where I want to
>>> import a cylindrical screw (picture attached) into a bed on granular media
>>> and then have the screw spin on top of the bed and then obtain the
>>> forces/torques on the screw.
>>>
>>> I am not sure about what would be the best way to import the screw in a
>>> way that it's set on the bed at the start of the simulation. Also, I am not
>>> sure how I can impose a type of motion that would force the screw to spin
>>> on top of that bed since I am importing it as an .obj file. Finally, due to
>>> the shape of the screw, I assume that when the screw moves it will tend to
>>> turn to the left/right. Is there a way to restrict the motion of the screw
>>> to be just straight while spinning? I was wondering if there are any demos
>>> regarding this or if someone has done something similar before. Any help
>>> will be appreciated.
>>>
>>> Thank you so much in advance,
>>>
>>>
>>>
--
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/29f708be-7cd4-440d-9cde-c830590776b7n%40googlegroups.com.