MPC-Berkeley / genesis_path_follower

MPC Path Follower for the Hyundai Genesis.
MIT License
152 stars 67 forks source link

Improvements #3

Open govvijaycal opened 4 years ago

govvijaycal commented 4 years ago

We should sync updates made on the lanekeeping and GXZ_kin branches. This would primarily be done by modifying the parse_rosbag scripts to capture the road frame and curvature information into the mat file. And then by adjusting the messages / main controller code to handle variation of the controller used.

Also, may be a good idea to remove unneeded elements from the analysis folder and/or add a README for future improvement.

huckl3b3rry87 commented 3 years ago

Speaking of improvements, I am curious why you switch from julia/JuMP to python/CASADI? I am also curious how the performance stacks up?

Thanks and great work!

govvijaycal commented 3 years ago

So there were a few reasons to move away from JuMP: (1) Initially I used RobotOS.jl but it was slow (I think it needs to compile messages every time you run a node). (2) I had precompilation working for the MPC module in Julia but it may still need a couple seconds to start up. (3) I tried to use pyjulia to remove the requirement of having a main script be in Julia, so only the MPC portion could be written in Julia. This is tricky since I could only get this working smoothly with specific versions of Julia and Python. (4) Casadi provides a similar interface to JuMP if you use the opti interface and starts almost immediately. I think, under the hood, it's basically a wrapper to Ipopt in C++ so the speeds are pretty good.

I found that, with a warm start, Casadi/Ipopt can find solutions at 50 Hz. Earlier, with JuMP/Ipopt, I could only get max 20 Hz, although it's likely I wasn't properly warm starting (just relied on whatever is cached when you call the solve function in JuMP). This hasn't been tested though with difficult optimization problems (e.g. collision avoidance); in this repo, usually the warm start is close to optimal since the reference path changes slowly.

So mostly changed due to simplicity, speed of start up with ROS/Python, and the fact that I don't need an additional install/configuration of Julia. Just need to do pip install casadi and that's it.

huckl3b3rry87 commented 3 years ago

Thank you very much for going into the details of this.

I definitely know the struggle of setting things up with Julia/RobotOS/Python and ROS, possible, but not fun.

Wow, there is a huge difference in speed!

huckl3b3rry87 commented 3 years ago

to stop printing all the messages, try

        p_opts = {"expand": True, "print_time":False}