Here is my question. How should I keep a PWM value for a few seconds? or How should I let motor rotates at a constant PWM value for a few seconds just like what it is shown in Fig.1?
I have tried following two ways:(1)I refer to your code https://github.com/bitcraze/crazyflie-f ... ta.py#L139. I have changed the 'time_step =0.1' to 'time_step=3' (assume I want to keep the specific PWM for 3 seconds), but the result is shown in Fig.2.
Code: Select all
    def _ramp_motors(self):
        thrust_mult = 1
        thrust_step = 500
        #time_step = 0.1
        time_step = 3
        thrust = 0
        pitch = 0
        roll = 0
        yawrate = 0
        # # Unlock startup thrust protection
        # for i in range(0, 100):
        #     self._cf.commander.send_setpoint(0, 0, 0, 0)
        localization = Localization(self._cf)
        self._cf.param.set_value('motor.batCompensation', 0)
        self._cf.param.set_value('motorPowerSet.m1', 0)
        self._cf.param.set_value('motorPowerSet.enable', 2)
        self._cf.param.set_value('system.forceArm', 1)
        while self.is_connected: #thrust >= 0:
            thrust += thrust_step * thrust_mult
            if thrust >= 65536 or thrust < 0:
            # if thrust >= 20000 or thrust < 0:
                thrust_mult *= -1
                thrust += thrust_step * thrust_mult
            print(thrust)
            # self._cf.commander.send_setpoint(roll, pitch, yawrate, thrust)
            localization.send_emergency_stop_watchdog()
            self._cf.param.set_value('motorPowerSet.m1', str(thrust))
            time.sleep(time_step)
Code: Select all
    def _ramp_motors(self):
        thrust_mult = 1
        thrust_step = 1000
        time_step = 0.1
        thrust = 0
        pitch = 0
        roll = 0
        yawrate = 0
        # # Unlock startup thrust protection
        # for i in range(0, 100):
        #     self._cf.commander.send_setpoint(0, 0, 0, 0)
        localization = Localization(self._cf)
        self._cf.param.set_value('motor.batCompensation', 0)
        self._cf.param.set_value('motorPowerSet.m1', 0)
        self._cf.param.set_value('motorPowerSet.enable', 1)
        self._cf.param.set_value('system.forceArm', 1)
        while self.is_connected: #thrust >= 0:
            thrust += thrust_step * thrust_mult
            # if thrust >= 65536 or thrust < 0:
            if thrust >= 65536*0.7 or thrust < 0:
                thrust_mult *= -1
                thrust += thrust_step * thrust_mult
            print(thrust)
            # self._cf.commander.send_setpoint(roll, pitch, yawrate, thrust)
            localization.send_emergency_stop_watchdog()
            t_start = time.time()
             while(1):
                 self._cf.param.set_value('motorPowerSet.m1', str(thrust))
                 time.sleep(0.1)
                 t_end = time.time()
                 if t_end-t_start > 3:
                     break