FAILSAFE mode activating constantly after the vehicle enters the OFFBOARD mode

System Configurations

OS: Ubuntu 18.04
ROS Distro: ROS Melodic
PX4-Autopilot branch commit ID: faca2b17d0b0259ba5083827d858510648cf45a9 on Sept 17, 2021
image

Build Status: Build successful, could see the drone in Gazebo simulation after I run make px4_sitl_default gazebo

Issue

When I launch the launch file mavros_posix_sitl.launch inside PX4-Autopilot/launch it works perfectly fine and I could see the drone as well in the Gazebo simulation.

The status of MAVROS also appears to be “connected” when I echo the data on the ROS topic /mavros/state

But when I run the offboard control example node from the official documentation of PX4, there is a hustle between the FAILSAFE and OFFBOARD modes. Every time the controller goes into OFFBOARD mode the FAILSAFE mode activates and is deactivated constantly. This makes my drone unable to arm and fly.
image

If there’s any more information I need to provide please let me know. Help is appreciated, TIA.