yuchnw / quadSimulator

Iris quadcopter path planning simulation in Gazebo
25 stars 5 forks source link

Automatic enabling of Failsafe mode #2

Closed Ayush1285 closed 3 years ago

Ayush1285 commented 3 years ago

after running setmode.py node, I am getting this error

INFO [commander] Armed by external command WARN [navigator] Using minimum takeoff altitude: 2.50 m INFO [commander] Takeoff detected WARN [commander] Failsafe enabled: no datalink INFO [commander] Failsafe mode activated INFO [navigator] RTL HOME activated INFO [navigator] RTL: landing at home position. INFO [tone_alarm] battery warning (fast) INFO [navigator] RTL: climb to 488 m (1 m above destination) INFO [commander] Failsafe mode deactivated INFO [navigator] RTL: return at 488 m (1 m above destination) INFO [navigator] RTL: land at destination INFO [commander] Landing detected INFO [commander] Disarmed by landing INFO [logger] closed logfile, bytes written: 3774768

Ayush1285 commented 2 years ago

I solved the issue by changing the settings of RC loss exceptions for offboard mode.

In setMode.py, replace the code of setoffBoard() function with this:

    rospy.wait_for_service('/mavros/set_mode')
    rospy.wait_for_service('mavros/set_param')
    rcl_except = ParamValue(1<<2, 0.0)
    try:
        landService = rospy.ServiceProxy('/mavros/set_mode', mavros_msgs.srv.SetMode)
        setparam = rospy.ServiceProxy('mavros/set_param', mavros_msgs.srv.ParamSet)
        landService(custom_mode = "OFFBOARD")
        setparam(param_id = "COM_RCL_EXCEPT", value = rcl_except)
    except rospy.ServiceException as e:
        print("service switch to offboard call failed: %s. The vehicle cannot land "%e)