Skip to content

Fix rotor_vel control_freq, quat2euler degrees and CasADi names - #151

Closed
malikdurmus wants to merge 1 commit into
learnsyslab:mainfrom
malikdurmus:fix-small-bugs
Closed

malikdurmus wants to merge 1 commit into
learnsyslab:mainfrom
malikdurmus:fix-small-bugs

Conversation

@malikdurmus

@malikdurmus malikdurmus commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

I came across three small bugs while reading through the code. Each fix comes with a regression test that fails before and passes after.

Sim.control_freq raises in rotor_vel mode

control_freq has no rotor_vel branch, so the sim.step(sim.freq // sim.control_freq) pattern from the README and docs raises NotImplementedError. Rotor velocity commands are applied every sim step (controllable already returns all True for rotor_vel, and the control docs list it as every dynamics step), so now it returns sim.freq.

cs_quat2euler(degrees=True) converts the wrong way

The degrees branch multiplied by pi / 180 instead of 180 / pi (This is a silent error!). The test i added compares against scipy's as_euler for extrinsic, intrinsic and symmetric sequences, in both radians and degrees.

Duplicate CasADi function names in rotation.py

cs_ang_vel_deriv2rpy_rates_deriv and cs_rpy_rates_deriv2ang_vel_deriv were both created with the name "cs_ang_vel2rpy_rates". I think this doesn't affect simulation results, but it gives misleading names in printouts and error messages, and generating C code for several of these functions in one CodeGenerator fails with redefinition of 'cs_ang_vel2rpy_rates'. I renamed them after their Python variables.

- Return the sim frequency from Sim.control_freq in rotor_vel mode instead of raising
- Convert radians to degrees in cs_quat2euler(degrees=True) instead of the inverse
- Give the CasADi derivative conversion functions unique names
@amacati

amacati commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Hi, thanks a lot for the contribution! Looks good on a first glance. Can you please split these up into two separate PRs, one for casadi and one for the frequency? Also, out of interest, how did you come across the sim? Are you using it in your projects?

@malikdurmus

Copy link
Copy Markdown
Contributor Author

Hi!, sure, I will split it into two PR's.

I came across it when I was looking for a JAX native simulation where I can train drone policies with DeepRL. My bachelors thesis at LMU extended a recent UED method, and I wanted to try those ideas on drone control, and I saw your repository. I wanted to take a look at it before starting, then I noticed small improvements i can make which led to this PR eventually.

Right now I think of it as a personal learning project, where I can implement concepts hands-on. I’m starting RCI masters at TUM next semester, so I'd be very interested in contributing more or getting involved in the lab’s work if there is an opportunity :)

@amacati

amacati commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Nice to hear :) Yeah there probably is, and you will probably recognize the sim in our courses as well ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants