GSoC’25 Gazebo Plugin Model of a Motor

1. Introduction
Hi ArduPilot community :waving_hand:.
My name is Bhajneet Singh Bedi, a robotics software engineer from India. I am thrilled to announce that this year my proposal “Gazebo Plug-in Model of a Motor” has been accepted for GSOC 2025.
First of all I would like to thank my mentors @NDev @rhys for giving me the opportunity to contribute this year. I am feeling very excited to go through this journey of developing something which would help the community, which I always wanted to do.

2. The Project
The main objective of this project is to make a plugin based electro-mechanical model of a motor in gazebo. The idea is to create a model such that it mimics a real life motor. The plugin would help identify the stats of the motor at runtime. This also provides a standardised way to test motor behaviour under various conditions before real-world deployment of the project.

3. Why is this important?

  • It bridges the gap between hardware testing and simulation.
  • Makes motor outputs more realistic under varying load.
  • Will allow researchers and developers to simulate motor performance under different conditions.

4. Overview
In the current implementation, PWM signals are mapped directly to joint control commands using one of three modes: velocity, position, or effort. A PID controller is applied to reduce the error between the commanded and actual values, and the resulting force is applied to the joint.

While this approach is straightforward and works well for high-level control and simple simulations, it abstracts away the physical characteristics of real motors — such as torque generation based on current, voltage dynamics, and rotor inertia. As a result, this model does not capture the subtleties of how motors respond to load changes, battery sag, or transient behaviours, which are critical in dynamic flight scenarios.

To address these limitations, the project proposes a physics-based motor model plugin that simulates motor response by incorporating electrical and mechanical dynamics directly in the simulation loop.

The electro-mechanical model is described as below:


Fig: Circuit of an Electric Motor


Fig: Nomenclature

The motor model I implemented is based on the theory described in “Motor and Propeller Models for Flight Dynamics Simulations” by Mark Drela (MIT). This model captures the electrical and mechanical behavior of brushless DC motors in a physically realistic way — making it ideal for improving the fidelity of drone simulations in Gazebo.

:high_voltage: 4.1 Electrical Model

The motor is treated as an electrical system, where the input is voltage VVV (derived from PWM and battery) and the output is torque.

The relationship is:
image

Where:

  • I = motor current [A]
  • V = applied voltage [V]
  • Ω = angular velocity [rad/s]
  • Kv = motor velocity constant [rpm/v]
  • R = internal resistance of the motor [Ω]

This reflects back-EMF: at higher speeds, the motor resists current flow due to the voltage generated by rotation.

:cyclone: 4.2. Torque Generation

The torque generated is proportional to the current:
torque_eqn

The torque constant can be simply assumed to be the same as KV .

image

So the torque depends on:

  • Motor Kv rating
  • Current flowing through the motor

This torque is then applied to the propeller via the joint.

5. Implementation outline

  • ArduPilot SITL transmits FDM (Flight Dynamics Model) data over the local network(127.0.0.1) on port 9002.
  • The FDM also consists of pwm signals (16 or 32 channel) based on the configuration.
  • If the control type is set to “COMMAND” and a topic is provided in cmd_topic then the ArduPilotPlugin publishes the pwm values on the given topic.

This is what the MotorPlugin will subscribe to and calculate the output force which will be then be given in respective joints in gazebo using JointForceCmd

6. Call for Collaborations

As this project evolves, I’d love the involvement of the ArduPilot community in shaping and testing the motor model. Your feedback, ideas, and even small contributions can make a big difference in refining its accuracy and usability.

If you’re interested in:

  • Testing the plugin with your own motor/propeller configurations.
  • Comparing simulated vs real flight data.
  • Suggesting improvements to the model.
  • Helping integrate the plugin more tightly with ArduPilot SITL.

— I’d be happy to collaborate!

More Updates will be coming - Don’t miss out

GitHub links:

GitHub - Bhajneet-Singh-Bedi/ardupilot_gazebo at template_plugin

7 Likes

For GSoC’25 Gazebo plugin, create a motor model with the plugin that controls motor speed and torque simulates physics research realistically, and integrates with ROS for commands and feedback.