private void Start()
    {
        InvokeRepeating("UpdateCar", 0f, 1 / Constants.targetHz);

        //Get dimensions of car sprite
        float length = GetComponentInChildren <Renderer>().bounds.size.x;
        float width  = GetComponentInChildren <Renderer>().bounds.size.y;

        //Initialize the controllers and system
        carController = new CarController(length);
        steerSys      = new FirstOrderSystem(Constants.carSimSteeringK, Constants.carSimSteeringTau, Constants.targetHz, 0f);
        throttleSys   = new AsymmetricFirstOrderSystem(Constants.carSimVelK, Constants.carSimVelIncreaseTau, Constants.carSimVelDecreaseTau, Constants.targetHz, 0f);

        // Set initial car state
        carState = new CarState(0, transform.position.z, transform.position.x, 0, length / 2, length / 2);
        goalPos  = transform.position;
        SetTargetPosition(goalPos);

        //Draw the lidar visualization
        line = gameObject.GetComponent <LineRenderer>();
        line.SetVertexCount(numLineSegments + 1);
        line.useWorldSpace = false;
        DrawLidar();

        Debug.Log(string.Format("track width {0}", GetTrackWidth()));
        Debug.Log(string.Format("track length {0}", GetTrackLength()));
    }
Example #2
0
 public AsymmetricFirstOrderSystem(float k, float increaseTau, float decreaseTau, float samplingFreqHz, float initialOutput)
 {
     prev           = 0f;
     beenIncreasing = true;
     increaseSystem = new FirstOrderSystem(k, increaseTau, samplingFreqHz, initialOutput);
     decreaseSystem = new FirstOrderSystem(k, decreaseTau, samplingFreqHz, initialOutput);
 }
Example #3
0
    private void Start()
    {
        InvokeRepeating("UpdateCar", 0f, 1 / Constants.targetHz);

        //Get dimensions of car sprite
        float length = GetComponentInChildren <Renderer>().bounds.size.x;
        float width  = GetComponentInChildren <Renderer>().bounds.size.y;

        carController = new CarController(length);
        steerSys      = new FirstOrderSystem(Constants.carSimSteeringK, Constants.carSimSteeringTau, Constants.targetHz, 0f);
        throttleSys   = new AsymmetricFirstOrderSystem(Constants.carSimVelK, Constants.carSimVelIncreaseTau, Constants.carSimVelDecreaseTau, Constants.targetHz, 0f);

        // Set initial car state
        carState = new CarState(0, transform.position.z, transform.position.x, 0, length / 2, length / 2);
    }
    void Start()
    {
        InvokeRepeating("ModifyGoal", 0f, 10f);        //for testing to set goal
        InvokeRepeating("CalculateControls", 0f, 1 / Constants.targetHz);

        //Get dimensions of car sprite
        float length = GetComponent <SpriteRenderer>().bounds.size.x;
        float width  = GetComponent <SpriteRenderer>().bounds.size.y;

        Debug.Log(string.Format("car length: {0}", length));

        carController = new CarController(length);
        steerSys      = new FirstOrderSystem(Constants.carSimSteeringK, Constants.carSimSteeringTau, Constants.targetHz, 0f);
        throttleSys   = new AsymmetricFirstOrderSystem(Constants.carSimVelK, Constants.carSimVelIncreaseTau, Constants.carSimVelDecreaseTau, Constants.targetHz, 0f);

        // Set initial car state
        // TODO: use the car's current direction as psi? DEVANSH
        carState = new CarState(0, transform.position.x, transform.position.y, 0, length / 2, length / 2);
    }
Example #5
0
    void Start()
    {
        InvokeRepeating("UpdateGoal", 0f, 1f);        //for testing to set goal
        InvokeRepeating("UpdateCar", 0f, 1 / Constants.targetHz);

        //Get dimensions of car sprite
        length = GetComponentInChildren <Renderer>().bounds.size.x;
        width  = GetComponentInChildren <Renderer>().bounds.size.y;
        Debug.Log(string.Format("car length: {0}", length));
        Debug.Log(string.Format("car width: {0}", width));

        carController = new CarController(length);
        steerSys      = new FirstOrderSystem(Constants.carSimSteeringK, Constants.carSimSteeringTau, Constants.targetHz, 0f);
        throttleSys   = new AsymmetricFirstOrderSystem(Constants.carSimVelK, Constants.carSimVelIncreaseTau, Constants.carSimVelDecreaseTau, Constants.targetHz, 0f);

        // Set initial car state
        transform.position = new Vector3(Constants.goalCoordinates.x, 1, Constants.goalCoordinates.z);
        carState           = new CarState(0, transform.position.z, transform.position.x, 0, length / 2, length / 2);
    }
Example #6
0
 public void AssignState(FirstOrderSystem other)
 {
     discreteSystem.AssignState(other.discreteSystem);
 }
Example #7
0
    public float Output(float input)
    {
        FirstOrderSystem selected = Select(input);

        return(selected.Output(input));
    }
Example #8
0
 public void ResetParams()
 {
     carController = new CarController(length);
     steerSys      = new FirstOrderSystem(Constants.carSimSteeringK, Constants.carSimSteeringTau, Constants.targetHz, 0f);
     throttleSys   = new AsymmetricFirstOrderSystem(Constants.carSimVelK, Constants.carSimVelIncreaseTau, Constants.carSimVelDecreaseTau, Constants.targetHz, 0f);
 }