Center of gravity position is not taken into account

Report crashes, strange behaviour, or apparent bugs
Post Reply
ayberkozgur
Posts: 21
Joined: 28 Feb 2013, 15:51

Center of gravity position is not taken into account

Post by ayberkozgur » 06 Mar 2013, 21:13

The center of gravity position given relative to the shape frame has no effect. It's as if the center of gravity is always placed directly on the shape frame (at (x,y,z)=(0,0,0)).

This flaw is demonstrated in the attached scene. There is a cuboid attached to a revolute joint at 1m distance with 1kg mass. Also, the joint efforts are published to the ROS topic named /vrep/joint_states. The joint is position controlled to hold the mass horizontally. You can echo the topic to see that 9.81Nm of torque is exerted by the joint as expected. When you move the center of gravity of the cuboid, the torque doesn't change.

Without ROS, you can see this bug in the following way: Move the center of gravity of the cuboid away from the joint. You would expect the joint to drop down increasingly as the mass moves away from it, increasing the torque needed to hold it. Since CoG is not taken into account, the joint is held at the same position even if the mass is 1 kilometer away from the joint.

The scene: http://dfiles.eu/files/pusfyins2

coppelia
Site Admin
Posts: 7441
Joined: 14 Dec 2012, 00:25

Re: Center of gravity position is not taken into account

Post by coppelia » 06 Mar 2013, 22:16

Hello,

Indeed! Thanks a lot for pointing that out!
Actually the bug happens only with "non-respondable" shapes: if you move the whole construction above the ground so that it doesn't touch it, then make the "Cuboid0" respondable, then the result is correct.
This is because of some simplification that I built-in, thinking to speed-up calculation for non-respondable shapes.
The bug will be corrected for next release V-REP 3.0.2, to be released mid-March 2013

Cheers

coppelia
Site Admin
Posts: 7441
Joined: 14 Dec 2012, 00:25

Re: Center of gravity position is not taken into account

Post by coppelia » 06 Mar 2013, 23:18

If you are compiling the dynamics plugin yourself, you can easily correct the bug by commenting one single instruction:

in function

void CRigidBodyContainerDyn::_addOrUpdateRigidBody(CDummyShape* shape,bool forceStatic)

comment out the condition

if (_simIsShapeDynamicallyRespondable(shape))

so that you have:

Code: Select all

void CRigidBodyContainerDyn::_addOrUpdateRigidBody(CDummyShape* shape,bool forceStatic)
{
	CRigidBodyDyn* body=getRigidBodyFromShapeID(_simGetObjectID(shape));

	if (body==NULL)
	{ // We have to add that shape!
		CCollShapeDyn* collShape=NULL;
		CRigidBodyDyn* body;

		CDummyGeomProxy* geom=NULL; // NULL means that this shape doesn't collide (but still dynamic)
		// will the shape collide?
//		if (_simIsShapeDynamicallyRespondable(shape))  
			geom=(CDummyGeomProxy*)_simGetGeomProxyFromShape(shape); // yes the shape collides

		// Following to display a warning with static respondable shapes build on a non-static construction:
		if (_simIsShapeDynamicallyStatic(shape)&&_simIsShapeDynamicallyRespondable(shape)) // second part added on 28/2/2013, thanks to Nikolaus
		{ // explore its parents:
			CDummy3DObject* parent=(CDummy3DObject*)_simGetParentObject(shape);

...
Non-respondable shapes will still and correctly not respond to collision (the not respondable flag is tested later again)

Cheers

ayberkozgur
Posts: 21
Joined: 28 Feb 2013, 15:51

Re: Center of gravity position is not taken into account

Post by ayberkozgur » 07 Mar 2013, 11:15

OK, I will recompile the dynamics plugin with your modification and use it until the update. Thank you.

coppelia
Site Admin
Posts: 7441
Joined: 14 Dec 2012, 00:25

Re: Center of gravity position is not taken into account

Post by coppelia » 07 Mar 2013, 11:40

You will have to compile a total of 4 items:
  • V-REP
  • the dynamics plugin
  • the mesh calculation plugin
  • the path planning plugin
The reason is: the precompiled V-REP PRO EDU has the above major 3 plugins compiled together with V-REP (not as separate entities).

Cheers

coppelia
Site Admin
Posts: 7441
Joined: 14 Dec 2012, 00:25

Re: Center of gravity position is not taken into account

Post by coppelia » 07 Mar 2013, 15:24

By the way, you can also as a quick work-around simply:
  • turn on the "Body is respondable" checkbox
  • turn off all the "Respondable mask" checkboxes
This has the same effect, but does not reveal the bug ;)

Cheers

ayberkozgur
Posts: 21
Joined: 28 Feb 2013, 15:51

Re: Center of gravity position is not taken into account

Post by ayberkozgur » 07 Mar 2013, 15:57

I recompiled the source code after making the change you suggested. The COG is now placed correctly. Thank you very much.

Post Reply