Fitting HMM/multievent capture-recapture models with TMB

I found materials on the internet to teach myself TMB, at least what I needed to implement a simple HMM model. See here for a linear regression and a Gompertz state space model examples, here for the same linear regression example on Youtube (that’s awesome!) and many other examples here. However, I got stuck and posted my desperate request for help on the TMB forum. Guess what, I got an answer less than a few hours after - thank you Mollie Brooks!
The R code is available on my GitHub here. Minimizing the deviance coded with TMB was… wait for it… > 300 times faster than using the deviance coded in standard R.
Hope this is useful.