Where tilt.current_tilt is set?

Dear all,

I start to rewrite our old original VTOL source code by arduplane.
I’m reading source code (arduplane 4.0.5) to learn about tilt rotor vtol.

Function “void QuadPlane::tiltrotor_slew(float newtilt)” in tiltrotor.cpp
controls the tilt angle of rotors.
But I can not find where tilt.current_tilt is set.

Could someone please teach me?
Thank you.

Its set in the slew functions, there is one for each type of tilt (line 43 and 145). If you use VS Code you can search the whole folder for ‘tilt.current_tilt’ and see exactly how it is used.

Dear Peter-san,
Thank you for your reply.

I am also using VS-Code.
And I had searched ‘tilt.current_tilt’ in the whole folder.

I understand that the part you pointed out is the part
that updates ‘tilt.current_tilt’.

Such as:

float max_change = tilt_max_change(newtilt<tilt.current_tilt);
tilt.current_tilt = constrain_float(newtilt, tilt.current_tilt-max_change, tilt.current_tilt+max_change);

But I have not found any code to initialize’tilt.current_tilt ‘.
Where is’tilt.current_tilt’ initialized?
Iis the initial value of ‘tilt.current_tilt’ 0?

Thank you.

It is initialized on line 442 of quadplane.h, as it is a structure you can just search for current_tilt because it is not initialized with the tilt.current_tilt syntax. It is automatically set to 0

Dear Peter-san,

Thank you for your reply.
‘zero initialization’ is a rule in c ++, isn’t it?

Ok, I see that.
It become clear for me!

Thank you.