Car test bench
Checking sign-in...
Name
Mode
Bore analyze
Matrix test
Matrix size
Smoke
Standard
Wide
Datatype
data WheelCar = WheelCar { wcPos :: Double , wcVel :: Double } deriving (Read, Show, Eq)
Stateful
data Smoother = Smoother { smootherAlpha :: Double , smootherValue :: Double } deriving (Read, Show, Eq) data StatefulCar = StatefulCar { preSmoothers :: [Smoother] , postSmoothers :: [Smoother] , previousSmoothedInput :: Maybe Double , unStateful :: WheelCar } deriving (Read, Show, Eq) initialState :: StatefulCar initialState = StatefulCar [Smoother 0.35 0, Smoother 0.2 0] [Smoother 0.5 0, Smoother 0.25 0] Nothing (WheelCar 0 0) stepSmoother :: Double -> Smoother -> (Smoother, Double) stepSmoother input (Smoother alpha old) = let value = old + alpha * (input - old) in (Smoother alpha value, value) runSmootherStack :: [Smoother] -> Double -> ([Smoother], Double) runSmootherStack [] value = ([], value) runSmootherStack (smoother:rest) value = let (smoother', value') = stepSmoother value smoother (rest', output) = runSmootherStack rest value' in (smoother' : rest', output) stepState :: Double -> StatefulCar -> StatefulCar stepState accel (StatefulCar preStack postStack previous (WheelCar p v)) = let (preStack', smoothedInput) = runSmootherStack preStack accel gradient = case previous of Nothing -> 0 Just old -> smoothedInput - old (postStack', smoothedGradient) = runSmootherStack postStack gradient v' = v + smoothedGradient in StatefulCar preStack' postStack' (Just smoothedInput) (WheelCar (p + v') v') getWheelCar :: StatefulCar -> WheelCar getWheelCar = unStateful
Parametric
data Params = Params { mass :: Double, drag :: Double } deriving (Show, Read, Eq) applyParams :: Params -> WheelCar -> WheelCar applyParams (Params m d) (WheelCar p v) = let v' = (v - d * v) / m in WheelCar p v'
Parameters
parametersVector :: [Double] parametersVector = [0.32712120153009894,-0.5,0.1974897487089038,0.5896522298455239,0.0,-5.484528131783012e-2,0.0,0.1,0.34078283854745767,0.790040553547442,0.5368317777290942,0.11576319765299567,0.16780070029199126,0.45190566591918474,0.7326758002461449,0.0,0.3358222281560302,0.6019360696896912,0.36108614038676023,0.0,1.0]
Run test
Account