Open lifenghua0108 opened 5 years ago
I confirm on Ubuntu 18.10.
I think that, weak point of this software is complexity operating environment. I would like to rewrite it in Windows C ++ if I have time...
Thank you so much It works well on Ubuntu 18.04
Good! I'm happy your works well.
Hi @r9kawai,
First of all, thank you for sharing this code. I have successfully installed and ran the programme.
As this is quite an interesting project, I would like to understand more:
AR markers are used in locating the next location is that correct? Therefore, we need an AR marker along with the QR code or Barcode. Am I right?
I have tried both Barcodes and QR codes, sometimes it can read the code but sometimes do not.. I assume its the lighting problem or size of the codes affecting it.
Hence, I am facing a problem of it only reads the QR code below AR-02, and after reading the first code, it does not record the second code anymore.
This program works roughly follow below.
1.If find a AR in camera image, then order a yawing command to that. 2.Then order a up or down command to that. (These angles and distances are calculated from the size of the AR and the position on the screen.) (This calculation is not accurate, and I want to improve it next time.) 3.Then order a forward command to that. (It keeps a certain distance to avoid contact.) 4.If a distance of AR to aircraft is under 60cm, then try read process Barcode. (BARREAD_DISTANCE = 60) (This program could measure a distance of AR to aircraft, but could'nt measure a distance of Barcode to aircraft! because, size of barcode is unknown) (It is important that the AR size is as expected.) 5.If close AR under 60cm, It continue trying, and axis correct and capt a AR at center) (If Barcode is too detailed, regardless capt in screen, May not be readable for a long time.) (Needs are room is bright, the image transfer on WiFi is good, the Barcode is clear, the lines are not too thin)
6.If success to read the Barcode, then 180degree yawing. but, If couldn't capt a next AR at timing at it. Will not continue. (I wanted to search with a better algorithm.)
(In fact, A camera of Tello is too cheep for read a Barcode, Not practical, but I wanted to demonstrate a new usecase for drones.)
Move to like the Youtube demo movie, two AR codes are arrangement place at roughly need oposite facing each other. About 5m.
I'm going to build a Windows version that was completely rewritten in C ++. I don't know when...
This program works roughly follow below.
1.If find a AR in camera image, then order a yawing command to that. 2.Then order a up or down command to that. (These angles and distances are calculated from the size of the AR and the position on the screen.) (This calculation is not accurate, and I want to improve it next time.) 3.Then order a forward command to that. (It keeps a certain distance to avoid contact.) 4.If a distance of AR to aircraft is under 60cm, then try read process Barcode. (BARREAD_DISTANCE = 60) (This program could measure a distance of AR to aircraft, but could'nt measure a distance of Barcode to aircraft! because, size of barcode is unknown) (It is important that the AR size is as expected.) 5.If close AR under 60cm, It continue trying, and axis correct and capt a AR at center) (If Barcode is too detailed, regardless capt in screen, May not be readable for a long time.) (Needs are room is bright, the image transfer on WiFi is good, the Barcode is clear, the lines are not too thin)
6.If success to read the Barcode, then 180degree yawing. but, If couldn't capt a next AR at timing at it. Will not continue. (I wanted to search with a better algorithm.)
(In fact, A camera of Tello is too cheep for read a Barcode, Not practical, but I wanted to demonstrate a new usecase for drones.)
Thank you for your reply. It really helps to understand how it works. However, I am still thinking the following issues:
1) I am trying to figure out how would it trigger to scan another QR code after the first one: I turn on the drone and link to the system, holding the tello and scan the first QR with AR. Success Then I move the tello and point to another QR code with AR. However, it does not read the code anymore.
Hence, if I understand what triggers the next scanning, I think I I will try to create a simple route for the tello to fly and scan 3~4 QR codes, e.g. up and down motion only.
Furthermore, I have also tried to control the tello with 'w' 'a' 's' 'd' to scan QR codes. However, it would not scan the 2nd QR code.
Example: One QR with AR placed in lower position Second QR with AR placed in higher position
Take off > read the first QR and AR code Control tello to fly up and read the 2nd QR and AR code (failed)
I want you to try a little amend below.
insert new line * 200 : # enable marker flag self.choise_marker = id 201 : detect[id] = True
*comment out line 318 : # self.choise_marker = self._marker_sel()
*comment out line 419 : # self._marker_reset()
May be, It has change action to your need. It support AR markers only No.0 - 3. This is not good code... but, The next future software will be fixed. If you add array variable 4 to more, so good.
Thank you for your quick reply. I will try your advise.
I was trying to build a flight path (auto pilot) for the following case, but I struggled alot... rip:
Following task:
I have read the UI file and come up with the following changes, but I failed... :
Source of: drone_ar_flight.py
def get_command(self):
if self.next_cmd != None:
cmd = self.next_cmd
val = self.next_cmd_val
self.next_cmd = None
self.next_cmd_val = 0
return cmd, val
cmd = 'stay'
val = 0
if self.mode == MODE_SEARCH_UD:
self.choise_marker = self._marker_sel()
#if self.marker_enable[self.choise_marker] == True:
self.marker_enable[self.choise_marker] == True:
self.mode = MODE_TO_DIR
#else:
#if self.now_height_cm > ALTITUDE_MAX:
# self.sub_mode = SUB_MODE_DOWN
#if self.now_height_cm < ALTITUDE_MIN:
# self.sub_mode = SUB_MODE_UP
droneMoveRight(self,40)
self.drone.move_right(40)
self.choise_marker = self._marker_sel()
self._marker_reset()
cmd = 'stay'
val = 0
droneUp(self,30)
self.drone.move_right(30)
self.choise_marker = self._marker_sel()
self._marker_reset()
cmd = 'stay'
val = 0
droneMoveLeft(self,40)
self.drone.move_right(40)
self.choise_marker = self._marker_sel()
self._marker_reset()
cmd = 'stay'
val = 0
return cmd, val
def draw_bold_text(self, drawtxt, text, x, y, color1, color2):
drawtxt.text((x+2,y-2), text, color2, font=self.fontbold)
drawtxt.text((x+2,y+2), text, color2, font=self.fontbold)
drawtxt.text((x-2,y-2), text, color2, font=self.fontbold)
drawtxt.text((x-2,y+2), text, color2, font=self.fontbold)
drawtxt.text((x,y), text, color1, font=self.font)
return
def _get_2point_degree(self, ax, ay, ax2, ay2):
radian = math.atan2(ay2 - ay, ax2 - ax)
return (int)(round(math.degrees(radian)))
def _marker_reset(self):
self.choise_marker = 0
self.marker_id = [False, False, False, False]
self.marker_time = [int(0), int(0), int(0), int(0)]
self.marker_enable = [False, False, False, False]
self.marker_inframe = [int(0), int(0), int(0), int(0)]
self.marker_pointss = [[[float(0),float(0)],[float(0),float(0)],[float(0),float(0)],[float(0),float(0)]]]*4
self.marker_distances = [int(0), int(0), int(0), int(0)]
self.marker_diff_cm = [ [int(0), int(0)],[int(0), int(0)],[int(0), int(0)],[int(0), int(0)] ]
self.marker_degree = [int(0), int(0), int(0), int(0)]
self.marker_ztilt = [int(0), int(0), int(0), int(0)]
self.code_flag = False
self.chase_marker = int(-1)
return
Apologies for being a beginner of python... Can I know which part I misunderstand?
Is it only possible on ubuntu 18.10 ? how about 18.04?16.04?