Home | Tutorials | Wiki | Issues
Ask Your Question
0

Why can't I set PID gains through JointController?

asked 2017-01-27 12:36:53 -0600

kaldo gravatar image

Hello,

When I set the gains of my PID object using a direct reference it works, as :

common::PID pid = common::PID(0.1, 0, 0);
std::cout << pid.GetPGain();

pid.SetPGain(0.5);
std::cout << pid.GetPGain();

produces

0.1
0.5

However, when I access it through the joint controller, the gain value isn't set.

std::cout << model->GetJointController()->GetPositionPIDs()[joint->GetScopedName()]->GetPGain();

model->GetJointController()->GetPositionPIDs()[joint->GetScopedName()]->SetPGain(0.5);

std::cout << model->GetJointController()->GetPositionPIDs()[joint->GetScopedName()]->GetPGain();

produces

0.1
0.1

Does GetPositionPIDs not provide you with the actual PID objects, but a bunch of copies?

Cheers,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-01-27 13:52:54 -0600

chapulina gravatar image

Yes, it looks like GetPositionPIDs is returning copies. See this at the API documentation.

I think the correct way to do what you want is to construct a new PID object and use Joint::Controller:SetPositionPID (API)

edit flag offensive delete link more

Comments

Actually, reading the doc had led me to think I would get the actual objects. So I was surprised at the actual behavior and wondering if it was intended.

kaldo gravatar imagekaldo ( 2017-01-27 17:10:04 -0600 )edit

I believe a copy is made unless you return a reference or a pointer.

chapulina gravatar imagechapulina ( 2017-01-27 17:11:45 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-01-27 12:36:53 -0600

Seen: 295 times

Last updated: Jan 27 '17