Get ardupilot output channels










0















How do we get output channel values of an ardupilot from dronekit-python?



We can get input channels from vehicle.channels but I couldn't find anything similar for output channels.



EDIT:



from time import sleep
from dronekit import connect
import dronekit_sitl

sitl = dronekit_sitl.start_default()
connection_string = sitl.connection_string()

vehicle = connect(connection_string,wait_ready=True)

while not vehicle.is_armable:
sleep(1)
print"Initializing"

vehicle.armed = True
while not vehicle.armed:
print "Arming"
sleep(1)
print "Armed"

@vehicle.on_attribute('ch1out')
def ch1out_listener(self, name, msg):
print '%s attribute is: %s' % (name, msg)

for i in range(1000,2000,100):
vehicle.channels.overrides['3']=i
sleep(1)

vehicle.close()


It should print ch1out everytime I update channel 3 but it is not.










share|improve this question




























    0















    How do we get output channel values of an ardupilot from dronekit-python?



    We can get input channels from vehicle.channels but I couldn't find anything similar for output channels.



    EDIT:



    from time import sleep
    from dronekit import connect
    import dronekit_sitl

    sitl = dronekit_sitl.start_default()
    connection_string = sitl.connection_string()

    vehicle = connect(connection_string,wait_ready=True)

    while not vehicle.is_armable:
    sleep(1)
    print"Initializing"

    vehicle.armed = True
    while not vehicle.armed:
    print "Arming"
    sleep(1)
    print "Armed"

    @vehicle.on_attribute('ch1out')
    def ch1out_listener(self, name, msg):
    print '%s attribute is: %s' % (name, msg)

    for i in range(1000,2000,100):
    vehicle.channels.overrides['3']=i
    sleep(1)

    vehicle.close()


    It should print ch1out everytime I update channel 3 but it is not.










    share|improve this question


























      0












      0








      0








      How do we get output channel values of an ardupilot from dronekit-python?



      We can get input channels from vehicle.channels but I couldn't find anything similar for output channels.



      EDIT:



      from time import sleep
      from dronekit import connect
      import dronekit_sitl

      sitl = dronekit_sitl.start_default()
      connection_string = sitl.connection_string()

      vehicle = connect(connection_string,wait_ready=True)

      while not vehicle.is_armable:
      sleep(1)
      print"Initializing"

      vehicle.armed = True
      while not vehicle.armed:
      print "Arming"
      sleep(1)
      print "Armed"

      @vehicle.on_attribute('ch1out')
      def ch1out_listener(self, name, msg):
      print '%s attribute is: %s' % (name, msg)

      for i in range(1000,2000,100):
      vehicle.channels.overrides['3']=i
      sleep(1)

      vehicle.close()


      It should print ch1out everytime I update channel 3 but it is not.










      share|improve this question
















      How do we get output channel values of an ardupilot from dronekit-python?



      We can get input channels from vehicle.channels but I couldn't find anything similar for output channels.



      EDIT:



      from time import sleep
      from dronekit import connect
      import dronekit_sitl

      sitl = dronekit_sitl.start_default()
      connection_string = sitl.connection_string()

      vehicle = connect(connection_string,wait_ready=True)

      while not vehicle.is_armable:
      sleep(1)
      print"Initializing"

      vehicle.armed = True
      while not vehicle.armed:
      print "Arming"
      sleep(1)
      print "Armed"

      @vehicle.on_attribute('ch1out')
      def ch1out_listener(self, name, msg):
      print '%s attribute is: %s' % (name, msg)

      for i in range(1000,2000,100):
      vehicle.channels.overrides['3']=i
      sleep(1)

      vehicle.close()


      It should print ch1out everytime I update channel 3 but it is not.







      dronekit-python






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 7:11







      Vedant Kandoi

















      asked Nov 14 '18 at 8:57









      Vedant KandoiVedant Kandoi

      1408




      1408






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I assume what you mean output channels is this 'ch1out','ch2out' value and so on.



          Mission Planner Status Message



          To get that value you can simply just using an attribute listener like this



          @vehicle.on_attribute('ch1out')
          def ch1out_listener(self, name, msg):
          print '%s attribute is: %s' % (name, msg)


          This function essentially just print the 'ch1out' value everytime it changes, you can just modify it accordingly. You can read more about this at here Observing attribute changes.



          But if you want to access the output channel value directly from the vehicle object like the input channel or other attribute.



          (Ex: vehicle.channels, vehicle.mode)



          You can add the output channel to the vehicle object by following this example provided by the Dronekit-Python documentation Create Attribute in App.






          share|improve this answer























          • What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

            – Vedant Kandoi
            Nov 15 '18 at 6:41











          • It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

            – Agustinus Baskara
            Nov 15 '18 at 6:57











          • I put the code in the question. Can you please check?

            – Vedant Kandoi
            Nov 15 '18 at 7:40










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296288%2fget-ardupilot-output-channels%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I assume what you mean output channels is this 'ch1out','ch2out' value and so on.



          Mission Planner Status Message



          To get that value you can simply just using an attribute listener like this



          @vehicle.on_attribute('ch1out')
          def ch1out_listener(self, name, msg):
          print '%s attribute is: %s' % (name, msg)


          This function essentially just print the 'ch1out' value everytime it changes, you can just modify it accordingly. You can read more about this at here Observing attribute changes.



          But if you want to access the output channel value directly from the vehicle object like the input channel or other attribute.



          (Ex: vehicle.channels, vehicle.mode)



          You can add the output channel to the vehicle object by following this example provided by the Dronekit-Python documentation Create Attribute in App.






          share|improve this answer























          • What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

            – Vedant Kandoi
            Nov 15 '18 at 6:41











          • It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

            – Agustinus Baskara
            Nov 15 '18 at 6:57











          • I put the code in the question. Can you please check?

            – Vedant Kandoi
            Nov 15 '18 at 7:40















          0














          I assume what you mean output channels is this 'ch1out','ch2out' value and so on.



          Mission Planner Status Message



          To get that value you can simply just using an attribute listener like this



          @vehicle.on_attribute('ch1out')
          def ch1out_listener(self, name, msg):
          print '%s attribute is: %s' % (name, msg)


          This function essentially just print the 'ch1out' value everytime it changes, you can just modify it accordingly. You can read more about this at here Observing attribute changes.



          But if you want to access the output channel value directly from the vehicle object like the input channel or other attribute.



          (Ex: vehicle.channels, vehicle.mode)



          You can add the output channel to the vehicle object by following this example provided by the Dronekit-Python documentation Create Attribute in App.






          share|improve this answer























          • What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

            – Vedant Kandoi
            Nov 15 '18 at 6:41











          • It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

            – Agustinus Baskara
            Nov 15 '18 at 6:57











          • I put the code in the question. Can you please check?

            – Vedant Kandoi
            Nov 15 '18 at 7:40













          0












          0








          0







          I assume what you mean output channels is this 'ch1out','ch2out' value and so on.



          Mission Planner Status Message



          To get that value you can simply just using an attribute listener like this



          @vehicle.on_attribute('ch1out')
          def ch1out_listener(self, name, msg):
          print '%s attribute is: %s' % (name, msg)


          This function essentially just print the 'ch1out' value everytime it changes, you can just modify it accordingly. You can read more about this at here Observing attribute changes.



          But if you want to access the output channel value directly from the vehicle object like the input channel or other attribute.



          (Ex: vehicle.channels, vehicle.mode)



          You can add the output channel to the vehicle object by following this example provided by the Dronekit-Python documentation Create Attribute in App.






          share|improve this answer













          I assume what you mean output channels is this 'ch1out','ch2out' value and so on.



          Mission Planner Status Message



          To get that value you can simply just using an attribute listener like this



          @vehicle.on_attribute('ch1out')
          def ch1out_listener(self, name, msg):
          print '%s attribute is: %s' % (name, msg)


          This function essentially just print the 'ch1out' value everytime it changes, you can just modify it accordingly. You can read more about this at here Observing attribute changes.



          But if you want to access the output channel value directly from the vehicle object like the input channel or other attribute.



          (Ex: vehicle.channels, vehicle.mode)



          You can add the output channel to the vehicle object by following this example provided by the Dronekit-Python documentation Create Attribute in App.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 3:31









          Agustinus BaskaraAgustinus Baskara

          16627




          16627












          • What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

            – Vedant Kandoi
            Nov 15 '18 at 6:41











          • It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

            – Agustinus Baskara
            Nov 15 '18 at 6:57











          • I put the code in the question. Can you please check?

            – Vedant Kandoi
            Nov 15 '18 at 7:40

















          • What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

            – Vedant Kandoi
            Nov 15 '18 at 6:41











          • It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

            – Agustinus Baskara
            Nov 15 '18 at 6:57











          • I put the code in the question. Can you please check?

            – Vedant Kandoi
            Nov 15 '18 at 7:40
















          What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

          – Vedant Kandoi
          Nov 15 '18 at 6:41





          What do you mean it prints everytime it changes, do I not have to call it? I tried simulating it with sitl and randomly changing channel.overrides['3'] which will change the output channels, right?. Should the function print automatically?

          – Vedant Kandoi
          Nov 15 '18 at 6:41













          It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

          – Agustinus Baskara
          Nov 15 '18 at 6:57





          It will run the print '%s attribute is: %s' % (name, msg) everytime ch1out value changes. Yes if you randomly change channel 3 (Throttle) values because ch1out - ch4out is the motor pwm output. (for Quadcopter).

          – Agustinus Baskara
          Nov 15 '18 at 6:57













          I put the code in the question. Can you please check?

          – Vedant Kandoi
          Nov 15 '18 at 7:40





          I put the code in the question. Can you please check?

          – Vedant Kandoi
          Nov 15 '18 at 7:40



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296288%2fget-ardupilot-output-channels%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3