LibrePilot Forum

Users => Applications - Autonomous Flight => Topic started by: NXTNiklas on November 12, 2017, 04:00:39 pm

Title: Python Connectionmanager
Post by: NXTNiklas on November 12, 2017, 04:00:39 pm
Hello everyone,

I'm trying to connect the CC3D to a Raspberry Pi.
I tried the steps explained here: https://forum.librepilot.org/index.php?action=profile;area=showposts;u=4390 (https://forum.librepilot.org/index.php?action=profile;area=showposts;u=4390)

First it worked, but after a while it stopped working... Now I can't get it to connect anymore.
I tried to get the newest firmware, but the GCS download is older than the bitbucket one.
Is there a way to get more control of which UAVObjects are used? Or an easy way to get matching firmwares?

Another question is, whether the CC3D needs to be fully set up (e.g. after upgrade and erase)?

Thanks in advance!

Title: Re: Python Connectionmanager
Post by: TheOtherCliff on November 12, 2017, 06:37:28 pm
All versions must match to communicate well.

When you change a UAVO (XML file or header file produced from XML) you must rebuild everything so that it knows the new checksum of the new UAVO.
Title: Re: Python Connectionmanager
Post by: f5soh on November 13, 2017, 10:41:55 am
Latest Next build is LibrePilot-16.09+r541-g8935906_i686.exe (https://drive.google.com/open?id=0B5d_9OcqQj8Bd2kwWkhZQnZIY3c) and will match the current bitbucket Next
Title: Re: Python Connectionmanager
Post by: TheOtherCliff on November 14, 2017, 03:52:48 am
Another question is, whether the CC3D needs to be fully set up (e.g. after upgrade and erase)?

The exact definition of that is whether any UAVO (xml source file) setting that you have non-default settings in (as set by GCS) got modified by code changes (in the xml file) from one version to the other version.

If you know for sure where all your non-default settings are (in GCS) you can just look at them to make sure they look correct, for instance, if you see non-default PIDs, you know it got them and you don't need to check each PID individually.

If you do this wrong then you will simply get default settings for the changed UAVOs.
Title: Re: Python Connectionmanager
Post by: f5soh on November 14, 2017, 10:12:43 am
Quote
Another question is, whether the CC3D needs to be fully set up (e.g. after upgrade and erase)?

If you do a Upgrade&Erase the CC3D will lost the USB VCP setting.
The python code works only using a serial port (connected to Main/Flexi port) or VCP set as USB telemetry.

https://forum.librepilot.org/index.php?topic=749.msg12347#msg12347
Title: Re: Python Connectionmanager
Post by: NXTNiklas on November 21, 2017, 10:48:29 pm
Thank you very much! Got the System connected now! Now I'm trying to change the ManualControlCommand.Thrust value, but unfortunally it doesn't affect the Motors. My aim is to set the Thrust via USB, is it possible to do so?
Do you have an example for me, if it's possible?
Title: Re: Python Connectionmanager
Post by: f5soh on November 21, 2017, 10:55:08 pm
Look the driveServo function (https://bitbucket.org/librepilot/librepilot/src/8935906fcaf2c09da887d14cd8e8429773326dfb/python/examples/example.py?at=next&fileviewer=file-view-default#example.py-147) inside example.py file.

Board need to be armed first if you want to run motors.
Title: Re: Python Connectionmanager
Post by: NXTNiklas on November 21, 2017, 11:00:56 pm
Yes, I looked into example.py, and the driveServoFunction works. But I would like to set the Throttle/Thrust value, so the Board keeps in stabilisation mode, rather than controlling every single Motor...

Thanks for the fast reply!
Title: Re: Python Connectionmanager
Post by: f5soh on November 21, 2017, 11:10:59 pm
yes, didn't make sense controlling every motor...

Try ManualControlCommand
Title: Re: Python Connectionmanager
Post by: NXTNiklas on November 21, 2017, 11:15:33 pm
I tried:
Code: [Select]
        self.objMan.ManualControlCommand.metadata.access = UAVMetaDataObject.Access.READONLY
        self.objMan.ManualControlCommand.metadata.updated()
        print "Got it!"
        while True:
            self.objMan.ManualControlCommand.Thrust.value = 0
            self.objMan.ManualControlCommand.updated()
            time.sleep(1)
            print "sleep"
            self.objMan.ManualControlCommand.Thrust.value = 1
            self.objMan.ManualControlCommand.updated()
            time.sleep(1)

But it just doesn't power the Motors... (Thrust should be -1 ; 1)
Title: Re: Python Connectionmanager
Post by: f5soh on November 21, 2017, 11:27:26 pm
Is the board Armed ?

Remove propellers !
Title: Re: Python Connectionmanager
Post by: NXTNiklas on November 21, 2017, 11:29:59 pm
if i do:

Code: [Select]
print self.objMan.FlighStatus.Armed.value

it returns 0 which is unarmed... So maybe there is the Problem...
Is it possible to set this value to armed?

EDIT:

Now armed it via Remote Control, it returns 2, but still the motors don't move... But
Code: [Select]
   self.objMan.ManualControlCommand.metadata.access = UAVMetaDataObject.Access.READONLY seems to work, can't control via remote until reboot
Title: Re: Python Connectionmanager
Post by: f5soh on November 21, 2017, 11:38:01 pm
Set how the board is armed in GCS: Config > Input > Arming settings

At Low Throttle (-1), "move" one stick you choose for arming
Apply Throttle.
Board will still Armed or disarm after a timeout if Throttle returns to -1
Title: Re: Python Connectionmanager
Post by: NXTNiklas on November 21, 2017, 11:54:58 pm
Tried to do what you said:

Code: [Select]
def driveServo(self):
        print "Taking control of self.actuatorCmd"
        self.objMan.ActuatorCommand.metadata.access = UAVMetaDataObject.Access.READONLY
        self.objMan.ActuatorCommand.metadata.updated()
        self.objMan.ManualControlCommand.metadata.access = UAVMetaDataObject.Access.READONLY
        self.objMan.ManualControlCommand.metadata.updated()
        print "Got it!"
        print "starting Arming:"
        self.objMan.ManualControlCommand.Throttle.value = -1
        self.objMan.ManualControlCommand.updated()
        self.objMan.ManualControlCommand.Pitch.value = -1
        self.objMan.ManualControlCommand.updated()
        self.objMan.ManualControlCommand.Throttle.value = 1
        self.objMan.ManualControlCommand.updated()

        time.sleep(1)
        while True:
            print self.objMan.FlightStatus.Armed.value
            self.objMan.ManualControlCommand.Throttle = 1
            self.objMan.ManualControlCommand.updated()
            time.sleep(1)
            print "sleep"
            self.objMan.ManualControlCommand.Thrust.value = 1
            self.objMan.ManualControlCommand.updated()
            time.sleep(1)



(Arming Settings: Pitch forward) Arming doesn't work... I don't know why :/

Could it be, that there is a problem with failsafe settings? Because I don't use a Remote Control...
Title: Re: Python Connectionmanager
Post by: NXTNiklas on November 22, 2017, 04:46:50 pm
Okay, I tried something else:
When i remove
Code: [Select]
self.objMan.ManualControlCommand.metadata.access = UAVMetaDataObject.Access.READONLY
the motors start to move a little...

The values get erased immediatly