BlueROV2 arming using MavRos

Currently i’m using the ROV playground by patrick electric to interact with my physical BlueROV2.
I’m having trouble arming the vehicle through code.
In the playground this is done using the user_mav.launch file which calls the script. This contains the following function. arm function source

    def arm(self):
        """ Arm the vehicle and trigger the disarm
        self.arm_service = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool)
        # Disarm is necessary when shutting down

I can print out the respons and receive a correct message: success: True
result: 0

Looking at topic /mavros/state/ => armed=False at this point and indeed rov doesn’t respond to controller inputs.
If i call the service “/mavros/cmd/arming” from rqt, set arming to True I receive the same respons message => the topic “mavros/state” gets set to True => ROV now responds to inputs controller.

Is there a difference between how rospy calls the service and rqt? Ideally I would like to arm the bluerov from the code.

@patrickelectric any ideas on this one?

I’m currently able to arm the BlueROV from code by calling the service mavros/cmd/arming multiple times in a row. I’m not sure this is a robust solution.

To be sure, does it works if you call rosservice call /mavros/cmd/arming True ?

It was a long time ago that I did that, but looking at the documentation, this could should work:

#!/usr/bin/env python

import rospy
from mavros_msgs.srv import CommandBool, CommandBoolRequest, SetMode, SetModeRequest

if __name__ == '__main__':

    arming_client = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool)

    # Arm the vehicle
    arming_request = CommandBoolRequest()
    arming_request.value = True
    arming_response =

    if arming_response.success:
        rospy.loginfo('Vehicle armed successfully')
        rospy.logerr('Failed to arm the vehicle')

rosservice call /mavros/cmd/arming True this works from the 1st time.
Right now I use the following function on start-up. I call the arming service 4 times. This has worked each time for now. If i call the service only once through code it never works. I also tried your code above, but it doesn’t work first time either.

Version of my BlueOS is: Release 1.0.1 · bluerobotics/BlueOS · GitHub

def arm(self):
        """ Arm the vehicle and trigger the disarm
        print("Waiting for arm service")
        self.arm_service = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool)
        print("Arming ROV")
        for _ in range(4):
            print("response: ", self.arm_service(True))

        # Disarm is necessary when shutting down

As I found a workaround by calling the arm function 4 times, i will close this post