AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

Add gazebo airsim plugin files

Open Jaeyoung-Lim opened this issue 4 years ago • 12 comments

Fixes: #

Related to: https://github.com/microsoft/AirSim/issues/2955

About

While the Gazebo environment is the most widely used environments for simulation, the rendering quality of gazebo makes it hard to test vision based applications. While Microsoft/Airsim solves this problem by using advanced game engines such as the Unreal Engine or Unity the physics Airsim can simulate are limited.

  • Only multirotors are available, and none of the vehicles have gimbals
  • Aerodynamic effects such as Fixedwing/VTOL vehicles are not available for PX4 SITL-Airsim

This PR provides a solution mid-way so that the capabilities not available in Unreal Airsim can be used with Gazebo. A gazebo_airsim_plugin is implemented as a link between gazebo and Airsim. The plugin can be attached to a specific link that orients the camera in Airsim. The specific link can be defined in the sdf flile as the following.

    <plugin name='airsim_plugin' filename='libgazebo_airsim_plugin.so'>
      <robotNamespace/>
      <link_name>typhoon_h480::cgo3_camera_link</link_name>
    </plugin>

This plugin assumes that Airsim is running in "Computer Vision Mode". The configuration file of Airsim is as the following.

{
  "SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md",
  "SettingsVersion": 1.2,
  "SimMode": "ComputerVision"
}

How Has This Been Tested?

This has been integrated into the PX4 Autopilot project, and tested using the following command. (Needs inclusion of https://github.com/PX4/PX4-SITL_gazebo/pull/791)

make px4_sitl gazebo_typhoon_h480_airsim

Screenshots (if appropriate):

GazeboAirsim

GazeboAirsim

Jaeyoung-Lim avatar Aug 23 '21 15:08 Jaeyoung-Lim

CLA assistant check
All CLA requirements met.

@jonyMarino I tried using clang-format-10 to format my code, but the settings doesn't seem to agree with what is being checked in CI.

Is there a good way to format the code that is appropriate for this repo?

Jaeyoung-Lim avatar Aug 23 '21 17:08 Jaeyoung-Lim

  1. check out your pull request

  2. run git checkout master .clang-format in your repo's root folder

  3. if you don't have npm installed, download it from https://www.npmjs.com/get-npm

  4. run npm install -g clang-format

  5. run clang-format -i path/to/file for each failing file (failing files can be found in the details for the clang-format check)

  6. run git add -u to track all style changes

  7. run git commit -am "apply style from clang-format"

  8. run git merge master

  9. resolve other non-style conflicts if you have any

  10. push changes

I hope it helps you!

jonyMarino avatar Aug 23 '21 19:08 jonyMarino

@jonyMarino Thanks for the pointers! I have addressed the style check failures

Jaeyoung-Lim avatar Aug 23 '21 20:08 Jaeyoung-Lim

@jonyMarino I have addressed the changes! Would there be anything more that needs to be addressed?

Jaeyoung-Lim avatar Aug 25 '21 20:08 Jaeyoung-Lim

Thanks, @Jaeyoung-Lim! An update on this page on how to use the plugin would be ideal...

jonyMarino avatar Aug 25 '21 21:08 jonyMarino

Thanks, Rajat for the review!

jonyMarino avatar Aug 26 '21 16:08 jonyMarino

Hey @Jaeyoung-Lim, I'm trying to test this PR with the command you mentioned:

make px4_sitl gazebo_typhoon_h480_airsim

However, I'm getting the following build errors:

ninja: error: unknown target 'gazebo_typhoon_h480_airsim'
make: *** [Makefile:230: px4_sitl] Error 1

I have your other PR https://github.com/PX4/PX4-SITL_gazebo/pull/791 checked out inside Tools/sitl_gazebo in my local PX4-Autopilot repo. Do I have to do something else to pick up the new target you added?

zimmy87 avatar Nov 03 '21 18:11 zimmy87

@zimmy87 You would also need https://github.com/PX4/PX4-Autopilot/pull/18566 which adds the make target

Jaeyoung-Lim avatar Nov 03 '21 19:11 Jaeyoung-Lim

@Jaeyoung-Lim Thanks for continuing to work on this. Can we specifically use Multirotor instead of CV and call simSetKinematics instead of simSetVehiclePose? That way we can get the sensors from AirSim and it may be that it improves the behavior of the camera as well.

jonyMarino avatar Nov 08 '21 20:11 jonyMarino

@jonyMarino Could you elaborate on where the sensor data from the airsim is being used? This is not being used from the simulation or the SITL autopilot instance

Jaeyoung-Lim avatar Nov 08 '21 20:11 Jaeyoung-Lim

@Jaeyoung-Lim It is convenient for the AirSim user who wants to know for the photos taken what the kinematics state was at that time. This way, you could get everything from the AirSim API in a synchronized way without communicating with Gazebo. It has no impact on the flight controller or the physics of the vehicle. At the same time, Frederic from Auterion (I don't know his user name, you can ping him) reported that the camera has a better behavior using the multirotor mode with the External Physics Engine if the kinematics state is updated through simSetKinematics().

jonyMarino avatar Nov 09 '21 17:11 jonyMarino