Regardless of the delay, I really appreciate the response. Your solution was exactly correct and cleared up my collision problems.
I was confused about the initial orientation given to created cylinder bodies. Also, although rotation about the center of mass for each body makes the most sense, I was confused by the fact that all coordinates (both used for setting and returning a body's state) are in a global frame. In any case, works great now, thank you.
To explain my last point more, I'm interested in getting forces that result from collisions, but when I tried to use "setFeedback" with my contact joints, it threw the following error:
ODE INTERNAL ERROR 2: Bad argument(s) in dJointSetFeedback()
I'd seen this in other threads and thought this meant that getting reaction forces from the contact was not possible. Also, I assumed that because the geometry has no "mass", that getting contact forces from the collision with a body and a geometry was also not possible. So I made an extra body for my obstacle that is rigidly fixed to the environment with a fixed joint that will give forces induced by the collision somewhere along the body. If there is a better/other way, I'd be happy to hear about it.
Thanks again for the help and course correction.
Healthcare Robotics Lab - Georgia Tech
Hi! Sorry about the delay -- it's hard for me to find free time these days. I'm not really familiar with vpython so I may be vastly misinterpreting the function of your program.It looks like body1, your robot arm, is not being rotated. If I understand correctly, this means that the capsule is extending along the Z-axis, whereas you are drawing it as extending along the X-axis. That is to say, your joint is not swinging the capsule like the arm of a turnstile, but more like the head of a hammer. I think the box obstacle is sufficiently wide that the capsule hits it anyhow, but if it is only 0.1, it fits "inside" the the radius of the hammer swing. To fix this, I put:
On 01/11/2011 03:17 PM, Marc Killpack wrote:
I've been trying to make a simple robot simulator which includes collisions. I'm getting weird
behavior though and wondered if I'm just making a dumb mistake. I want some objects that are
fixed in the environment. From other examples and from archived questions on the list it seems like
the best way to do this is using geometry objects that are not associated with a body. The only
collision that works so far is if I collide with the floor plane that is defined as a fixed geometry.
I've attached my file that uses vpython for visualization and I had the following questions if anyone
1)If I set a tall square in place, different sizes will result in collisions while smaller sizes do not, why?
(Try changing width and length of square to 0.1 in line 56 of .py file to reproduce this)
body1.setRotation([0, 0, 1, 0, 1, 0, -1, 0, 0])
Just after your body1.setPosition() call, before adding the geom. (A 90 degree rotation around the Y axis, to exchange the X and Z axes, to make your visualization line up with the simulation.) Now a collision always happens.I'm guessing the motor on the joint is sufficiently powerful to keep pressing the body against the obstacle. Try changing MaxForce to 0 after the first time step (at the end of the while loop), so that the body has an initial velocity. You'll definitely see a bounce, and it will definitely be different for different bouncinesses.
Also, if I change the bounciness in the collision callback function (line 28), it seems to have no effect
on the collision, why?
This looks right to me, and once I added the rotation of the body (as per point 1), this caused collisions.
2)I can place a geometry object that is a capped cylinder in the environment but how do I orient it? I tried
setting the rotation, but still couldn't get a collision to occur. Change "OBSTACLE = 2" on line 9 to see this.
I don't think this is true. Can you explain further?
3)If I want forces from the collision, it seems that I have to have the obstacle be associated with a body
as well, is that true? If so, what kind of hinge or connection should I use? I tried a fixed joint to the
environment but that also did weird things.