예제 #1
0
    def send_pwm_continuesly(self):
        with navio.pwm.PWM(self.rc_channel) as pwm:
            pwm.enable()
            pwm.set_period(50)

            def _max_pwm():
                pwm.set_duty_cycle(self.max_pwm)

            def send_max_pwm():
                rospy.loginfo("Sending max pwm ({}) to {}. channel...".format(
                    self.min_pwm, self.rc_channel))
                try:
                    _max_pwm()
                except:
                    rospy.logerr("Error occured while sending max pwm...")
                rospy.loginfo("Sent")
                self.pub_stat.publish("open")

            def _min_pwm():
                pwm.set_duty_cycle(self.min_pwm)

            def send_min_pwm():
                rospy.loginfo("Sending max pwm ({}) to {}. channel...".format(
                    self.min_pwm, self.rc_channel))
                try:
                    _min_pwm()
                except:
                    rospy.logerr("Error occured while sending min pwm...")
                rospy.loginfo("Sent")
                self.pub_stat.publish("close")

            while (True):
                if self.next_state == self.state:
                    if self.state == "open":
                        rospy.loginfo("STILL open")
                        send_min_pwm()
                    elif self.state == "close":
                        rospy.loginfo("STILL close")
                        send_max_pwm()
                    else:
                        rospy.logerr(
                            "States are the same but... unknown error happend..."
                        )
                else:
                    if self.next_state == "open":
                        rospy.loginfo("RECEIVED open")
                        send_min_pwm()
                        self.change_state("open")
                    elif self.next_state == "close":
                        rospy.loginfo("RECEIVED close")
                        send_max_pwm()
                        self.change_state("close")
                    else:
                        rospy.logerr("Ooo!")
        rospy.spin()
예제 #2
0
def main():
    pwm = navio.pwm.PWM(PWM_OUTPUT)
    pwm.initialize()
    pwm.set_period(50)
    pwm.enable()

    loop_for(2, pwm.set_duty_cycle, SERVO_MAX)
    loop_for(2, pwm.set_duty_cycle, SERVO_MIN)
    loop_for(2, pwm.set_duty_cycle, SERVO_NOM)

    while (True):
        loop_for(1, pwm.set_duty_cycle, 1.3)
예제 #3
0
pwm = navio.pwm.PWM(PWM_OUTPUT)
pwm2 = navio.pwm.PWM(PWM_OUTPUT2)
pwm3 = navio.pwm.PWM(PWM_OUTPUT3)
pwm4 = navio.pwm.PWM(PWM_OUTPUT4)

pwm.initialize()
pwm2.initialize()
pwm3.initialize()
pwm4.initialize()

pwm.set_period(50)
pwm2.set_period(50)
pwm3.set_period(50)
pwm4.set_period(50)

pwm.enable()
pwm2.enable()
pwm3.enable()
pwm4.enable()

t1 = threading.Thread(target=servo, args=[])
t1.start()

stream = io.BytesIO()

print "*****Command*****"
print "demarrage = 1 palm (pomme de la main)"
print "arret = 1 fists"
print "acceleration = 2 palm"
print "decceleration = 2 fist"
print "photo = palm when drone is ON"