Assignment 1


Reading: Find material on Dijstra's Algorithm and read through carefully at least once. For example: section 8.9 of Module 8 of the Algorithms course. You won't need this material for the assignment below but will need it for the next assignment.

This assignment builds on the CarSim exercises in the Intro module. You will write a controller for the Dubin car (non-accelerative case) to perform a single task and to do so optimally.

But first, let's see how a car simulator can be used without the GUI. Suppose you have written a controller. There are two ways you can test your controller:

Here's an example of using an instance of SimpleCarSimulator (for the unicycle, say):
public class SimpleCarControlTest {
    public static void main (String[] argv) 
    {
        // Build an instance of the simulator. Note: no obstacles in this example.
        // The constructor: isAccel=false, isUnicycle=true
        SimpleCarSimulator simulator = new SimpleCarSimulator (false, true);
        simulator.init (50, 50, 0, null);

        // This example moves the unicycle from (50,50) to (550,50).
        double x = 50;

        while (x < 550) {

            // Pass the controls (v=10, theta=0) to the simulator. DeltaT=0.1.
            simulator.nextStep (10, 0, 0.1);

            // Now extract the new location and other info.
            double t = simulator.getTime ();
            x = simulator.getX ();
            double y = simulator.getY ();

            // Display.
            System.out.println ("t=" + t + " x=" + x + " y=" + y);

            // The CarGUI merely adds an animation delay and drawing here.

        } //end-while
        
    }
}
To use the DubinCarSimulator, your code would be similar:
public class DubinCarControlTest {
    public static void main (String[] argv) 
    {
        // Build an instance of the simulator. Note: no obstacles in this example.
        // The constructor: isAccel=false
        DubinCarSimulator simulator = new DubinCarSimulator (false);
        simulator.init (50, 50, 0, null);

        // This example moves the car from (50,50) to (550,50).
        double x = 50;

        while (x < 550) {

            // Pass the controls (v1=10, v2=10) to the simulator. DeltaT=0.1.
            simulator.nextStep (10, 10, 0.1);

            // Now extract the new location and other info.
            double t = simulator.getTime ();
            x = simulator.getX ();
            double y = simulator.getY ();

            // Display.
            System.out.println ("t=" + t + " x=" + x + " y=" + y);

        } //end-while
        
    }
}
  

You are to use the configuration in Scene-3:

Thus, the initial position is:

The ultimate goal is to reach the target quickly and in the orientation facing rightwards. However, you are to do this in four discrete phases:

You should experiment with various values of A, v1 and v2 to see which values get you to the target (and facing rightwards) the soonest. Write code to systematically try different values of A, v1 and v2, using the GUI-less simulator. This latter program is different than the controller that uses the best values. Then, when you have the optimal values, use these in your controller so that the version loaded into the GUI uses the optimal values.

Guidelines:

Submission: