AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

Changing physics aspects of Drones

Open EdwinMeriaux opened this issue 5 years ago • 18 comments

Hello,

So I was trying to modify the physics of the basic drone to replicate a scenario with a stronger engine and a heavier frame.

So if I understand correctly it is just this file to modify right: https://github.com/Microsoft/AirSim/blob/v1.1.10/AirLib/include/vehicles/multirotor/configs/SimpleFlightQuadX.hpp for the physical aspects (drone dimmensions)

and this one for the actual thrust of the drone: https://github.com/microsoft/AirSim/blob/v1.1.10/AirLib/include/vehicles/multirotor/RotorParams.hpp

So for the weight can it really only be between .8kg and 1.6kg?

EdwinMeriaux avatar Jan 14 '21 20:01 EdwinMeriaux

Hi @EdwinMeriaux, On quickly scanning through both files it seems that you're right. However, I recommend giving this a try with the latest version of AirSim (1.4.0 as of a couple of days ago) since the structure has changed since version 1.1.10.

ahmed-elsaharti avatar Jan 15 '21 16:01 ahmed-elsaharti

Awesome thank you!

Out of pure curiosity is would you know if any work is being done to modify the physics engine to allow heavier drones? Or even allow the ability to switch out the fast physics engine to something that can support heavier drones?

EdwinMeriaux avatar Jan 20 '21 18:01 EdwinMeriaux

Glad to be of help ^_^

Also, this would be a question better suited for @jonyMarino and the team. But based on #3284 it seems like there could be something in the works related to the physics engine

ahmed-elsaharti avatar Jan 20 '21 18:01 ahmed-elsaharti

Ok Great!

Just one more clarification. When I modify those files is there anything to be done? Say I change the weight of the drone from 1kg to 1.2kg do I need to rebuild the airsim file? what is there to do other than change the value of the drone?

EdwinMeriaux avatar Jan 21 '21 15:01 EdwinMeriaux

@EdwinMeriaux Correct. You would have to rebuild AirSim. If you're working on the blocks environment, you would have to rebuild AirSim and run the update_from_git script. If you're working on a custom environment, you would need to rebuild AirSim and copy the new Plugins folder over (if I remember the steps correctly 😂)

ahmed-elsaharti avatar Jan 21 '21 17:01 ahmed-elsaharti

@ahmed-elsaharti what update_from_git script?

EdwinMeriaux avatar Jan 21 '21 18:01 EdwinMeriaux

The one in "AirSim\Unreal\Environments\Blocks"

Ok so just to make sure the steps to change drone mass or rotor strength are:

  1. make the modification to the file
  2. rebuild airsim
  3. update_from_git

Is this accurate?

EdwinMeriaux avatar Jan 21 '21 18:01 EdwinMeriaux

This is the update_from_git script: image its the same one from the blocks environment docs. And yup, this is assuming that you're modifying the MAIN files in the airsim directory/solution (Airsim.sln) and not the Blocks solution.

If you're modifying the files in the Blocks project, you would need to:

  1. make the modification to the file in the blocks solution (Blocks.sln file)
  2. run update_to_git
  3. rebuild airsim
  4. run update_from_git
  5. open the Blocks.sln and run the simulation

ahmed-elsaharti avatar Jan 21 '21 19:01 ahmed-elsaharti

ok when you say rebuild just to confirm is that the ./build.sh command from airsim install process or the build button in the blocks environment?

EdwinMeriaux avatar Jan 21 '21 19:01 EdwinMeriaux

If youre on linux, yes rebuilding would be through build.sh.

ahmed-elsaharti avatar Jan 21 '21 19:01 ahmed-elsaharti

The file that should be moddifed I am slightly confused now. Say the blocks file for the environment with the drone I would like to change mass is called blocks-4

You said modifying the main files does that mean the: /home/edwinm/AirSim/AirLib/include/vehicles/multirotor/firmwares/simple_flight /home/edwinm/AirSim/Unreal/Plugins/AirSim/Source/AirLib/include/vehicles/multirotor/firmwares/simple_flight /home/edwinm/AirSim/Unreal/Environments/Blocks 4.24 - 4/Plugins/AirSim/Source/AirLib/include/vehicles/multirotor/firmwares/simple_flight

cause everytime I modify one of the first 2 it gets over written with update_to_git and when I modify the 3rd one I don't see a difference in the program When I change the mass it's position curve stays constant I would assume when it works the drone would take longer to accelerate to the designated velocity?

EdwinMeriaux avatar Jan 21 '21 20:01 EdwinMeriaux

What update_to_git does is that it copies the changes under the Blocks environment: /home/edwinm/AirSim/Unreal/Environments/Blocks 4.24 - 4/ to the main directory /home/edwinm/AirSim what update_from_git does it the opposite, it updates the blocks environment from the main directory for example, if i want to make changes to a particular file in AirLib, I could either make those changes directly in /home/edwinm/AirSim/AirLib/, rebuild airsim (ie: the main airsim project) then do update_from_git to update the blocks environments' AirLib (/home/edwinm/AirSim/Unreal/Environments/Blocks 4.24 - 4/Plugins/AirSim/Source/AirLib/) with the new files and run. OR Make the changes under the blocks environment (/home/edwinm/AirSim/Unreal/Environments/Blocks 4.24 - 4/Plugins/AirSim/Source/AirLib/) and directly run the environment. However, from what I've seen sometimes this results in compilation errors so if you want to do it this way, make your changes under the blocks environment (/home/edwinm/AirSim/Unreal/Environments/Blocks 4.24 - 4/Plugins/AirSim/Source/AirLib/) then update_to_git (to copy the files over from the blocks environment to the main project), rebuild airsim (this builds the MAIN airsim project that just got updated with our new files), then run update_from_git to make sure everything is synced and run the blocks project.

Have a look at https://microsoft.github.io/AirSim/dev_workflow/#updating-and-changing-airsim-code

ahmed-elsaharti avatar Jan 21 '21 21:01 ahmed-elsaharti

Ok I'm running into a problem with those steps: ./update_from_git.sh: line 10: ./clean.sh: Permission denied

I used your first method:

  1. modified mass of drone at /home/edwinm/AirSim/Unreal/Environments/Blocks/Plugins/AirSim/Source/AirLib/include/vehicles/multirotor/firmwares/simple_flight to 1.5kg
  2. in ~/Airsim I used ./build.sh
  3. when in ~/AirSim/Unreal/Environments/Blocks 4.24 - 4 I tried to ./update_from_git.sh I then get the error

EdwinMeriaux avatar Jan 22 '21 00:01 EdwinMeriaux

Are any of the files within ~/AirSim/Unreal/Environments/Blocks 4.24 - 4 open? that might be preventing the script from cleaning. I'm not an expert on the topic though so my guess is probably waaaay off 😂

ahmed-elsaharti avatar Jan 22 '21 00:01 ahmed-elsaharti

No such files were open.

I realized there was a file in the same folder as the ./update_from_git.sh called clean.sh I gave the execute privileges to that and the next time I ran ./update_from_git.sh it worked.

I tested the new drone and it appears to work.

EdwinMeriaux avatar Jan 22 '21 02:01 EdwinMeriaux

Thanks for the help!

EdwinMeriaux avatar Jan 22 '21 16:01 EdwinMeriaux

Hi, I wonder whether the control APIs are work correctly after changing the parameters, such as weight or length.

paobuliao avatar Aug 19 '23 12:08 paobuliao

Hi, I wonder whether the control APIs are work correctly after changing the parameters, such as weight or length.

same question? do we need to re-tune pid gains after changing the parameters?

AlexanderZ3 avatar Sep 25 '23 11:09 AlexanderZ3