sallyc

  • *
  • 47
Hello,

My intetion is to do the low level (Attitude mode) stabilization on the CC3D and navigation in Pi with my own algorithms.

I donot have GPS (in door flying), I will be using Attitude mode.

I integrated the Pi and CC3D using serial. I  use UAVObjects to receive and send data from Pi (thanks for the Python API).

I can read whatever I need from UAVobjects, the quadcopter state, Rc commands etc.

But how can I send my commands to CC3D? Shall I override Rc commands?

What is the best way to use telemetry commands (UAVobjects) and Rc together?

CC3D will not stop processing Rc commands. The values from Pi and Rc will interfare. How to solve it?

Is it possible to change input channel configuration from PWM to GCS on the fly (using UAV Setting Objects) and still having the Rc commands in UAVObjects?

Bests,

Sally.


The GCS can take over control of the FC and bypass RC input, you would just need to determine how it does it.

In the flight code I recall this has to do with the inline function ManualControlCommandReadOnly()

I haven't researched it...

Thanks TheOtherCliff. I think UAVObject ManualControlSettings enables us to change from PWM to GCS, even during runtime.

In the same UAVObject specification, there is <access gcs="readwrite" flight="readwrite"/> . How can we configure them to read from Rc and overwrite from telemetry?

In ManualControlCommand specification, the description says:

<object name="ManualControlCommand" singleinstance="true" settings="false" category="Control">
        <description>The output from the @ref ManualControlModule which decodes the receiver inputs. Overriden by GCS for fly-by-wire control.</description>

How can we achieve "Overriden by GCS for fly-by-wire control."?



f5soh

  • *****
  • 4572
    • LibrePilot
You need to take control of ManualControlCommand and AccessoryDesired (if needed), you need to disable the previous RC Input configured and avoid two sides changing the same UAVO.

You can try two solutions:
- temporary set the input type and input channel to None.
- change metadata and set readonly from flight side.

Maybe like in example.py for ActuatorCommand:
Code: [Select]
    def driveServo(self):
        print "Taking control of self.actuatorCmd"
        self.objMan.ActuatorCommand.metadata.access = UAVMetaDataObject.Access.READONLY
        self.objMan.ActuatorCommand.metadata.updated()

        while True:
            self.objMan.ActuatorCommand.Channel.value[0] = 1000
            self.objMan.ActuatorCommand.updated()
            time.sleep(1)

            self.objMan.ActuatorCommand.Channel.value[0] = 2000
            self.objMan.ActuatorCommand.updated()
            time.sleep(1)

Thanks f5soh. That is a great example. I like the idea to make it read only to the flight side (as in the code) and set it from the UAVtalk. How can be get/read the Rc commands at the same time when ManualControlCommand is readonly from flight side? Is it possible? I could not find any other place (then ManualControlCommand) in UAVO that Rc commands are written. Is there any intermidiate buffer?

f5soh

  • *****
  • 4572
    • LibrePilot
Raw input values from receiver are populated into ManualControlCommand > Channels
Next, in ManualControlCommand > Throttle, Pitch, Roll, Yaw the values are translated to -1 > 0 > +1 range according to the settings (min/neutral/max + channel mapping)

If the readonly solution do not work the first one disabling inputs will work, you need to experiment by yourself.

sallyc

  • *
  • 47
You need to take control of ManualControlCommand and AccessoryDesired (if needed), you need to disable the previous RC Input configured and avoid two sides changing the same UAVO.

You can try two solutions:
- temporary set the input type and input channel to None.
- change metadata and set readonly from flight side.

Maybe like in example.py for ActuatorCommand:
Code: [Select]
    def driveServo(self):
        print "Taking control of self.actuatorCmd"
        self.objMan.ActuatorCommand.metadata.access = UAVMetaDataObject.Access.READONLY
        self.objMan.ActuatorCommand.metadata.updated()

        while True:
            self.objMan.ActuatorCommand.Channel.value[0] = 1000
            self.objMan.ActuatorCommand.updated()
            time.sleep(1)

            self.objMan.ActuatorCommand.Channel.value[0] = 2000
            self.objMan.ActuatorCommand.updated()
            time.sleep(1)
Hello, Thanks for your replying. what do you mean - temporary set the input type and input channel to None? If I set the input type and input channel to None then I cannot get data from RC. 

f5soh

  • *****
  • 4572
    • LibrePilot
Quote
If I set the input type and input channel to None then I cannot get data from RC.


And if you keep the Rc active you cannot get control from Pi3.
If you want control from Pi3 and python you cannot take control using Rc at same time.

sallyc

  • *
  • 47
Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #8 on: September 05, 2017, 12:20:01 pm »
Raw input values from receiver are populated into ManualControlCommand > Channels
Next, in ManualControlCommand > Throttle, Pitch, Roll, Yaw the values are translated to -1 > 0 > +1 range according to the settings (min/neutral/max + channel mapping)

If the readonly solution do not work the first one disabling inputs will work, you need to experiment by yourself.
Hello f5soh,
Does that mean the value of Throttle, Pitch, Roll, Yaw are always in the range of -1 to 1? Because when I read the value on pi now, sometimes it is beyond this range.
I think if i want to control cc3d with pi, this 4 value of ManualControlCommand is enough, right?

Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #9 on: September 05, 2017, 12:46:30 pm »
[-1,+1] for ManualControlCommand Roll Pitch Yaw Thrust Throttle

There are other UAVOs where the values are scaled differently though, like in degrees or degrees per second.

In GCS you can go to System page and expand DataObjects then expand ManualControlCommand and watch the values in close to real time.

sallyc

  • *
  • 47
Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #10 on: September 05, 2017, 02:23:41 pm »
[-1,+1] for ManualControlCommand Roll Pitch Yaw Thrust Throttle

There are other UAVOs where the values are scaled differently though, like in degrees or degrees per second.

In GCS you can go to System page and expand DataObjects then expand ManualControlCommand and watch the values in close to real time.
Thank you TheOtherCliff,

And what is the difference between thrust and throttle? Do I have to populate the values for Pitch, Yaw, Roll, Thtrottle and Thrust for ManualControlCommand to control it from pi side? Or do I need to take control of more UAVOs?
« Last Edit: September 05, 2017, 02:27:56 pm by sallyc »

Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #11 on: September 05, 2017, 04:35:53 pm »
Thrust and Throttle are the same value for multicopters and Collective is unused.

I recall that collective pitch helis have Thrust and Collective with the same value.  For CP, the calculation model assumes that the Throttle channel sets the motor RPM and from then on a motor/engine governor maintains that RPM with the varying load.

So you need to populate the Thrust field / member because that is the field the code always uses.  The later code ignores the Throttle and Collective fields.

sallyc

  • *
  • 47
Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #12 on: September 09, 2017, 03:21:27 pm »
Thrust and Throttle are the same value for multicopters and Collective is unused.

I recall that collective pitch helis have Thrust and Collective with the same value.  For CP, the calculation model assumes that the Throttle channel sets the motor RPM and from then on a motor/engine governor maintains that RPM with the varying load.

So you need to populate the Thrust field / member because that is the field the code always uses.  The later code ignores the Throttle and Collective fields.
Thank you very much, TheOtherCliff,
Now I can control it, to make sure, so the range of thrust is -1 to 1 too, right? The same as Throttle

Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #13 on: September 09, 2017, 07:14:06 pm »
The range is [-1,1], but everything from [-1,0] is throttle off, maps to -1.

Beware of exactly zero, I recall that it is throttle off, but maps to 0 where negative values all map to -1.  This may no longer be true.

Re: Low level (Attitude mode) stabilization on the CC3D and navigation in Pi
« Reply #14 on: December 06, 2017, 07:15:59 pm »
Dear all,

We are trying to do the exact same thing.
We also use the example.py and with this example we are able to read the attitude state, and to control the servo directly.
Based on the example to control the servo, we try to populate the ManualControlCommand with Roll, Pitch, Yaw, Throttle.

Code: [Select]
        self.objMan.ManualControlCommand.metadata.access = UAVMetaDataObject.Access.READONLY
        self.objMan.ManualControlCommand.metadata.updated()

        while True:
            print "."
            self.objMan.ManualControlCommand.Throttle.value = 0.9
            self.objMan.ManualControlCommand.Roll.value = 0.9
            self.objMan.ManualControlCommand.Pitch.value = 0.9
            self.objMan.ManualControlCommand.Yaw.value = 0.9
            self.objMan.ManualControlCommand.Thrust.value = 0.9
            self.objMan.ManualControlCommand.updated()
            time.sleep(1)

            self.objMan.ManualControlCommand.Throttle.value = 0.1
            self.objMan.ManualControlCommand.Roll.value = 0.1
            self.objMan.ManualControlCommand.Pitch.value = 0.1
            self.objMan.ManualControlCommand.Yaw.value = 0.1
            self.objMan.ManualControlCommand.Thrust.value = 0.1
            self.objMan.ManualControlCommand.updated()
            time.sleep(1)

But I don't see anything happen on the drone.
I read in this forum that it is possible to set the input type and input channel to None, but I don't understand how to do it. Can someone tell me how to do that.

Kind regards,
Iris