// Use this for initialization void Start() { mainThruster = gameObject.transform.Find("Thrusters/MainThruster").GetComponent <Nozzle> (); frontLeftThruster = gameObject.transform.Find("Thrusters/FrontLeftThruster").GetComponent <Nozzle> (); frontRightThruster = gameObject.transform.Find("Thrusters/FrontRightThruster").GetComponent <Nozzle> (); backLeftThruster = gameObject.transform.Find("Thrusters/BackLeftThruster").GetComponent <Nozzle> (); backRightThruster = gameObject.transform.Find("Thrusters/BackRightThruster").GetComponent <Nozzle> (); frontThruster1 = gameObject.transform.Find("Thrusters/FrontThruster1").GetComponent <Nozzle> (); frontThruster2 = gameObject.transform.Find("Thrusters/FrontThruster2").GetComponent <Nozzle> (); if (weapons.Length != 0) { activeWeapon = weapons[0]; weaponIndex = 1; } else { weaponIndex = 0; } radar = gameObject.transform.Find("Radar").GetComponent <RadarController>(); radar.pingReach = radarRange; radar.SetRadarOff(); initialFuel = fuel; fuelIsBingo = false; pidController = gameObject.GetComponent <PIDController> (); if (gameObject.tag == "Vessel") { StartCoroutine(ClearSpaceAroundShip(false, 0.1f)); } }
private void Awake() { pidController = new PIDController(1, 0.5, 1); pidController.SetPoint = 0; rb = GetComponent <Rigidbody>(); }
// Start is called before the first frame update void Start() { Physics2D.IgnoreCollision(transform.parent.GetComponent <Collider2D>(), GetComponent <Collider2D>()); rb = GetComponent <Rigidbody2D>(); joyController = FindObjectOfType <JoyController>(); pidController = new PIDController(); }
public AttitudeControllerNode () { prevTime = new RosTime ( new Messages.TimeData ( 0, 0 ) ); // Roll controller double rollKp = 0; double rollKi = 0; double rollKIMax = 0; double rollKd = 0; rollController = new PIDController ( rollKp, rollKi, rollKd, rollKIMax, 0 ); // Pitch controller double pitchKp = 0; double pitchKi = 0; double pitchKIMax = 0; double pitchKd = 0; pitchController = new PIDController ( pitchKp, pitchKi, pitchKd, pitchKIMax, 0 ); // Yaw controller double yawKp = 0; double yawKi = 0; double yawKIMax = 0; double yawKd = 0; yawController = new PIDController ( yawKp, yawKi, yawKd, yawKIMax, 0 ); lastImu = new Imu (); zThrust = 0; }
public void ProportionalControl() { int setPoint = 5, minimumError = -5, maximumError = 5, minimumControl = 0, maximumControl = 10; var controller = new PIDController( minimumError, maximumError, minimumControl, maximumControl) { ProportionalGain = 1, IntegralGain = 0, DerivativeGain = 0 }; var seed = Enumerable .Range(minimumControl, maximumControl - minimumControl + 1) .ToList(); var expected = seed .Select(Convert.ToDouble) .Reverse() .ToList(); var actual = seed .Select(value => Math.Round(controller.Next(setPoint - value, 1000))) .ToList(); actual.Should().BeEquivalentTo(expected); }
//public bool showParticles = true; //public GameObject[] thrusterClockwise; //public GameObject[] thrusterCounterClockwise; // Start is called before the first frame update void Start() { desired_angle = 0; lightSensors = GetComponentsInChildren <LightSensor2>(); solarPanels = GetComponentsInChildren <SolarPanel2>(); rgbd = GetComponent <Rigidbody>(); //pidRotate = new PIDController(0.000001f, 0.025f, 0.0000f); pidRotate = new PIDController(5f, 1f, 0.01f); //pidRotate = new PIDController(1f, 0f, 0f); //pidRotate = new PIDController(1f, 0.001f, 0.001f); //pidRotate = new PIDController(0.001f, 0f, 0f); //AnimateThrusters(thrusterClockwise, false); //AnimateThrusters(thrusterCounterClockwise, false); socket = FindObjectOfType <NetworkHandler>().client; socket.On("connect", () => { //socket.FillSendBuffer<string>("u","\"float\""); socket.FillSendBuffer <string>("actual_angle", "\"float\""); socket.FillSendBuffer <string>("desired_angle", "\"float\""); socket.SendAvailableData(); }); }
public void Reinitialise() { transform.position = Vector3.zero; TargetDirection = new Vector3(transform.forward.x, 0f, transform.forward.z); TargetVelocity = Vector3.zero; PID = new PIDController(0.2f, 0.8f, 0f); Positions = new Vector3[Actor.Bones.Length]; Forwards = new Vector3[Actor.Bones.Length]; Ups = new Vector3[Actor.Bones.Length]; Velocities = new Vector3[Actor.Bones.Length]; Trajectory = new Trajectory(Points, Controller.GetNames(), transform.position, TargetDirection); if (Controller.Styles.Length > 0) { for (int i = 0; i < Trajectory.Points.Length; i++) { Trajectory.Points[i].Styles[0] = 1f; } } for (int i = 0; i < Actor.Bones.Length; i++) { Positions[i] = Actor.Bones[i].Transform.position; Forwards[i] = Actor.Bones[i].Transform.forward; Ups[i] = Actor.Bones[i].Transform.up; Velocities[i] = Vector3.zero; } }
public PositionControllerNode() { firstPoseReceived = false; // x config double xKp = 0; double xKi = 0; double xKIMax = 0; double xKd = 0; xController = new PIDController(xKp, xKi, xKd, xKIMax, 0); // y config double yKp = 0; double yKi = 0; double yKIMax = 0; double yKd = 0; yController = new PIDController(xKp, xKi, xKd, xKIMax, 0); // z config double zKp = 0; double zKi = 0; double zKIMax = 0; double zKd = 0; zController = new PIDController(xKp, xKi, xKd, xKIMax, 0); }
public void TearDown() { m_controller.Disable(); m_controller.Dispose(); m_controller = null; s_me.Reset(); }
public void SetUp() { input = new FakeInput(); output = new FakeOutput(); pid = new PIDController(0.05, 0.0, 0.0, input, output); pid.SetInputRange(-range/2, range/2); }
public void Setup() { s_me.Setup(); m_table = NetworkTable.GetTable("TEST_PID"); m_controller = new PIDController(m_kP, m_kI, m_kD, s_me.GetEncoder(), s_me.GetMotor()); m_controller.InitTable(m_table); }
void Awake() { Actor = GetComponent <Actor>(); NN = GetComponent <MANN>(); MotionEditing = GetComponent <MotionEditing>(); TargetDirection = new Vector3(transform.forward.x, 0f, transform.forward.z); TargetVelocity = Vector3.zero; PID = new PIDController(0.2f, 0.8f, 0f); Positions = new Vector3[Actor.Bones.Length]; Forwards = new Vector3[Actor.Bones.Length]; Ups = new Vector3[Actor.Bones.Length]; Velocities = new Vector3[Actor.Bones.Length]; Trajectory = new Trajectory(Points, Controller.GetNames(), transform.position, TargetDirection); if (Controller.Styles.Length > 0) { for (int i = 0; i < Trajectory.Points.Length; i++) { Trajectory.Points[i].Styles[0] = 1f; } } for (int i = 0; i < Actor.Bones.Length; i++) { Positions[i] = Actor.Bones[i].Transform.position; Forwards[i] = Actor.Bones[i].Transform.forward; Ups[i] = Actor.Bones[i].Transform.up; Velocities[i] = Vector3.zero; } if (NN.Parameters == null) { Debug.Log("No parameters saved."); return; } NN.LoadParameters(); }
public void PIDController_UnitTest3() { PIDController pid = new PIDController(100); // Creates a Robot Robot robot = new Robot(); // Append the periodic control loop to the robot scheduler robot.TaskScheduler.Add(thePeriodicTask: pid); // Starts the TaskScheduler with log robot.TaskScheduler.Start(true, true); // Waits 1s Thread.Sleep(1050); // Stops the TaskScheduler robot.TaskScheduler.Stop(); // Scheduler testato con tolleranza di 2ms. int numberOfLines = robot.TaskScheduler.LastExecutionLog.Split('\n').Length; for (int i = 0; i < (numberOfLines - 1); i++) { double timing = Convert.ToDouble(robot.TaskScheduler.LastExecutionLog.Split('\n')[i].Split(' ')[0]); Assert.AreEqual(100.0d * i, timing, 3.0f); } }
void InitPidController() { switch (pidController) { case multiWiiClean: PidController = new PIDController.pidMultiWiiClean(); break; case rewriteClean: PidController = new PIDController.pidRewriteClean(); break; case luxFloat: PidController = new PIDController.pidLuxFloat(); break; case multiWii23: PidController = new PIDController.pidMultiWii23(); break; case harakiri: PidController = new PIDController.pidHarakiri(); break; } var data = GetSaveData(PidController.SaveFileName, SaveName); PidController.LoadSaved(data); }
// Start is called before the first frame update void Start() { simulationTime = 0; robotsArr = GameObject.FindGameObjectsWithTag("Robot"); foreach (GameObject robot in robotsArr) { PIDController PC = robot.GetComponent <PIDController>(); if (PC != null) { robot.GetComponent <PIDController>().enabled = false; } } backCamera.enabled = false; topCamera.enabled = false; angleCamera.enabled = true; angleCameraDefaultRotation = angleCamera.transform.rotation.eulerAngles; robotsList = new List <GameObject>(GameObject.FindGameObjectsWithTag("Robot")); motorsList = new List <GameObject>(GameObject.FindGameObjectsWithTag("Motor")); sensorsList = new List <GameObject>(GameObject.FindGameObjectsWithTag("Sensor")); UI.createUiElements(robotsList, motorsList, sensorsList); }
// Use this for initialization void Start() { mainThruster = gameObject.transform.Find("Thrusters/MainThruster").GetComponent <Nozzle> (); frontLeftThruster = gameObject.transform.Find("Thrusters/FrontLeftThruster").GetComponent <Nozzle> (); frontRightThruster = gameObject.transform.Find("Thrusters/FrontRightThruster").GetComponent <Nozzle> (); backLeftThruster = gameObject.transform.Find("Thrusters/BackLeftThruster").GetComponent <Nozzle> (); backRightThruster = gameObject.transform.Find("Thrusters/BackRightThruster").GetComponent <Nozzle> (); frontThruster1 = gameObject.transform.Find("Thrusters/FrontThruster1").GetComponent <Nozzle> (); frontThruster2 = gameObject.transform.Find("Thrusters/FrontThruster2").GetComponent <Nozzle> (); if (weapons.Count != 0) { activeWeapon = weapons[0]; weaponNr = 1; } else { weaponNr = 0; } pidController = gameObject.GetComponent <PIDController> (); if (gameObject.tag == "Vessel") { StartCoroutine(ClearSpaceAroundShip(false, 0.1f)); } initialFuel = fuel; fuelIsBingo = false; initialHealth = health; }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); sr = GetComponent <SpriteRenderer>(); altitudePID1 = new PIDController(); altitudePID2 = new PIDController(); startIgnorePIDTime = 1f; }
public Cruiser(double dt, double thrustDeadZone) { thrustPID = new PIDController(dt); thrustPID.Kp = ThrustKp; thrustPID.Ti = ThrustTi; thrustPID.Td = ThrustTd; ThrustDeadZone = thrustDeadZone; }
protected void PreparePIDControllers(PIDControllerFactory PID_factory, ref PIDController[] PID_array, int PID_num) { PID_array = new PIDController[PID_num]; for (int i = 0; i < PID_array.Length; i++) { PID_array[i] = PID_factory.CreatePID(); } }
void Start() { quadcopterRB = gameObject.GetComponent <Rigidbody>(); PID_pitch = new PIDController(); PID_roll = new PIDController(); PID_yaw = new PIDController(); }
/// <summary> /// Creates a car controller that follows some path /// </summary> /// <param name="car">Car to control</param> /// <param name="path">Path to follow</param> public DrivingState(Vehicle car, Path path) { this.car = car; this.Path = path; LeaderVehicleInfo = new Dictionary <int, LeaderVehicleInfo>(); pidController = new PIDController(9.0f, 0.0f, 9.0f); }
private void CreatePIDs() { //Create an instance of the PIDController class for each hover point PIDs = new PIDController[HoverPoints.Length]; for (int i = 0; i < HoverPoints.Length; i++) { PIDs[i] = new PIDController(ProportionalGain, IntegralGain, DerivativeGain); } }
/// <summary> /// Copy settings from another controller /// </summary> public void CopySettings(PIDController controller) { overallAmplify = controller.overallAmplify; proportionalConst = controller.proportionalConst; integralConst = controller.integralConst; maxIntegralAbs = controller.maxIntegralAbs; derivativeConst = controller.derivativeConst; BIBO = controller.BIBO; }
public CarController(float axleDistance) { velController = new PIDController(Constants.pVel, Constants.iVel, Constants.dVel, Constants.throttleCommandMin, Constants.throttleCommandMax); posController = new PIDController(Constants.pPos, Constants.iPos, Constants.dPos, Constants.velMin, Constants.velMax); headController = new StanleyController(Constants.kpHeading, Constants.kdHeading, Constants.kCrosstrack, Constants.velDamping, axleDistance / 2); velKFeedforward = Constants.kFeedForward; discontinuityThreshold = Constants.discontinuityThreshold; posIThreshold = Constants.iThreshold; goalReceived = false; }
public PIDPRoc(PIDController c, float mt) { isDone = false; cont = c; cont.endOfPathCB += OnPathDone; maxTimePerRun = mt; camPos = Camera.main.transform.position; camRot = Camera.main.transform.rotation; }
public HoverControllerNode() { // PID params double kiMax = 20; double kp = 0; double ki = 0; double kd = 0; controller = new PIDController(kp, ki, kd, kiMax, 0); }
private void Awake() { _rigidbody = GetComponent <Rigidbody>(); _stateMachine = new StateMachine(); _controller = new PIDController(_rigidbody); dock.position = transform.position; dock.rotation = transform.rotation; _rlModule = GetComponent <RLModule>(); _meshModel = GetComponentInChildren <MeshRenderer>().transform.parent; }
// Use this for initialization void Start() { /* For those with time constraints: */ Time.timeScale = 1f; transform.position = new Vector3(0f, 0.5f, 0f); force = new Vector3(0f, 9.81f / 4, 0f); controller = new PIDController(setPoint, pGain, iGain, dGain, force, transform.position); controller.updateOutputSignal(transform.position); }
public Seeker(double dt) { yawPID = new PIDController(dt); pitchPID = new PIDController(dt); rollPID = new PIDController(dt); yawVPID = new PIDController(dt); pitchVPID = new PIDController(dt); rollVPID = new PIDController(dt); ControlThreshold = 0.01; }
public void turnOnController() { foreach (GameObject robot in robotsArr) { PIDController PC = robot.GetComponent <PIDController>(); if (PC != null) { robot.GetComponent <PIDController>().enabled = true; } } }
private void Awake() { ship = GetComponent <Ship>(); rBody = GetComponent <Rigidbody>(); // Initialize the PID controllers with preset parameters pid_angle = new PIDController(pid_P, pid_I, pid_D); pid_velocity = new PIDController(pid_P, pid_I, pid_D); wayPointList = new List <Transform>(); }
protected PIDCommand(string name, double p, double i, double d, double period) : base(name) { m_controller = new PIDController(p, i, d, this, this, period); }
protected PIDCommand(double p, double i, double d, double period) { m_controller = new PIDController(p, i, d, this, this, period); }
public Seeker(double dt) { yawPID = new PIDController(dt); pitchPID = new PIDController(dt); rollPID = new PIDController(dt); }
/// <summary> /// Instantiates a <see cref="PIDSubsystem"/> that will use the give p, i, d and f values. /// It will also space the time between PID loop calcuulations to be equal to the given period. /// </summary> /// <param name="name">The name</param> /// <param name="p">The proportional value</param> /// <param name="i">The integral value</param> /// <param name="d">The derivative value</param> /// <param name="f">The feed forward value</param> /// <param name="period">The time (in seconds) between calculations</param> protected PIDSubsystem(string name, double p, double i, double d, double f, double period) : base(name) { PIDController = new PIDController(p, i, d, f, this, this, period); }
public PIDSubsystem(string name, double p, double i, double d, double f) : base(name) { PIDController = new PIDController(p, i, d, f, this, this); }
void Start() { if (!playerInput) { playerInput = gameObject.GetComponent<PlayerInput>(); } if (!attachToSurface) { attachToSurface = gameObject.GetComponent<AttachToSurface>(); } if (!playerCamera) { playerCamera = Camera.main.transform; } pidControllerX = new PIDController(pGainX, iGainX, dGainX); pidControllerY = new PIDController(pGainY, iGainY, dGainY); pidControllerZ = new PIDController(pGainZ, iGainZ, dGainZ); }
public PIDSubsystem(double p, double i, double d, double period, double f) { PIDController = new PIDController(p, i, d, f, this, this, period); }
public void TearDown() { controller.Disable(); controller.Dispose(); controller = null; me.Reset(); }
public void TearDown() { pid.Dispose(); pid = null; }
public PIDSubsystem(double p, double i, double d) { PIDController = new PIDController(p, i, d, this, this); }
public void Setup() { me.Setup(); table = NetworkTable.GetTable("TEST_PID"); controller = new PIDController(k_p, k_i, k_d, me.GetEncoder(), me.GetMotor()); controller.InitTable(table); }
/// <summary> /// Instantiates a <see cref="PIDSubsystem"/> that will use the give p, i and d values. /// It will also space the time between PID loop calcuulations to be equal to the given period. /// It will use the class name as its name. /// </summary> /// <param name="p">The proportional value</param> /// <param name="i">The integral value</param> /// <param name="d">The derivative value</param> /// <param name="period">The time (in seconds) between calculations</param> protected PIDSubsystem(double p, double i, double d, double period) { PIDController = new PIDController(p, i, d, this, this, period); }