Welcome to the Robolink Community forum!
Trouble getting real time feedback form sensors
-
@beraug Can you try running this code instead to verify everything works https://support.robolink.com/codrone-library/getgyroangles let me know what results you get.
-
@robolink_arnold Can you take a look at this?
-
Thanks guys, will have a look.
The link to download the lates library would also be highly regarded.
I've actually manage to get the code running with this code, although when the drone is flying it don't send the data. He can only send when has finished the flight command. I wonder how to make then work in parallel?
import time
def eventUpdateAttitude(data):
global height, horizontal_position_X, horizontal_position_Yheight = getHeight()
horizontal_position_X = horizontal_position.X
horizontal_position_Y = horizontal_position.Y#set the event handler
drone = CoDrone.CoDrone(True, False, False, False, False)
drone.connect()
drone.setEventHandler([drone.getHeight(),drone.getOptFlowPosition()], eventUpdateAttitude)horizontal_position = drone.getOptFlowPosition()
height = drone.getHeight()drone.takeoff()
while(drone.isConnected()):
#request for the angle data
drone.sendRequest([drone.getHeight(),drone.getOptFlowPosition()])
time.sleep(0.05)#make sure to have a delay
print(horizontal_position.X, horizontal_position.Y,height) -
@beraug Ohhh, I see, Jupyter notebook. We haven't yet tested running CoDrone using a Jupyter Notebook yet, unfortunately. That explains why you're running into errors. At the moment, I would recommend following the PyCharm setup to use Python with CoDrone, since that's what we've supported so far. It can be a bit cumbersome and technical, which we're currently trying to improve on. That said, here is the tutorial on how to set that up.
Our team is currently exploring Jupyter notebook for a different project, but we haven't used it with CoDrone yet. @robolink_arnold Are you familiar with what the error might mean, and whether we even have access to the latest CoDrone library via Jupyter notebook?
-
Hi guys, sorry for my late reply, I’m in Australia so a bit of lag on my answers.
I’m using the command lines directly from Jupiter notebook. Cheers.
-
Hello @beraug are you using pycharm?
-
@beraug Let me check with @robolink_whoseop to make sure you're getting the proper version and library.
Quick question before I get back with Whoseop's help, are you running in PyCharm or just purely command line?
-
HI Arnold and Wes, Thanks very much for replying my question.
I've actually had a bit of trouble finding the latest library that actually works with the functions in the link sent. Not sure but when I've installed CoDrone using pip it gave me a different version from the latest.
I'm getting the files from here: https://github.com/RobolinkInc/CoDrone and have also tried to just replace the files in the installed directory to update them to the latest revision but does not look like it is working. I'm getting the same error:
***NameError Traceback (most recent call last)
<ipython-input-8-d219565f103e> in <module>()
18
19 #set the event handler
---> 20 drone.setEventHandler(DataType.Imu, eventUpdateAttitude)
21
22NameError: name 'DataType' is not defined***
Could you please share the repository of the latest code?
Cheers.
-
As @robolink_arnold mentioned, looks like the code you're running is using the old library. If you check out the URL he linked, you'll be able to use a newer set of functions that hopefully are easier to use and understand.
Let us know if you have any other questions or have trouble getting it to work!
-
Hello @beraug Are you using our latest library with the most updated functions we have recently created? Check out this link it has sample code we have created for our library https://support.robolink.com/ Let me know if you have any other questions.