I'm trying to make this part of my program run more efficiently and I'm not sure what the best way is to optimize this block of code so its quicker
An input to the system ranging from 1 to -1 (it's sensitive, I need fine detail). I am trying to compute an output which is called yaw_cmd_v
(yaw commanded voltage)
//Here we try to put force values based on rudder deflection but divided into many parts to reduce noise and prevent suddend onset of force
if (rudderValueForce >= 0 && rudderValueForce <= 0.05) { yaw_CMND_V = -rudderValueForce * 0; }
if (rudderValueForce >= 0.05 && rudderValueForce <= 0.1) { yaw_CMND_V = -rudderValueForce * 5; }
if (rudderValueForce >= 0.1 && rudderValueForce <= 0.15) { yaw_CMND_V = -rudderValueForce * 10; }
if (rudderValueForce >= 0.15 && rudderValueForce <= 0.2) { yaw_CMND_V = -rudderValueForce * 15; }
if (rudderValueForce >= 0.2 && rudderValueForce <= 0.25) { yaw_CMND_V = -rudderValueForce * 20; }
if (rudderValueForce >= 0.25 && rudderValueForce <= 0.3) { yaw_CMND_V = -rudderValueForce * 25; }
if (rudderValueForce > 0.3 && rudderValueForce <= 0.5) { yaw_CMND_V = -rudderValueForce * 50; }
if (rudderValueForce > 0.5 && rudderValueForce <= 0.7) { yaw_CMND_V = -rudderValueForce * 60; }
if (rudderValueForce > 0.7 && rudderValueForce <= 1) { yaw_CMND_V = -rudderValueForce * 70; }
//Here we try to put force values based on rudder deflection but divided into many parts to reduce noise and prevent suddend onset of force
if (rudderValueForce >= -0.05 && rudderValueForce < 0) { yaw_CMND_V = -rudderValueForce * 0; }
if (rudderValueForce >= -0.1 && rudderValueForce < -0.05) { yaw_CMND_V = -rudderValueForce * 5; }
if (rudderValueForce >= -0.15 && rudderValueForce < -0.1) { yaw_CMND_V = -rudderValueForce * 10; }
if (rudderValueForce >= -0.20 && rudderValueForce <- 0.15) { yaw_CMND_V = -rudderValueForce * 15; }
if (rudderValueForce >= -0.25 && rudderValueForce <- 0.20) { yaw_CMND_V = -rudderValueForce * 20; }
if (rudderValueForce >= -0.3 && rudderValueForce <- 0.25) { yaw_CMND_V = -rudderValueForce * 25; }
if (rudderValueForce >= -0.5 && rudderValueForce <- 0.3) { yaw_CMND_V = -rudderValueForce * 50; }
if (rudderValueForce >= -0.7 && rudderValueForce <- 0.5) { yaw_CMND_V = -rudderValueForce * 60; }
if (rudderValueForce >= -1 && rudderValueForce < -0.7) { yaw_CMND_V = -rudderValueForce * 70; }
Aucun commentaire:
Enregistrer un commentaire