Library function is not working like regular function

I'm writing a library to control a flying wing type airplane. When I upload this to the Arduino the rudder servo goes to 0 degrees but tries to keep pushing further. The left and right servos don't react in ant way. I tried to use FullControl in a regular function in an ino file and it worked completely fine. This is my code:

main Arduino code (.ino):
#include"FlyingWingRudder.h"

FlyingWingRudder plane(9,8,7); // declares the FlyingWingRudder object
void setup() {
}
void loop() {
 plane.FullControl(15,15,15);  // controls the Elevator, Ailerons and rudder
}







library (.h file)
#ifndef FlyingWingRudder_h
#define FlyingWingRudder_h
#include "Arduino.h"

class FlyingWingRudder{
 public:
   FlyingWingRudder(int leftServo , int rightServo , int rudderServo);
   void FullControl(int PowerE, int PowerA, int PowerR);
   
 private:
   int _leftServo;
   int _rightServo;
   int _rudderServo;
   int _Power;
   int _PowerE;
   int _PowerR;
   int _PowerA;
};

#endif










library (.ccp) file
#include "Arduino.h"
#include "FlyingWingRudder.h"
#include <Servo.h>

Servo left;   //left flap servo
Servo right;  //right flap servo
Servo Rudder; // rudder servo

//float positionLeft = 90;
//float positionRight = 90;
//float positionRudder = 90;

FlyingWingRudder::FlyingWingRudder(int leftServo , int rightServo ,int rudderServo){   //attaches the servos to the pins specified in the program
 
 left.attach(leftServo);
 right.attach(rightServo);
 Rudder.attach(rudderServo);
}

void FlyingWingRudder::FullControl(int PowerE , int PowerA , int PowerR ){  // power (in degrees) of the Elevator, Aileron and Rudder

  if(PowerE > 0 && PowerA > 0){               //the elevator will tilt the plane upwards and the aileron will roll the plane anticlockwise
   left.write(90 + PowerA + PowerE);
   right.write(90 - PowerA + PowerE);
 }
  if(PowerE > 0 && PowerA < 0){         //the elevator will tilt the plane upwards and the aileron will roll the plane clockwise
   left.write(90 - PowerA + PowerE);
   right.write(90 + PowerA + PowerE);
 }
 if(PowerE > 0 && PowerA == 0){  //the elevator will tilt the plane upwards and the aileron is disabled
   left.write(90 + PowerE);
   right.write(90 + PowerE);
 }


 
 if(PowerE < 0 && PowerA > 0){               //the elevator will tilt the plane downwards and the aileron will roll the plane anticlockwise
   left.write(90 + PowerA - PowerE);
   right.write(90 - PowerA - PowerE);
 }
  if(PowerE < 0 && PowerA < 0){             //the elevator will tilt the plane downwards and the aileron will roll the plane clockwise
   left.write(90 - PowerA - PowerE);
   right.write(90 + PowerA - PowerE);
 }
  if(PowerE < 0 && PowerA == 0){            //the elevator will tilt the plane downwards and the aileron is disabled
   left.write(90 - PowerE);
   right.write(90 - PowerE);
 }
   Rudder.write(90 + PowerR);            //turns the plane's rudder
 
}

Why are your 3 Servos global variables in the .cpp file rather than (private) members of the FlyingWingRudder class?

You should probably attach the Servos in a begin() method rather than in the constructor.

I think gfvalvo is right about calling Servo::attach() in your constructor being the cause of the problem. That sets the pin mode. You should not do any hardware work in the constructor because of the order in which that code will be ran (before hardware configuration is done via init()).

So I should declare my servos in the private section of the FlyingWingRudder class in the .h file?

That will give you better OOP encapsulation / abstraction. But, you still also need to move calls to .attach() out of the constructor as I mentioned in Reply #1.

so how would I assign pins to the servos?

I'd pass the pin numbers to the constructor, then write them to global variables there, but pass the pin numbers to Servo.attach() in FlyingWingRudder::begin(). This is a very common paradigm in Arduino libraries.