3drobotics / solodevguide

Solo Development Guide (SDG).
http://dev.3dr.com/
40 stars 62 forks source link

Gopro functions for Dronekit Python? #284

Open nicOwlas opened 8 years ago

nicOwlas commented 8 years ago

Hi,

I am not sure it is the right place to raise the question but I did not find any better:

I would like to control my Gopro onboard the solo via some dronekit Python functions and I am therefore looking for the functions to do this. This would allow me to trigger the camera at specific GPS positions etc.

I have found this blog from Daniel McKinnon: http://www.ddmckinnon.com/2015/12/30/idiots-guide-to-dronekit-python-a-journey-to-whoz-chillin/ which gives mavlink messages syntax to change Gopro mode, take picture and control the Gimbal.

Suggested function to take a picture: def goproTakePic(self): MAVLINK_GIMBAL_SYSTEM_ID=1 MAVLINK_GIMBAL_COMPONENT_ID=154
msg = self.message_factory.gopro_set_request_encode( MAVLINK_GIMBAL_SYSTEM_ID, MAVLINK_GIMBAL_COMPONENT_ID, mavutil.mavlink.GOPRO_COMMAND_SHUTTER, (1, 0, 0, 0)) self.send_mavlink(msg) self.flush()

The suggested Gimbal control works (sad though that the default dronekit gimbal functions do not work with solo). The Gopro functions doesn't seem to work for me (cygwin, ubuntu, solo-cli 1.1.2). Is there any more documentation somewhere on how to control the Gopro?

Digging into solo code, I found in ./usr/bin/ shotManager.py and GoProManager.py which seems to show that it is feasible but any way to access those functions from dronekit?

Thanks! :-)

hamishwillee commented 8 years ago

II have no idea. I would perhaps try using MAVProxy as it appears to support a gopro module (https://github.com/Dronecode/MAVProxy/blob/master/MAVProxy/modules/mavproxy_gopro.py). If it works, then you can engineer what commands work and what do not.

hamishwillee commented 8 years ago

Looking around at the code, the trick is probably to send messages using the correct cmponent ID. mavutil.mavlink.MAV_COMP_ID_GIMBAL.

E.g. to send a request ...


        msg = self.message_factory.gopro_get_request_encode(
                                    0, mavutil.mavlink.MAV_COMP_ID_GIMBAL,    # target system, target component
                                    command
                                    )
        self.send_mavlink(msg)

Sending a command is the same, but you have to also pass a value.

YOu can look at the response to a get message with something like this.


@vehicle.on_message('GOPRO_GET_RESPONSE')
def listener(self, name, message):
            """

            """
            print "GOPRO GET RESPONSE: %s" % message

YOu can look at the set command response and the heartbeat with watchers like this.


@vehicle.on_message('GOPRO_HEARTBEAT')
def listener(self, name, message):
            """
            """
            #print "GOPRO message: %s" % message

@vehicle.on_message('GOPRO_SET_RESPONSE')
def listener(self, name, message):
            """

            """
            print "GOPRO SET RESPONSE: %s" % message   

Hope that helps.

hamishwillee commented 8 years ago

Enough to get started?

nicOwlas commented 8 years ago

Hi @hamishwillee!

Yes thanks a lot, just got into office. I'll have a look today itself and let you know!

Cheers, nicOwlas

nicOwlas commented 8 years ago

Hi @hamishwillee ,

Short status: nothing worked and after digging everything up, it seems that the problem comes from my gimbal (I cannot even control the gopro from the official app). 3DR aftersales said that it was damaged, so I returned the gimbal and I will wait for the new one to give it another try. Hope next week.

I'll let you know,

Cheers

hamishwillee commented 8 years ago

Thanks for letting me know @nicOwlas. Sorry to hear about the gimbal!

imutkarshpatil commented 7 years ago

Hey @nicOwlas ,

Were you able to access GoPro after the setting new gimbal?

nicOwlas commented 7 years ago

Hi @imutkarshpatil,

Ahah, I was not expecting a message on this issue after 18 months ! To be fully honest no, but we did not investigate for too long, we switched to DJI.