コード例 #1
0
ファイル: motorTestCase.py プロジェクト: Aamirnadeem/Gimbal
    def testGetDuty(self):

        filesystem = SysfsWriterDummy()
        motor = Motor(0, 50.0).setSysfsWriter(filesystem)
        motor.start()
        motor.setThrottle(10.0)

        duty = motor.getDuty()

        self.assertEquals(duty, 1100000, "Duty wasn't properly returned")
コード例 #2
0
ファイル: motorTestCase.py プロジェクト: Aamirnadeem/Gimbal
    def testSetThrottle(self):

        filesystem = SysfsWriterDummy()
        motor = Motor(0, 50.0).setSysfsWriter(filesystem)
        motor.start()

        motor.setThrottle(10.0)

        throttle = motor.getThrottle()
        duty = motor.getDuty()

        self.assertEquals(throttle, 10.0, "Throttle wasn't properly set")
        self.assertEquals(duty, 1100000, "Duty wasn't properly set")
        #pwm6 corresponds to the motor number 0
        self.assertEquals(int(filesystem.read("/sys/class/pwm/pwm6/duty_ns")),
                          1100000, "Duty wasn't properly written")
コード例 #3
0
ファイル: motorTestCase.py プロジェクト: Aamirnadeem/Gimbal
    def testStart(self):

        filesystem = SysfsWriterDummy()
        motor = Motor(0, 50.0).setSysfsWriter(filesystem)
        motor.start()

        throttle = motor.getThrottle()
        duty = motor.getDuty()

        self.assertEquals(throttle, 50.0, "Incorrect throttle")
        self.assertEquals(duty, 1500000, "Incorrect duty")

        #pwm6 corresponds to the motor number 0
        self.assertEquals(int(filesystem.read("/sys/class/pwm/pwm6/run")), 1,
                          "Motor not running")
        self.assertEquals(
            int(filesystem.read("/sys/class/pwm/pwm6/period_ns")), 20000000,
            "Incorrect period")
        self.assertEquals(int(filesystem.read("/sys/class/pwm/pwm6/duty_ns")),
                          1500000, "Motor not running")