Commit Graph

44 Commits

Author SHA1 Message Date
Sravan Balaji
d591bb68c9 Try adjusting track boundary constraints (still being violated, but not detected)
- Use all track boundary points when checking if position is inside
- Still fails to stop simulation when car goes off track
2021-12-13 07:45:23 -05:00
Sravan Balaji
91fc8ff4c3 Playing with Nonlinear Constraint Costs
- Drastically increase nonlinear constraint violation cost (I think)
- Make state & input costs much smaller than constraint costs
- Add condition to stop simulation if nonlinear constraint
  is not satisfied (doesn't seem to work for going off track)
- Create separate nonlinear constraints for each state to check
  if it is on track and if it doesn't intersect each obstacle
- Change indexing of nonlinear constraints
2021-12-13 07:16:27 -05:00
Sravan Balaji
69c704e66b More outputs / debugging info
- Decrease `sim_stop_idx` to 1500
- Add some debugging messages for when simulation hits
  limit or when `fmincon` can't satisfy constraints
- Add more `fmincon` outputs for future debugging
- Add obstacle information to `getTrajectoryInfo` call
  in `part2_test_controller.m` to see when car crashes
2021-12-12 17:31:52 -05:00
Sravan Balaji
6f6db84c23 Simulation Stop Index & Obstacle Plotting
- Add parameter to stop simulation when specified
  index in reference trajectory is reached
- Modify `forwardIntegrate` to return `Xobs` for plotting
- Plot obstacles in part2 testing figure
- Change some line plotting styles for clarity
2021-12-12 16:29:20 -05:00
Sravan Balaji
5534819d90 File Renaming / Reorganization & Minor Changes
- Add 1/2 coefficient to cost function
- Move `MPC_Class.m` to "Deliverables" folder
- Modify `part2_test_controller.m` plotting style a bit
- Rename `part2_MPC_controller.m` to `sravan_MPC_controller.m`
2021-12-12 16:03:27 -05:00
Sravan Balaji
0812db21ef Bunch of Fixes & Add Some Testing Scripts
- Fix missing references to `obj`
- Fix `npredinputs` so it matches `npredstates` as specified by
  `forwardIntegrate.m`
- Fix typo: `get_start_idx` -> `obj.get_state_start_idx`
- Fix nonlinear constraint indexing issue
- Fix nonlinear constraint obstacle indexing typo
- Remove unused `nonlinear_bike_model` function
- Compute continuous system matrices offline and convert
  to function with `matlabFunction`: `A_c_func` & `B_c_func`
- Add `miscellaneous_stuff.m` which has some random testing
  and continuous system matrix generation code
- Add `part2_test_controller.m` for testing part2 deliverable
2021-12-12 15:27:37 -05:00
Sravan Balaji
6361cfd40c Fix Missing References & Add clamp Function
- Change `SpecifyObjectiveGradient` to `false`
- Fix missing references to `obj`
- Add missing `clamp` function
2021-12-12 14:50:11 -05:00
Sravan Balaji
2d3304ace1 Implement compute_inputs to call fmincon
- Call fmincon with cost function and constraints in `compute_inputs`
- Add function `get_ref_decision_variable` to construct the full
  decision variable for reference trajectory from reference
  states and inputs
2021-12-12 14:36:39 -05:00
Sravan Balaji
637112e60c Cost Function for fmincon
- Add quadratic cost function using state costs (Q)
  and input costs (R)
- Use `npredstates` and `npredinputs` instead of `npred`
  when looping through states and inputs
- Update `get_state_start_idx` and `get_input_start_idx`
  descriptions to include assumption of `i` starting at 0
2021-12-12 14:14:55 -05:00
Sravan Balaji
943aac2e8d Nonlinear Track & Obstacle Constraints
- Add `nonlcon` function that checks if position is on track
  and not on or inside an obstacle
- Add `options` for `fmincon` to not specify constraint gradient,
  but specify objective gradient
- Add parameter for number of track boundary points to use
  around the closest point to current position when checking
  if point is inside track polygon
2021-12-12 13:53:16 -05:00
Sravan Balaji
96aa438587 Bunch of new properties, remove unnecessary function arguments
- Add properties for prediction horizon of states & inputs
- Add properties for obstacles, current state, reference index,
  and termination flag
- Update constructor to take in and set new properties
- Move properties with calculated values to constructor
- Remove function inputs for new properties
- Rename `curr_state` to `Y_curr` in `MPC_Class.m`
- Use object properties instead of function arguments (e.g., obj.ref_idx)
2021-12-12 13:26:15 -05:00
Sravan Balaji
fde6b62ac4 Add Euler Discretization Equality Constraint
- Use problem 4 solution `eq_cons` function as baseline
- Add number of decision states/inputs as properties
2021-12-12 12:29:48 -05:00
Sravan Balaji
04d0734b48 Add Kinematic Models
- Add nonlinear and linearized bike model functions
- Add `bike_model_helper` function to perform intermediate
  calculations
2021-12-10 12:47:25 -05:00
Sravan Balaji
8f94243964 Comments & Clean-Up
- Add more comments describing class, functions, variables, etc.
- Remove some unnecessary TODO comments
2021-12-10 10:49:00 -05:00
Sravan Balaji
28fc4d8b47 Boundary Constraints & Index Helper Functions
- Add boundary constraints for staying on the "map"
  and staying within operating limits of vehicle inputs
- Add helper functions to get indices of things
2021-12-10 10:20:53 -05:00
Sravan Balaji
d16e25ca85 Update part2 function to use MPC_Class
- Update part2 deliverable function to use `MPC_Class`
- Clean-up some comments in `MPC_Class`
- Add MPC tunable parameters to `MPC_Class`
- Add TODO comments
2021-12-10 08:05:47 -05:00
Sravan Balaji
b562360f6b Start working on MPC Class
- Add `MPC_Class` to perform all MPC related computation
  for use with part 2's deliverable function
2021-12-10 07:31:13 -05:00
Sravan Balaji
a0d868db88 Delete some old code 2021-12-09 17:59:12 -05:00
Sravan Balaji
729fd4fc05 Position Limits & Update bound_cons
- Add max/min position limits
- Delete `eq_cons` function for now
- Update `bound_cons` to enforce limit and
  max/min position limits
- Rename `nonlincon` to `road_obstacle_cons`
- Parameterize index search around closest
  road boundary point in `road_obstacle_cons`
2021-12-09 17:52:41 -05:00
Sravan Balaji
5218d7fbec Nonlinear Constraints for Road & Obstacles
- Use `inpolygon` to check if position is within road
  and not in or on an obstacle
- Add helper function `get_start_idx` to get
  starting index of Z(i) [states(i), inputs(i)]
  in Z vector (combined states & inputs for prediction
  horizon)
2021-12-09 17:30:44 -05:00
Sravan Balaji
6416cc762b Reference Trajectory States & Global Variable Clean-Up
- Add generated states from part 1 as variable
  `ROB535_ControlProject_part1_state` to
  `ROB535_ControlProject_part1_Team3.mat`
- Make step size and prediction horizon global variables
- Remove references to unused global variables
- Fix reference trajectory indexing with "i" based
  on `ROB535_ControlProject_part1_state` variable
- Replace `dt` with `T_s` in `linearized_bike_model`
2021-12-09 14:27:38 -05:00
Sravan Balaji
3e873fc597 Simulation Parameters & File Loading
- Rename `xenia_sravan_nonlinearopt.m` to `part2_MPC_controller.m`
- Add commands to close figures, clear workspace, and clear terminal
- Load track information & reference trajectory
- Add simulation parameters (step size & prediction horizon)
2021-12-09 14:18:53 -05:00
Sravan Balaji
28ad7d9d21 Clean-Up & Compute Linearized Model
- Delete nonlinear optimization functions
- Move intermediate kinematic model computations to
  `bike_model_helper` function
- Compute discrete-time linearized model in `linearized_bike_model`
  function
2021-12-09 14:05:43 -05:00
Sravan Balaji
79711d6e7a Start Implementing MPC based on Xenia's work
- Copy `xenia_nonlinearopt.m` to `xenia_sravan_nonlinearopt.m`
- Clean up nonlinear bike model: add comments, whitespace,
  intermediate variables, etc.
- Add helper function `clamp` to clamp a value between min
  and max limits
2021-12-09 13:02:37 -05:00
Sravan Balaji
c3c9546342 Incorporate xenia-nonlinear branch changes
- Copy-paste `xenia_nonlinearopt.m` from xenia-nonlinear branch
2021-12-09 12:58:51 -05:00
Sravan Balaji
f7b9eb687c Extend end of part 1 trajectory so car crosses finish line
- Increase the number of steps in last sector so the
  car actually crosses the finish line and registers
  a "t_finished" in the getTrajectoryInfo output
2021-12-08 11:26:43 -05:00
Sravan Balaji
4ea4a830de Add Project Document w/ Updated Due Date 2021-12-08 11:19:42 -05:00
Sravan Balaji
b036087001 Add Gitignore & Garbage Submission for Part 2
- Add gitignore for matlab's "asv" files
- Provide garbage inputs for qualifying session submission of part 2
2021-11-30 15:45:46 -05:00
Sravan Balaji
33945f6414 Re-Organize Files Again
- Deliverables folder holds final files for submission
- Experimentation holds scripts and things related to our development of
  a final solution
- Simulation holds the provided files
- Added template for part 2 submission with comments
2021-11-30 11:17:24 -05:00
Sravan Balaji
b0ad7defd3 Move Files out of "SimPkg_F21(student_ver)" folder 2021-11-30 10:46:06 -05:00
xdemenchuk
2de1b54ba9 typo.... not sure how this didn't come up earlier but ok 2021-11-29 18:18:41 -05:00
xdemenchuk
3a954497dc nonlinear trajectory based on sravan segments 2021-11-29 18:00:10 -05:00
xdemenchuk
21434cb4de iteration attempt 2021-11-29 14:09:19 -05:00
xdemenchuk
3637368bfb typo. 2021-11-28 18:56:57 -05:00
xdemenchuk
cc4d3a4ea2 change to phi bounds 2021-11-28 18:53:09 -05:00
xdemenchuk
81363e8e2a commiting 2021-11-28 18:35:59 -05:00
ppongsa
eed2424543 Add files via upload
Added calculation for dg for "nonlcon" function; Added diff_g function to calculate dg_dz
2021-11-28 12:24:44 -05:00
ppongsa
1a20a1f4a3 Add files via upload
*Ignore the stuff that runs* Added "bounds" function to generate lower and upper bound; Added "nonlcon" function  that generates g vector
2021-11-27 21:22:09 -05:00
Sravan Balaji
420dc67a26 Plot Trajectory of Submission Inputs
- Load the mat file with part 1 deliverable inputs
- Plot second figure with final submission trajectory
2021-11-26 15:48:04 -05:00
Sravan Balaji
6cde3df187 Save part 1 deliverable
- Rename `sravan_part_1.m` to `part1_generate_trajectory.m`
- Save inputs to variable called `ROB535_ControlProject_part1_input`
- Save variable to `ROB535_ControlProject_part1_Team3.mat`
2021-11-26 15:32:29 -05:00
Sravan Balaji
a1aa4e87f0 Generate Valid Trajectory to Complete Track
- Update input values
- Generate full set of inputs and simulate entire trajectory
2021-11-26 15:27:09 -05:00
Sravan Balaji
a37a1d62d3 Working on Generating Trajectory Manually
- Move provided files out of "SimPkg_F21(student_ver)" folder
- Add `sravan_part_1.m` that generates segments of trajectory
- Currently at 57.34% track completion
2021-11-26 14:42:21 -05:00
Sravan Balaji
15263a552e Model Parameters
- Add sravan_part_1.m with vehicle parameters and initial conditions
2021-11-24 09:09:32 -05:00
Sravan Balaji
0d1791887a Initial Commit
- Add provided template code for control project
- Add control project documentation pdf
2021-11-08 17:01:23 -05:00