-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add physics-based simulation #160
Conversation
This change got bigger than I hoped, mostly because some refactoring was needed and I also included another useful visualization tool. Let me know if you want me to try to break this is smaller PRs for easier review. I verified that the 3 firmware controllers work on simple trajectories as well as the previous mode that uses no physics-based simulation. Note that the control performance of PID and Brescianini aren't great. Future changes in both crazyflie-firmware and here are needed to allow the user to tune gains. |
Hi! Sorry for the delay. But great! I will try to find some time this week to look at it but it might be next week if that is okay? |
Sure, no rush! |
Hi! Before I give a thorough review, I noticed that there might be something off with the np simulation when I tried some parameters, what you can perhaps confirm if this is supposed to happen or not:
Perhaps there is something off with the simulation time perhaps? |
? I think if the simulator itself is called with I notice that this change is very big and perhaps it's too early to update the documentation, since more (firmware) changes are needed to properly support the multi UAV cases. Would it help if I split up the PR in smaller logical chunks (and hold off on the doc changes)? |
Ah yes, if I put use_sim_time to true it indeed does it correctly. I didn't see the arg before. I don't think smaller PRs are necessary. In concept this is already quite a big change and smaller chunks of PRs will not make it much more simpler probably. We just need a bit more time to review :) But perhaps we can leave the doc changes for now indeed. |
I reverted some of the doc changes that were about the physics backend specifically. I think this PR is difficult to review since it mixes refactoring and new features. Perhaps reviewing by commit is easier than looking at the whole thing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I mostly have very minor request, mostly comments. In general I agree with the current framework as it is. I mostly also wanted to go through it in detail so I'll understand how to implement the webots simulator :)
For the rest, let's indeed make separate issues for the max_dt not working for physics based simulation, and for making the bindings more separate so that multiple drones can be flown.
|
||
# convert RPM -> Force | ||
def rpm_to_force(rpm): | ||
# polyfit using Tobias' data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some context here perhaps as not everybody knows who Tobias is :) Wondering where a good place would be to place these csv files you plotfitted these from...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have them in https://github.com/IMRCLab/crazyflie-system-id (a private repo). I am happy to make it public and refer to it, if the data itself is fine to share publicly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why not actually! I'll ask tobias just to be sure but since the plots are already out. Perhaps you can already go ahead and refer to it in the text and make the repo public once I received the okay.
Just a bit of a comment as I am a bit OCDs for symmetry tough, as now we have:
While perhaps it might be nicer to do
This should not be part of this PR but something I noticed and perhaps we can keep in mind for the future. |
Also currently, we will be limiting ourselves to only simulations that have an python API. That is in general not a problem, since Webots and the pybullet based sim, but Gazebo will be out probably for the time being. I'm okay with that as long as you are okay with the limitation as well, and I'm sure that when the time comes we can perhaps see if we can make a wrapper for that. |
I pushed some of the minor changes and left comments for the bigger ones. Structure: The current one is even a bit more chaotic: Sim Limitations: Yes, although this was already in the design. One could rewrite the whole simulator in a different language (and then use the C-firmware directly, rather than the Python bindings). I think Gazebo is still possible. If I remember correctly, most functions are done by writing (C++) plugins. Then we would write a plugin that exposes setting the rotor speeds and querying the robot state from Python (e.g., with zeroMQ). |
Yeah that is true. It is not ideal but let's solve it for now with good documentation and update the overview to add a detailed schematics once the dust settles. We can keep this in mind for any future redesigns! I think it is more important to get to a good working base state first. Gazebo is indeed only c++ plugins which is quite difficult to work with I felt, but I wrote some base of it to do exactly those things you said. We can also have the query communication go completely through ROS and have gazebo separate but I'm not sure if we would have nice control over the simulator steps. Once we come to the point where we want to implement gazebo, I'm sure that there are multiple ways to solve this. btw, it seems that the CI is failing, but couldn't see the exact reason |
CI: some of the ROS2 tests in crazyflie_interfaces are failing (ValueError pep257_rosidl_generated_py). My guess is that somehow the ROS2 version in the docker image the CI uses changed. I couldn't find anything using a google search so far and this is definitely unrelated to this PR. |
btw, congrats on submitting your first contribution @whoenig 😜 Must be a bug haha |
Add physics-based simulation
No description provided.