Replace hardcoded values for Pi (#20235)

* Avoid redefining pi, use instead math.pi or M_PI from math.h

* Revert overwriting of the gpsPi variable, which is part the GPS standard.

* Move standard library imports to top, remove standard library import comments.
old-commit-hash: 93911a7dbe
commatwo_master
wolterhv 4 years ago committed by GitHub
parent 0818f7166d
commit 56f48a03bc
  1. 3
      selfdrive/car/ford/carcontroller.py
  2. 3
      selfdrive/car/mock/interface.py
  3. 6
      selfdrive/controls/lib/lateral_mpc/generator.cpp

@ -1,3 +1,4 @@
import math
from cereal import car from cereal import car
from selfdrive.car import make_can_msg from selfdrive.car import make_can_msg
from selfdrive.car.ford.fordcan import create_steer_command, create_lkas_ui, spam_cancel_button from selfdrive.car.ford.fordcan import create_steer_command, create_lkas_ui, spam_cancel_button
@ -33,7 +34,7 @@ class CarController():
if (frame % 3) == 0: if (frame % 3) == 0:
curvature = self.vehicle_model.calc_curvature(actuators.steeringAngleDeg*3.1415/180., CS.out.vEgo) curvature = self.vehicle_model.calc_curvature(actuators.steeringAngleDeg*math.pi/180., CS.out.vEgo)
# The use of the toggle below is handy for trying out the various LKAS modes # The use of the toggle below is handy for trying out the various LKAS modes
if TOGGLE_DEBUG: if TOGGLE_DEBUG:

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import math
from cereal import car from cereal import car
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog
@ -10,7 +11,7 @@ from selfdrive.car.interfaces import CarInterfaceBase
TS = 0.01 # 100Hz TS = 0.01 # 100Hz
YAW_FR = 0.2 # ~0.8s time constant on yaw rate filter YAW_FR = 0.2 # ~0.8s time constant on yaw rate filter
# low pass gain # low pass gain
LPG = 2 * 3.1415 * YAW_FR * TS / (1 + 2 * 3.1415 * YAW_FR * TS) LPG = 2 * math.pi * YAW_FR * TS / (1 + 2 * math.pi * YAW_FR * TS)
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):

@ -1,8 +1,8 @@
#include <math.h>
#include <acado_code_generation.hpp> #include <acado_code_generation.hpp>
#include "common/modeldata.h" #include "common/modeldata.h"
#define PI 3.1415926536 #define deg2rad(d) (d/180.0*M_PI)
#define deg2rad(d) (d/180.0*PI)
const int N_steps = 16; const int N_steps = 16;
using namespace std; using namespace std;
@ -23,7 +23,7 @@ int main( )
OnlineData rotation_radius; OnlineData rotation_radius;
Control curvature_rate; Control curvature_rate;
// Equations of motion // Equations of motion
f << dot(xx) == v_ego * cos(psi) - rotation_radius * sin(psi) * (v_ego * curvature); f << dot(xx) == v_ego * cos(psi) - rotation_radius * sin(psi) * (v_ego * curvature);

Loading…
Cancel
Save