Skip to content

Commit

Permalink
hopefully fixed all flake8 issues and got rid of get_statuses() in cr…
Browse files Browse the repository at this point in the history
…azyflie_server
  • Loading branch information
julienthevenoz committed Mar 13, 2024
1 parent d922bec commit 6e4d811
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
15 changes: 7 additions & 8 deletions crazyflie_examples/crazyflie_examples/infinite_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ def main():

# fly figure8 until battery is low
fig8_counter = 0
status = allcfs.get_statuses()[0]
status = allcfs.crazyflies[0].status()# status = allcfs.get_statuses()[0]
# while status['battery'] > 3.8:
while status['pm_state'] == 0:
fig8_counter += 1
print(f'starting figure8 number {fig8_counter} of flight number {flight_counter}')
allcfs.startTrajectory(0, timescale=TIMESCALE)
timeHelper.sleep(traj1.duration * TIMESCALE + 2.0)
status = allcfs.get_statuses()[0]
status = allcfs.crazyflies[0].status() # status = allcfs.get_statuses()[0]
print(f'pm state : {status["pm_state"]}, battery left : {status["battery"]}')
timeHelper.sleep(1)


# not sure if useful
# check if pm = 3 just to be sure, if not abort test
if status['pm_state'] != 3:
print(f'power state is not 3 (low) but {status['pm_state']}. Landing and aborting')
print(f'power state is not 3 (low) but {status["pm_state"]}. Landing and aborting')
allcfs.land(targetHeight=0.06, duration=2.0)
timeHelper.sleep(3)
return 1
Expand All @@ -61,7 +61,7 @@ def main():
# now that battery is low, we try to land on the pad and see if it's charging
allcfs.land(targetHeight=0.06, duration=2.0)
timeHelper.sleep(5)
status = allcfs.get_statuses()[0]
status = allcfs.crazyflies[0].status() # status = allcfs.get_statuses()[0]

# if not charging, take off and land back again until it charges
while status['pm_state'] != 1:
Expand All @@ -74,17 +74,16 @@ def main():
timeHelper.sleep(2.5)
allcfs.land(targetHeight=0.06, duration=2.0)
timeHelper.sleep(5)
status = allcfs.get_statuses()[0]
status = allcfs.crazyflies[0].status() # status = allcfs.get_statuses()[0]


# now we wait until the crazyflie is charged
# while status['battery'] < 4.1:
while status['pm_state'] != 2:
print(f'not charged yet, battery at {status['battery']}V')
timeHelper.sleep(60)
status = allcfs.get_statuses()[0]
###not sure if useful
#check if it's still charging
status = allcfs.crazyflies[0].status( )#status = allcfs.get_statuses()[0]
#check if it's still charging ###not sure if this check is useful
if status['pm_state'] != 1:
print(f'charging interrupted, pm state : {status['pm_state']}')

Expand Down
13 changes: 0 additions & 13 deletions crazyflie_py/crazyflie_py/crazyflie.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,16 +997,3 @@ def cmdFullState(self, pos, vel, acc, yaw, omega):
self.cmdFullStateMsg.twist.angular.y = omega[1]
self.cmdFullStateMsg.twist.angular.z = omega[2]
self.cmdFullStatePublisher.publish(self.cmdFullStateMsg)

def get_statuses(self):
'''
Obtain a list containing the status of each crazyflie controlled by the Crazyserver
Each status is a dict, see status_topic_callback() for more details
'''

# self.get_logger().info(f'Crazyserver.get_statuses() was called')
statuses = []
for cf in self.crazyflies:
statuses.append(cf.get_status())

return statuses

0 comments on commit 6e4d811

Please sign in to comment.