Using Gazebo_motor_failure_plugin in gazebo simulation

Hi all,

I want to simulate motor failure in gazebo on a quadcopter

I understand that a plugin is already made for this but I have no idea how to use it. I have built it by modifying the CMakeFile but how would I actually go about using it?

You can interface it through the gazebo topics by sending the motor number

I wasnt too sure on how to publish to a gazebo topic, but I thought the plugin existed so I could publish to the ros topic and that would publish to gazebo. However I dont see the corresponding ros topic so I was not sure how to publish to that.

If you are using ROS, you can interact with ROS topics: https://github.com/PX4/sitl_gazebo/blob/f9bc7e34a754b6f204a8b3825c2b132587574cba/src/gazebo_motor_failure_plugin.cpp#L74

The issue I am facing is that I dont see the ROS topic for motor failure, so I am not sure if the plugin is even running. I know it built but do I need to check an option or modify the launch files to enable it?

Thanks a lot for your help btw I reallt appreciate it

@steelshot Ah, of course you need to add the plugin to the model

Ahh I see. Do you have any pointers on how to do that? I am kind of new to gazebo.

Have you solved this problem by any chance?
My goal is to break it down. To be more specific, my goal is to move the drone to the desired setpoint and stop one motor in real time or control the speed.
But I thought it was impossible to control the px4 code because I’m a ros beginner.

I was looking for a way, and if I look at iris.sdf
/gazebo/command/motor_speed

/motor_speed/0
There’s a code called that.
So I thought there was something about exchanging these topics and when I looked, I found the gazebo_motor_model.cpp, gazebo_motor_model.h file.

However, I have a question that I can modify these files to control iris in gazebo.

What I thought was that you can control the motor by sub or sub here, and you can use this to control the motor in real time.

I’m wondering if this is right, and if it is, I’d like to know how to do it in detail…