Parrot-Developers/olympe

AttributeError: ‘function’ object has no attribute ‘health’ / 'reset_orientation'

Closed this issue · 1 comments

g0d commented

Regardless of what I do or how I do it, the command: from olympe.messages import battery might load correctly but the battery object is completely blank! No get_state() is working and I always get:

return drone.get_state(battery.health)[“state_of_health”]
AttributeError: ‘function’ object has no attribute ‘health’

Same happens for 'reset_orientation' and probably for other commands!

I search through the Python sources and there is no reference to Gimbal and Battery options and therefore the code can't find the assemblies.

Can you please update the SDK to 1.7.1 and check for other missing libraries?

It literally broke all my builds…

Best,
George Delaportas

1/ battery.health issue
It seems that the "battery" message identifier is masked by a function with the same name in your code. (Do you have a "def battery():" somewhere ?)

2/ reset_orientation issue
reset_orientation is a command and there is no sate associated with command messages (only the event messages have an associated state). So if you get a RuntimeError: gimbal.reset_orientation state is uninitialized it's completely normal. You may be looking for the gimbal.attitude event message instead.

The following code works fine:

import olympe
from olympe.messages import battery
from olympe.messages import gimbal

# def battery():
#     pass

drone = olympe.Drone("192.168.43.1")
drone.connect()
print(drone.get_state(battery.health)["state_of_health"])
print(drone.get_state(gimbal.attitude))