-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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 Wind simulation #2867
Add Wind simulation #2867
Conversation
8793f35
to
d1b4c6d
Compare
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 have implemented payload dynamics (single point of attachment to a cable) in AirSim and implemented it very similarly to how you have done. Can't speak to the exact physics of the wind, but it looks good.
@nicocarb Thanks for the review! Payload attachment certainly seems interesting, would be nice to see the implementation if you're able to |
@rajat2004 I apologize for the late response. I could perhaps explain my payload implementation. Not sure if I can show you my full code, however. I essentially created a payload object that has a volume, drag faces, a mass, and a cable length. Then, I take information about the current angle of the payload, current rate of change of angle of the payload, and drag force on the payload and use a small angle approximation to solve for the payload position in time in the World Frame relative to the drone's attachment point. Then, I apply a force vector equivalent to the tension force created by the payload in the direction of the payload position. Small angle approximations were appropriate for my use case; however, if small angle approximations are not valid, perhaps exploring a Euler approximation using payload acceleration and velocity may be successful. I was not able to get this to act appropriately. Most of the actual calculations occur in getNextKinematicsNoCollision(), which I've overriden. Perhaps we can discuss showing you an implementation of this from my side (I am just not sure as of right now whether I can). In terms of the wind, I imagine it must be too high. For a drone to fly against wind, attempting to hold its positions, its thrust vectors must attempt to counteract the wind force. The video you've attached seems to suggest this is what the controller is attempting to do. I may be incorrect, however. |
@nicocarb No problem at all, I was just interested in getting an overview on the implementation. Thanks for the explanation, looks pretty complex, great that you got it working. |
I think the physics implementation could be improved. Right now drag and wind are dealt with separately in The correct way to calculate the effect of wind would be to feed it into getDragWrench and subtract/add it (depending on convention) from the vehicle linear velocity |
@samuelctabor Thanks for the review! Yes, I think you're correct, using the relative velocity does make more sense. Here's a video with SimpleFlight - https://drive.google.com/file/d/1ydMt8BFMTWRvJiTEuEByY6bfJmfswR4Z/view?usp=sharing |
@rajat2004 the previous implementation was incorrect :-) 25m/s is a lot - over 55mph - your new values are more realistic. Note that |
Use velocity wrt wind to calculate drag forces
Yup, the new behaviour did make more sense, but wanted to confirm. The |
hey @rajat2004 , I tried to test out your implementation. I keep getting this when I run simSetWind(): msgpackrpc.error.RPCError: rpclib: function 'simSetWind' (called with 1 arg(s)) threw an exception. The exception is not derived from std::exception. No further information available. I could not trace it back. Could you guess my mistake? |
Quite strange, haven't seen that before. |
Okay my bad :) It was a silly mistake. Seems like I need some coffee :DD |
Ok, great that it got fixed. Still, curious to know what caused the problem :) |
I have given a tuple as the argument of airsim.Vector3r function. So instead of passing windX,windY,windZ I have passed (windX,windY,windZ) |
BTW, wind physics is beautiful but can be adjusted to me more realistic. I can run tests for my drone now. Thanks for your contribution. |
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 tested it on the following environment:
- Unreal Engine 4.24
- PX4 1.9.2 SITL
- AirSim 1.2.0 (+ some updates from 1.3.1 and a few fixes + my own customizations)
Couldn't face any problems. Wind implementation is great and fine for me now. Good job @rajat2004
Great, thanks for the testing! |
@rajat2004 The wind implementation is great! Is it possible to create location-based injection of wind, i.e., at different locations, different winds are injected? |
An interesting idea, there currently isn't any such location-based separation of effects anywhere in the code AFAIK, a possible way could be to store multiple wind profiles for areas based on the coordinates, and then lookup the specfic area every time. Any another ideas which might work? |
I was thinking to add another function in the physics engine, which takes the wind velocity and the corresponding location information as the input argument. If the drone's location is close to the input location, the wind velocity takes an effect. otherwise a default wind velocity is used. The wind profiling can be at the client side which looks up the wind velocity based on the vehicle's position. This way i think we can affect multiple drones with different wind velocities. I would like to give a try anyway. but i am very new to AirSim and a novice C++ programmer. Any advice would be appreciated. |
Sure, that's another way, it all depends on the goal and the kind of effect to be achieved. You'll have to set some threshold to decide the barrier around the location as well. |
I have doubts with the wind implementation. Considering the example provided at: As far as I understood, when you apply 10m/s in forward direction, if we do nothing at code (e.g., time.sleep(10)), we should expect the drone to move forward during 10 seconds. I am confused, because instead of seeing such behavior, the drone does not move. In fact, the drone does not move when you modify either the X or Y dimensions with values between 0 and 20 m/s. For example, for 15m/s in X axis: Am I missing something? Does the drone have a way to stay stable on its own without coding it? |
I use Unity Airsim. |
Adds force calculation due to Wind. Based on #284
TODO:
Settings:
API:
Video: https://drive.google.com/file/d/1Cl1QOY_pD4SQd-EtuUNMMmxYDGDHZagI/view?usp=sharing
Script video - https://drive.google.com/file/d/1Gx4zCSnifbVN3I-32583dM6GTiQP0ZLT/view?usp=sharing
Would be great if others can test it out as well. Review of the physics implementation would be very much appreciated, haven't dabbled in this part of the codebase earlier
Related issues: #284, #2081, #2728, #2342