Re: [OpenRAVE-users] Make gravity affect objects created with InitFrom...()
Brought to you by:
rdiankov
|
From: Juan G V. <jcg...@gm...> - 2012-10-31 09:33:15
|
Hi Rosen,
Thank you!
Yes, I was missing that line. I had actually commented it out because
of the exception. In my case, the exception is avoided if SetStatic is
called _outside_ the scope of where the environment is locked.
Cheers and thank you once again,
-juan
2012/10/31 Rosen Diankov <ros...@gm...>:
> hi juan,
>
> i see, that's because you were creating the body with InitFromBoxes,
> which sets all the links to "static". If you execute this line the box
> should fall:
>
> body.GetLinks()[0].SetStatic(False)
>
> rosen,
>
> 2012/10/31 Juan G Victores <jcg...@gm...>:
>> Hi Rosen,
>> Unfortunately the newly created objects remain unaffected by gravity.
>> I brewed up a small python example (attached) so it will be easier to
>> debug.
>>
>> On my machine, the robot swings, the box remains in the air. Could you
>> please see if this behavior is replicable? Could there be a fix?
>>
>> Cheers and many thanks,
>> -juan
>>
>> ------------------- script in case attached file does not reach -----------
>> #!/usr/bin/python
>> from openravepy import *
>> import numpy, time
>> env = Environment() # create openrave environment
>> env.SetViewer('qtcoin') # attach viewer (optional)
>> env.Load('data/testphysics.env.xml') # load a simple scene
>> env.GetPhysicsEngine().SetGravity([0,0,0])
>> with env:
>> body = RaveCreateKinBody(env,'')
>> body.SetName('testbody')
>> body.InitFromBoxes(numpy.array([[1,1,1,0.1,0.2,0.3]]),True)
>> body.GetLinks()[0].SetMass(1)
>> body.GetLinks()[0].SetPrincipalMomentsOfInertia([1,2,3])
>> body.GetLinks()[0].SetLocalMassFrame([1,0,0,0,1,1,1])
>> env.Add(body,True)
>> time.sleep(2) # sleep 2 seconds
>> env.GetPhysicsEngine().SetGravity([0,0,-9.8])
>> time.sleep(5) # sleep 2 seconds
>>
>> 2012/10/30 Rosen Diankov <ros...@gm...>:
>>> hi juan,
>>>
>>> you'll need to set a gravity vector via the physics engine:
>>>
>>> env->GetPhysicsEngine()->SetGravity(Vector(0,0,-9.8))
>>>
>>> rosen,
>>>
>>> 2012/10/2 Juan G Victores <jcg...@gm...>:
>>>> Dear openrave-users list,
>>>> Is it possible to make gravity affect objects created with
>>>> InitFrom[Boxes/Spheres/Geometries]?
>>>> I'm using the C++ interface (I'd be happy with a Python example), so I added
>>>> the following lines:
>>>> ssphKinBodyPtr->GetLinks()[0]->SetMass(1);
>>>> Vector inertia(1,2,3);
>>>> ssphKinBodyPtr->GetLinks()[0]->SetPrincipalMomentsOfInertia(inertia);
>>>> Transform pose(Vector(1,0,0,0),Vector(0,0,0));
>>>> ssphKinBodyPtr->GetLinks()[0]->SetLocalMassFrame(pose);
>>>>
>>>> This had no effect, so I tried a
>>>> "ssphKinBodyPtr->GetLinks()[0]->SetStatic(false);" and ended up with a
>>>> pretty bad exception: """what(): openrave (NotInitialized): [virtual void
>>>> OpenRAVE::KinBody::SetDOFValues(const std::vector<double>&, uint32_t, const
>>>> std::vector<int>&):1091] (_nHierarchyComputed == 2) failed body ssph_1
>>>> internal structures need to be computed, current value is 0. Are you sure
>>>> Environment::AddRobot/AddKinBody was called?"""
>>>>
>>>> Could anyone give me any guidelines on how I could get this working?
>>>>
>>>> Cheers and thanks in advanced,
>>>> -juan
>>>>
>>>> PS: I'm using ODE as the physics engine.
>>>> ________________________________________________________
>>>> http://roboticslab.uc3m.es/roboticslab/persona.php?id_pers=72
>>>> PhD Candidate - RoboticsLab Researcher
>>>> Dpto. de Ingeniería de Sistemas y Automática
>>>> Universidad Carlos III de Madrid
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Don't let slow site performance ruin your business. Deploy New Relic APM
>>>> Deploy New Relic app performance management and know exactly
>>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app
>>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
>>>> http://p.sf.net/sfu/newrelic-dev2dev
>>>> _______________________________________________
>>>> Openrave-users mailing list
>>>> Ope...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/openrave-users
>>>>
|