This repository was archived by the owner on Mar 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2.py
More file actions
33 lines (28 loc) · 1.3 KB
/
task2.py
File metadata and controls
33 lines (28 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
from copter import Copter, NavPoint
# from Objects_detector import ObjectsDetector
import rospy
from std_msgs.msg import String, Bool
CURRENT_POINT = 0
LOG_PATH = "/home/clover/Documents/CopterNTI/log.txt"
# We have choosen height 0.5m, because with other height copter has seen two or more markers in camera
Points = [NavPoint(0, 0, 0.5, endpoint=True), NavPoint(0, 2.5, 0.5), NavPoint(3.5, 0.5, 0.5), NavPoint(2, 1.5, 0.5), NavPoint(3.5, 3.5, 0.5), NavPoint(0, 0, endpoint=True)]
def logging(data):
info = "Point #" + str(CURRENT_POINT) + ", X coordinate " + str(Points[CURRENT_POINT].x) + ", Y coordinate " + str(Points[CURRENT_POINT].y) + ", Recognized Color " + data.data + "\n"
with open(LOG_PATH, 'a') as f:
f.write(info)
print("Writed, " + info)
if __name__ == "__main__":
rospy.init_node('flight_cont')
with open(LOG_PATH, 'w') as f:
f.write("---FLIGHT LOG---\n")
start = rospy.Publisher('detector/start', Bool, queue_size=100)
logger = rospy.Subscriber('detector/detected', String, logging)
clover = Copter()
for point in Points:
clover.navigate_to_point(point)
if not point.endpoint:
# Sending command to recognize objects
start.publish(True)
rospy.sleep(5)
CURRENT_POINT += 1