How to command PX4 to reboot via MAVROS?

Hi, I’m making SITL environment for PX4 using Gazebo simulator.
After some crashes, I coded the SITL program to let Gazebo sim reset the pose of the IRIS model, but it moved wired. I thought I should reboot PX4 firmware, but I don’t know how to do that…not manually. How can I send a reboot message to PX4 firmware?

Hi ! I need to implement the same, any improvement on this?
Thank you,

Paolo.

I’ve had trouble resetting simulations as well, the reason being that EKF2’s position estimate would need to be reset. I don’t think there’s a MAVLink command recognized by PX4 to do so.

What’s wrong with restarting PX4? That’s what I ended up doing

I’ve been doing some test with the pixhawk 1 - offboard mode
seems like the only way to reset the ekf2 estimator is the hardware way -> pushing the little button nearby the usb port

since there is a way to reset using QGC maybe we can send same mavlink via mavros

1 Like

Any solution to this problem , how to reset the SITL programmatically?

You can reset some modules by writing a mavlink message handler and stop - start the module in that handler by calling those functions.

You can use mavcmd or call the mavros service /mavros/cmd/command

rosrun mavros mavcmd long 246 1 0 0 0 0 0 0

or simply write a ROS node calling the service /mavros/cmd/command

from mavros_msgs.srv import CommandLong
mavcmd = rospy.ServiceProxy('/mavros/cmd/command', CommandLong)
mavcmd(command=246,param1=1)

I refer to mavlink doc for this method. http://mavlink.io/en/messages/common.html#MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN