Home | Tutorials | Wiki | Issues
Ask Your Question
0

Use of GetLinkForce or GetLinkTorque

asked 2016-03-16 12:14:32 -0600

gabri89 gravatar image

Hi,

In my gazebo plugin, I have to use the function

virtual math::Vector3 gazebo::physics::Joint::GetLinkForce ( unsigned int   _index) const pure virtual

or

virtual math::Vector3 gazebo::physics::Joint::GetLinkTorque ( unsigned int  _index) const pure virtual

These functions should return the force applied at the centre of mass of a link; the problem is that this functions are pure virtual, so I must define them. I could use the ODEJoint class (that inherits from Joint class): this owns the above functions, but only virtual.

I don't understand how to use the ODEJoint class, nay how to include this class in my plugin.

Can I use this functions without having ODEJoint?

Thank you!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-03-23 03:48:39 -0600

gabri89 gravatar image

Hi I solved the proble adding

joint1->SetProvideFeedback(1);

command. So I can use GetLinkForce without problem.

edit flag offensive delete link more
0

answered 2016-03-16 12:27:46 -0600

You're not the one who must define it, each of the 4 physics engines supported by Gazebo will have its implementation.

Gazebo's API is organized in a way that you can call the base class functions, and under the hood, the function for the current physics engine will be called for you. This is made so you can switch physics engines without changing your code.

So if you're using ODE as the physics engine and call Joint::GetLinkForce, ODEJoint::GetLinkForce will actually be called. The same is valid for the other physics engines.

See this plugin for example. It calls SetForce, which is also pure virtual.

edit flag offensive delete link more
0

answered 2016-03-16 12:24:16 -0600

nkoenig gravatar image

Those functions get implemented by a specific physics engine, such as ODE or Bullet or Simbody. You can call a pure virtual function, and the correct implementation will be used automatically.

You should not try to implement that function, unless you are trying to implement a new physics engine.

Maybe you should describe what you are trying to do.

edit flag offensive delete link more

Comments

Hi, I would like to obtain the force applied on the link at every gazebo step. So, as usual I get the pointer to the joint in the Load function: joint=this->model->GetJoint("joint_name"); Then in the OnUpdate function (called in the Load) I try to obtain the force: force=joint->GetLinkForce(index); (I defined force as a class variable math::Vector3). This causes segmentation fault. Can my problem be caused by an error on the pointer? I thought that it was caused by the GetLinkForce function.

gabri89 gravatar imagegabri89 ( 2016-03-16 13:27:28 -0600 )edit

You should generate a backtrace using gdb to see where the segmentation fault is occurring. You could have a bad pointer, but it's hard to say without more information.

nkoenig gravatar imagenkoenig ( 2016-03-16 13:32:20 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-16 12:14:32 -0600

Seen: 284 times

Last updated: Mar 23 '16