m =.1 #mass
l=1 #lengthh=1 #heightd=1 #depthD=1000 #density seg0 = chrono.ChBodyEasyBox(l,h,d,D, True, True)seg0.SetPos(chrono.ChVectorD(11.5,7,-1))seg0.SetBodyFixed(False)seg0.SetMass(m)my_system.Add(seg0)my_color = chrono.ChColorAsset(0,31,40)seg0.AddAsset(my_color)seg0.SetCollide(True)seg0.GetMaterialSurfaceNSC().SetFriction(0.4)seg0.GetCollisionModel().ClearModel()seg0.GetCollisionModel().AddBox(0.2, 0.1, 0.1, chrono.VNULL, chrono.ChMatrix33D(chrono.QUNIT))seg0.GetCollisionModel().BuildModel()
a = 20 #rod parameter 1b = .001 #rod parameter 2c = .05 #rod paremeter 3 .005 is loose and everything flies away, .5 it is so tight everything curlsrm = .01 #rod mass
rod1 = chrono.ChBody()my_system.AddBody(rod1)rod1.SetMass(rm) rod1.SetInertiaXX(chrono.ChVectorD(a, b, c))
x=11.4 #starting x position
link1 = chrono.ChCylinderShape()link1.GetCylinderGeometry().p1 = chrono.ChVectorD(x,7,-1)seg_connect1 = chrono.ChLinkUniversal()seg_connect1.Initialize(seg0, rod1, chrono.ChFrameD(chrono.ChVectorD(x,7,-1)))my_system.AddLink(seg_connect1)
link1.GetCylinderGeometry().p2 = chrono.ChVectorD(x-1.3,7,-1)seg_connect2 = chrono.ChLinkUniversal()seg_connect2.Initialize(rod1, seg1, chrono.ChFrameD(chrono.ChVectorD(x-1.3,7,-1)))my_system.AddLink(seg_connect2)rod1.AddAsset(link1)
The screenshots above reflect approximately what I intend to visualize. (They were taken while the simulation was still running, before everything floated apart.)
The last two images are what happens when I let the simulation continue.
CK,
In addition to that, you should make sure the universal joints are properly oriented. I assume you want the 2 rotational DOFs to be about axes that are perpendicular to the axis of your millipede. Keep in mind that for a universal joint these 2 rotational DOFs are about the x and y axes of the *joint* frame. If you build the millipede along the global x axis as you seem to do, for the particular form of the Initialize function you use for your joints that will probably require including a rotation about the z axis in the ChFrameD passed to Initialize.
A couple of suggestions:
--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/c0e055b0-4f09-4c50-9bd1-34d927e43454o%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to projec...@googlegroups.com.
Hi CK,
I'm not sure I understand why you would consider dynamic variable names. That is definitely something to be discouraged. But it's perfectly fine to reuse local variables in a loop. As soon as you add a body or joint to the Chrono system, that local variable in the loop is not needed anymore and can be reused for the next segment.
Now, in your loop you should create both new bodies and the
joints to connect them to the last body added in the previous
iteration. Maybe this is the source of your confusion.
Say you want to build a chain with the following topology
[B1]-(j1)-[B2]-(j2)-[B1]-(j1)-[B2]-(j2)-[B1]-(j1)-[B2]-(j2)-[B1]-(j1)-[B2]-(j2)......[B1]
with two different types of bodies [B1] and [B2] and two different
types of joints (j1) and (j2).
Then your "building block" would be
(j1)-[B2]-(j2)-[B1]
and you could organize your construction along these lines:
b1 = create, add body to system
for i = 1:n_blocks
b2 = create, add body to system
j1 = create, connect b1 & b2, add joint to system
b1 = create, add body to system
j2 = create, connect b2 & b1, add joint to system
end
An alternative to this is to simply create lists of bodies and
joints of appropriate size before the loop and then create your
bodies and joints at increasing indices in those lists while you
iterate in the loop (note that a list + an index in that list
serves precisely as your "dynamic variable name").
You should also create your "millipede" in a straight initial
configuration, that will make setting up the proper body and joint
initial locations and orientations in the loop much easier. I'm
not sure why you have a relative pitch angle in your "building
block". Maybe because you just copied the configuration from the
demo I pointed you to?
Hope that this helps and puts you on the right track.
--Radu
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/91ce290e-a82a-4abe-b9d8-ae27bb1bb7e1o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/91ce290e-a82a-4abe-b9d8-ae27bb1bb7e1o%40googlegroups.com.