ArduPilot / ardupilot_gazebo

Plugins and models for vehicle simulation in Gazebo Sim with ArduPilot SITL controllers
GNU Lesser General Public License v3.0
82 stars 78 forks source link

Add gazebo catapult plugin #51

Open 41Mo opened 1 year ago

41Mo commented 1 year ago

Add support for a catapult via the catapult plugin.

This plugin will be useful for testing takeoff modes and will simplify usage of zephyr model e.g. #39

Details:

The catapult plugin implemented using a detachable joint system.

The plugin should be added directly to one of the models, either the Launchpad/catapult or the vehicle.

For example, in the case of the Zephyr Delta Wing model:


<plugin filename="libCatapultPlugin.so" name="CatapultPlugin">
  <direction>0.7 0 0.3</direction>
  <force_magnitude>100.0</force_magnitude>
  <launch_duration>0.5</launch_duration>
  <vehicle_link>zephyr::wing</vehicle_link>
  <catapult_link>launchpad::base_link</catapult_link>
</plugin>

In this example, the plugin is added to the zephyr_catapult.sdf, which includes zephyr.sdf. Therefore, we should use the fully qualified name zephyr::wing inside the vehicle_link parameter. The catapult_link parameter should be done similarly.

The direction parameter is a three-component vector that describes the direction of the force applied by the catapult.

The final force applied by the catapult is calculated as force_magnitude * direction, and it is applied to the vehicle during the launch_duration.

Testing

Gazebo

gz sim -r -v4 zephyr_catapult.sdf

SITL

./Tools/autotest/sim_vehicle.py -v ArduPlane -f gazebo-zephyr --model JSON --map --console

Se takeoff mode and arm

mode takeoff
arm throttle

Gazebo

publish message to topic

gz topic -t "/model/zephyr_with_catapult/catapult/cmd_release" -m gz.msgs.Empty -p "unused: true"

Launching with ardupilot plugin enabled:

https://user-images.githubusercontent.com/40123891/229605911-8e0b454a-e0ce-4a06-94ec-a63c70d76ddf.mp4

Launching without ardupilot plugin enabled.

https://user-images.githubusercontent.com/40123891/229606264-342d4aba-6176-4176-af35-35a43eee1fbd.mp4

Current ISSUES/TODOS

  1. Allow user to launch vehicle using gui plugin or servo command. I don't know which is better solution.
  2. Document code.
  3. Add implemetnation for Reset() method.
  4. Add nice model to catapult.
  5. Find way how to simulate bungee.
srmainwaring commented 1 year ago

@41Mo, could you please rebase your PR on main. Apologies for the delay in the review.

41Mo commented 1 year ago

@srmainwaring yeah, ofcourse. This PR is still in draft state, I made some modifications locally to calculate force using desired acceleration. But it's incomplete.

srmainwaring commented 1 year ago

This PR is still in draft state

Ok - I'll mark as draft and wait for your request before reviewing.

My rebased branch is here: https://github.com/srmainwaring/ardupilot_gazebo-1/tree/review/pr-catapult-plugin. It's the CMakeLists.txt that is conflicted.