Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72682d946e | ||
|
|
a556f1c179 | ||
|
|
b632b14a55 | ||
|
|
783b373943 | ||
|
|
d2aaf307e9 | ||
|
|
46278e3cda | ||
|
|
2dc7d96884 | ||
|
|
710b87e11f | ||
|
|
a72c728f33 | ||
|
|
87aaeb947d | ||
|
|
be3d08b05a | ||
|
|
db3a0cff37 | ||
|
|
2374764af5 | ||
|
|
1f09723ff3 | ||
|
|
3f4da20282 | ||
|
|
387aef30d1 | ||
|
|
40bd45e7e6 | ||
|
|
4a26fe1460 | ||
|
|
4f98f5bf85 | ||
|
|
bdde39d6d0 | ||
|
|
de36b09bce | ||
|
|
6e75c6927f | ||
|
|
18ef1603f2 | ||
|
|
48819cb513 | ||
|
|
d6febac252 | ||
|
|
6fc46ceb71 | ||
|
|
d73cb8c4d8 | ||
|
|
fdf80652c9 | ||
|
|
d4c81a2885 | ||
|
|
2f613bbcf4 | ||
|
|
7915cc431d | ||
|
|
b4547c2088 | ||
|
|
7a26a4cbb3 | ||
|
|
076e9a6bac | ||
|
|
ff3bf78ade | ||
|
|
ba29a07e28 | ||
|
|
c8cc46269b | ||
|
|
2faf39408e | ||
|
|
baa0fbcdbe | ||
|
|
74cb3b4b70 | ||
|
|
89cf11d711 | ||
|
|
6ce5534fdd | ||
|
|
21d27fef69 | ||
|
|
2b1087b3ce | ||
|
|
3fcfafa388 | ||
|
|
ab60d14897 | ||
|
|
7ab7d8f60f | ||
|
|
6fdfb450ca | ||
|
|
321774e870 | ||
|
|
8eee835815 | ||
|
|
4d664bbbd5 | ||
|
|
5c113e31e8 | ||
|
|
04a232534c | ||
|
|
ef823b3df9 | ||
|
|
510bbd2544 | ||
|
|
cfad3480a5 | ||
|
|
97b820e49a | ||
|
|
b2be135175 | ||
|
|
40d7c1035e | ||
|
|
20c6e06801 | ||
|
|
5b5d34cda6 | ||
|
|
cf2d1447df | ||
|
|
9144c5b231 | ||
|
|
6cbf1bcbf2 | ||
|
|
5a807ff1ee | ||
|
|
506f8b24d6 | ||
|
|
cc2ceeb6ac | ||
|
|
dab2a5e1b9 | ||
|
|
ecfda4b47f | ||
|
|
9372927e02 | ||
|
|
056c0323a2 | ||
|
|
d0f0e063d3 | ||
|
|
05b58a1102 | ||
|
|
0bd5d3f5cf | ||
|
|
dbba31ae7a | ||
|
|
e37ecf13c6 | ||
|
|
462b0bfa7d | ||
|
|
f8c901bfb7 | ||
|
|
f4c652f70f | ||
|
|
0b1bb0ff81 | ||
|
|
4b708657f0 | ||
|
|
ec74ec7c7b | ||
|
|
0c588bc139 | ||
|
|
f549aa72ee | ||
|
|
6064d27577 | ||
|
|
42c5bfc1d1 | ||
|
|
589a955de6 | ||
|
|
e5ae36e48f | ||
|
|
129678a543 | ||
|
|
119bde92b6 | ||
|
|
e9f7268509 | ||
|
|
36965d0015 | ||
|
|
a0ea2f584f | ||
|
|
c217cc9700 | ||
|
|
293dcbd4a3 | ||
|
|
7c4eea39f1 | ||
|
|
605dcb09bb | ||
|
|
d2ed38ef51 | ||
|
|
f59e0d2f23 | ||
|
|
9fd5682691 | ||
|
|
0146534ccc | ||
|
|
b2cb9adcf9 | ||
|
|
ba7ef1edda | ||
|
|
63c8606c82 | ||
|
|
cb39d5646f | ||
|
|
20443a5cd3 | ||
|
|
6227d57b55 | ||
|
|
b7cd47b2c0 | ||
|
|
a409658f8b | ||
|
|
0bc9f716b3 | ||
|
|
a6dfd5511f | ||
|
|
8e8b380c76 | ||
|
|
4cb8137668 | ||
|
|
a177ba0494 |
@@ -1,3 +0,0 @@
|
||||
.vscode/
|
||||
turtle_control/CMakeFiles/*
|
||||
Docker/turtle_control/*
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
sudo docker exec -it ros-core bash
|
||||
@@ -1,34 +0,0 @@
|
||||
#Simon Tscherne
|
||||
version: "3"
|
||||
services:
|
||||
novnc-backend:
|
||||
image: theasp/novnc:latest
|
||||
environment:
|
||||
- DISPLAY_WIDTH=1700
|
||||
- DISPLAY_HEIGHT=901
|
||||
- RUN_XTERM=no
|
||||
ports:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- host
|
||||
container_name: novnc
|
||||
|
||||
ros-core:
|
||||
image: ros_noetic_turtlebot
|
||||
environment:
|
||||
- DISPLAY=novnc:0.0
|
||||
devices:
|
||||
- /dev/video0:/dev/video0
|
||||
- /dev/video1:/dev/video1
|
||||
volumes:
|
||||
- ./turtle_control:/catkin_ws/src/turtle_control
|
||||
depends_on:
|
||||
- novnc-backend
|
||||
command: bash -c "roscore"
|
||||
networks:
|
||||
- host
|
||||
container_name: ros-core
|
||||
|
||||
networks:
|
||||
host: {}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
sudo docker rm -f $(sudo docker ps -a -q)
|
||||
@@ -1,62 +0,0 @@
|
||||
#Simon Tscherne
|
||||
FROM osrf/ros:noetic-desktop-full
|
||||
|
||||
# Change the default shell to Bash
|
||||
SHELL [ "/bin/bash" , "-c" ]
|
||||
|
||||
# Install some needed stuff
|
||||
RUN apt update && apt install -y git vim liborocos-kdl-dev python3 python-is-python3 python3-pip tmux
|
||||
|
||||
RUN pip install imutils opencv-python
|
||||
|
||||
|
||||
RUN source ./ros_entrypoint.sh \
|
||||
&& mkdir -p /catkin_ws/src \
|
||||
&& cd /catkin_ws/ \
|
||||
&& catkin_make \
|
||||
&& cd src/ \
|
||||
&& git clone https://github.com/turtlebot/turtlebot.git \
|
||||
&& git clone https://github.com/turtlebot/turtlebot_msgs.git \
|
||||
&& git clone https://github.com/turtlebot/turtlebot_apps.git \
|
||||
&& git clone https://github.com/turtlebot/turtlebot_simulator \
|
||||
&& git clone https://github.com/yujinrobot/yujin_ocs.git \
|
||||
&& mv yujin_ocs/yocs_cmd_vel_mux yujin_ocs/yocs_controllers yujin_ocs/yocs_velocity_smoother . \
|
||||
&& rm -rf yujin_ocs \
|
||||
&& git clone https://github.com/yujinrobot/kobuki.git
|
||||
|
||||
RUN source ./ros_entrypoint.sh \
|
||||
&& cd /catkin_ws/src \
|
||||
&& rosdep install --from-paths . --ignore-src -r -y \
|
||||
&& cd .. \
|
||||
&& source ./devel/setup.bash \
|
||||
&& catkin_make \
|
||||
&& cd build \
|
||||
&& make install
|
||||
|
||||
RUN echo "source /ros_entrypoint.sh" >> ~/.bashrc
|
||||
RUN echo "source /catkin_ws/devel/setup.bash" >> ~/.bashrc
|
||||
|
||||
#Now astra camera
|
||||
|
||||
RUN apt install -y libgflags-dev ros-noetic-image-geometry ros-noetic-camera-info-manager ros-noetic-image-transport ros-noetic-image-publisher libgoogle-glog-dev libusb-1.0-0-dev libeigen3-dev
|
||||
|
||||
RUN git clone https://github.com/libuvc/libuvc.git \
|
||||
&& cd libuvc \
|
||||
&& mkdir build \
|
||||
&& cd build \
|
||||
&& cmake .. \
|
||||
&& make -j4 \
|
||||
&& sudo make install \
|
||||
&& sudo ldconfig
|
||||
|
||||
RUN source /catkin_ws/devel/setup.bash \
|
||||
&& cd /catkin_ws/src \
|
||||
&& git clone https://github.com/orbbec/ros_astra_camera.git \
|
||||
&& rosdep install --from-paths . --ignore-src -r -y \
|
||||
&& cd .. \
|
||||
&& catkin_make \
|
||||
&& roscd astra_camera
|
||||
|
||||
|
||||
# Set the working folder at startup
|
||||
WORKDIR /catkin_ws
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
#Simon Tscherne
|
||||
echo "This can take some time!"
|
||||
echo "This does create new docker images. Press enter"
|
||||
read nothing
|
||||
sudo chmod -R 0777 ./turtle_control
|
||||
sudo docker build -f ros_noetic_dockerfile -t ros_noetic_turtlebot .
|
||||
sudo docker compose down --volumes --remove-orphans
|
||||
sudo docker compose up --remove-orphans -d
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
#Simon Tscherne
|
||||
echo "This starts a roscore container in a non safe, not isolated way!"
|
||||
echo "Only works if youre using X11"
|
||||
echo "Press enter"
|
||||
read nothing
|
||||
sh removeAllContainer.sh
|
||||
sudo docker run -d \
|
||||
--net=host \
|
||||
--name=ros-core \
|
||||
--env="DISPLAY" \
|
||||
--env="QT_X11_NO_MITSHM=1" \
|
||||
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
|
||||
--volume="./turtle_control:/catkin_ws/src/turtle_control" \
|
||||
--device=/dev/video0:/dev/video0 \
|
||||
--device=/dev/video1:/dev/video1 \
|
||||
ros_noetic_turtlebot \
|
||||
"rqt"
|
||||
export containerId=$(sudo docker ps -l -q)
|
||||
sudo xhost +local:`sudo docker inspect --format='{{ .Config.Hostname }}' $containerId`
|
||||
sudo docker start $containerId
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
#Stops all docker container
|
||||
sudo docker stop $(sudo docker ps -a -q)
|
||||
sudo docker ps
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
Programm für den Arduino für die Kontrolle des Arms.
|
||||
Nutzung des Arms:
|
||||
1. Bewegung an eine bestimmte Position & Greifen:
|
||||
Wenn man den Arm an eine bestimmte Position bekommen will muss man in den Serial Port "x y z" schreiben, wobei x, y und z durch die jeweiligen Werte ersetzt werden müssen.
|
||||
Die Formatierung der Eingabe ist wichtig, daher x-Wert Leerzeichen y-Wert Leerzeichen z-Wert leerzeichen (z.B. 100 100 0).
|
||||
Dann bewegt sich der Arm an die Position, wartet 2 Sekunden, greift das Objekt und fährt dann wieder zurück.
|
||||
2. Loslassen
|
||||
Um das Objekt loszulassen (d.h. in die Box lassen), in den Serial Port "release" schreiben.
|
||||
3. Reset
|
||||
Um den Arm in die Grundposition zu bringen -> In den Serial Port "reset schreiben"
|
||||
|
||||
Die optimale z-Position für die Steine war -140.
|
||||
x-Achse ist nach vorne(+) und hinten(-), y-Achse ist nach links (-) und rechts (+), z-Achse ist nach oben(+) und unten(-)
|
||||
KEINE negativen Werte für x nutzen, funktioniert garnicht
|
||||
|
||||
|
||||
//Start -> 0 in Serial
|
||||
//Started -> 1 in Serial
|
||||
//Grabbed -> 2 in Serial
|
||||
//Release -> 3 in Serial
|
||||
//Released -> 4 in Serial
|
||||
//RESET -> X in Serial
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <InverseK.h>
|
||||
#include <Servo.h>
|
||||
|
||||
#define SERVOVELOCITY 1
|
||||
#define LEDPIN 13
|
||||
|
||||
|
||||
bool resetUsed = false;
|
||||
|
||||
//Definition der Servos, s6 ist der unterste, s5 der darüber und so weiter, s2 ist der Servo der das Objekt greift.
|
||||
Servo s6,s5,s4,s3,s2;
|
||||
int v6,v5,v4,v3,v2;
|
||||
|
||||
int servo6Pos, servo5Pos, servo4Pos, servo3Pos, servo6Vel, servo5Vel,servo4Vel,servo3Vel;
|
||||
|
||||
int x,y,z;
|
||||
String s;
|
||||
|
||||
float a0, a1, a2, a3, temp1, temp2, temp3, temp4;
|
||||
|
||||
void setup() {
|
||||
//9600 GEHT NICHT! IN DIE DOKU
|
||||
Serial.begin(115200);
|
||||
Serial.setTimeout(1);
|
||||
s6.attach(6);
|
||||
s5.attach(5);
|
||||
s4.attach(4);
|
||||
s3.attach(3);
|
||||
s2.attach(2);
|
||||
reset();
|
||||
|
||||
//Definition der Bestandteile des Arms für die Inverse Kinematik
|
||||
Link base, upperarm, forearm, hand;
|
||||
|
||||
base.init(20, b2a(0), b2a(180.0));
|
||||
upperarm.init(122, b2a(0.0), b2a(180.0));
|
||||
forearm.init(80, b2a(0.0), b2a(180.0));
|
||||
hand.init(180, b2a(0.0), b2a(180.0));
|
||||
|
||||
InverseK.attach(base, upperarm, forearm, hand);
|
||||
|
||||
pinMode(LEDPIN,OUTPUT);
|
||||
|
||||
String s;
|
||||
|
||||
while(true){
|
||||
while (!Serial.available());
|
||||
s = Serial.readString();
|
||||
//Serial.println(s);
|
||||
if(s.indexOf("0") != -1)
|
||||
break;
|
||||
|
||||
//Serial.println(s);
|
||||
}
|
||||
digitalWrite(LEDPIN,HIGH);
|
||||
Serial.write("1");
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
void manuell(){
|
||||
s6.write(a2b(30)); //im Uhrzeigersinn negativ
|
||||
s5.write(a2b(00)); //positiv nach vorne, negativ nach hinten
|
||||
s4.write(a2b(0)); //negativ nach unten, positiv nach oben
|
||||
//Serial.println(a3);
|
||||
Serial.println(convertServo(a2b(90)));
|
||||
s3.write(a2b(0)); //negativ nach oben
|
||||
// s2.write(50);
|
||||
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
|
||||
void delayServo(Servo *s, float value){
|
||||
|
||||
float temp = value/2;
|
||||
|
||||
s->write(temp);
|
||||
delay(1000);
|
||||
s->write(value);
|
||||
|
||||
}
|
||||
//Bringt den Arm in die Grundposition
|
||||
void reset(){
|
||||
|
||||
|
||||
if(!resetUsed){
|
||||
s6.write(90);
|
||||
servo6Pos = 90;
|
||||
s5.write(90);
|
||||
servo5Pos = 90;
|
||||
s4.write(10);
|
||||
servo4Pos = 10;
|
||||
s3.write(170);
|
||||
servo3Pos = 170;
|
||||
s2.write(90);
|
||||
resetUsed = true;
|
||||
}else{
|
||||
Serial.write("X");
|
||||
moveToPos(10,130,10, 170);
|
||||
delay(1000);
|
||||
s2.write(90);
|
||||
}
|
||||
}
|
||||
//Greif-Funktion, hebt den Arm wieder hoch, wird nur automatisch aufgerufen
|
||||
void pullUp(){
|
||||
//Serial.println("Grabbing!");
|
||||
/*s6.write(90);
|
||||
delay(1000);
|
||||
s5.write(90);
|
||||
|
||||
delay(1000);
|
||||
|
||||
s3.write(170);*/
|
||||
|
||||
moveToPos(90,90,40, 170);
|
||||
delay(1000);
|
||||
for(int i = 0; i< 10000; i++){
|
||||
Serial.println("2");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Release-Funktion, Nutzung oben beschrieben
|
||||
void release(){
|
||||
|
||||
|
||||
/*s6.write(90);
|
||||
|
||||
delay(1000);
|
||||
s5.write(150);
|
||||
delay(1000);
|
||||
s4.write(30);
|
||||
delay(1000);
|
||||
s3.write(100);
|
||||
|
||||
delay(3000);*/
|
||||
|
||||
moveToPos(90, 150, 50, 100);
|
||||
delay(3000);
|
||||
|
||||
s2.write(90);
|
||||
delay(2000);
|
||||
Serial.write("4");
|
||||
reset();
|
||||
|
||||
}
|
||||
//Funktion um die langsame Bewegung des Armes zu ermöglichen
|
||||
//Inkrementiert alle 200 Millisekunden die Position
|
||||
//Bis Zielposition erreicht wurde
|
||||
void moveToPos(int servo6End, int servo5End, int servo4End, int servo3End){
|
||||
|
||||
servo6Vel = servo6Pos > servo6End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
servo5Vel = servo5Pos > servo5End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
servo4Vel = servo4Pos > servo4End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
servo3Vel = servo3Pos > servo3End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
|
||||
bool b6 = false, b5 = false, b4 = false, b3 = false;
|
||||
|
||||
while(true){
|
||||
|
||||
if(servo6Pos != servo6End){
|
||||
servo6Pos+=servo6Vel;
|
||||
s6.write(servo6Pos);
|
||||
Serial.println("S6: "+ String(servo6Pos) + " - " + String(servo6End));
|
||||
}else b6 = true;
|
||||
|
||||
if(servo5Pos != servo5End){
|
||||
servo5Pos+=servo5Vel;
|
||||
s5.write(servo5Pos);
|
||||
Serial.println("S5: "+ String(servo5Pos) + " - " + String(servo5End));
|
||||
} else b5 = true;
|
||||
|
||||
if(servo4Pos != servo4End){
|
||||
servo4Pos+=servo4Vel;
|
||||
s4.write(servo4Pos);
|
||||
Serial.println("S4: "+ String(servo4Pos) + " - " + String(servo4End));
|
||||
} else b4 = true;
|
||||
|
||||
if(servo3Pos != servo3End){
|
||||
servo3Pos+=servo3Vel;
|
||||
s3.write(servo3Pos);
|
||||
Serial.println("S3: "+ String(servo3Pos) + " - " + String(servo3Pos));
|
||||
} else b3 = true;
|
||||
|
||||
delay(200);
|
||||
|
||||
if(b6 && b5 && b4 && b3){
|
||||
Serial.println("Moved!");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void loop() {
|
||||
|
||||
//Serial Port wird gelesen, wenn der String "reset" ist wird resetted, wenn "release" wird der Block gelassen, wenn Format "x y z" bewegt sich der Arm an die Position
|
||||
s = Serial.readString();
|
||||
|
||||
if(s.length() >= 3){
|
||||
Serial.println(s);
|
||||
if(s.indexOf("X") != -1){
|
||||
reset();
|
||||
}else if(s.indexOf("3") != -1){
|
||||
release();
|
||||
}
|
||||
else{
|
||||
|
||||
if(sscanf(s.c_str(),"%d %d %d",&x,&y,&z) == 3){
|
||||
|
||||
Serial.print("x: "); Serial.print(x); Serial.print("\n");
|
||||
Serial.print("y: "); Serial.print(y); Serial.print("\n");
|
||||
Serial.print("z: "); Serial.print(z); Serial.print("\n");
|
||||
|
||||
if(InverseK.solve(x, y, z, a0, a1, a2, a3)) {
|
||||
|
||||
s2.write(150);
|
||||
delay(1000);
|
||||
|
||||
/*InverseK.solve(x* 0.85, y*0.85, z ,temp1, temp2, temp3 ,temp4);
|
||||
s6.write(a2b(-temp1));
|
||||
delay(1000);
|
||||
s5.write(a2b(-temp2));
|
||||
delay(500);
|
||||
s4.write(a2b(temp3));
|
||||
delay(500);
|
||||
s3.write(a2b(-temp4));
|
||||
delay(1000);*/
|
||||
|
||||
Serial.println(a2b(a0));
|
||||
Serial.println(a2b(a1));
|
||||
Serial.println(a2b(a2));
|
||||
Serial.println(a2b(a3));
|
||||
|
||||
|
||||
|
||||
|
||||
/*s6.write(a2b(-a0));
|
||||
delay(1000);
|
||||
s5.write(a2b(-a1));
|
||||
delay(500);
|
||||
s4.write(a2b(a2));
|
||||
delay(500);
|
||||
s3.write(a2b(-a3));
|
||||
delay(1000);*/
|
||||
|
||||
moveToPos(a2b(-a0), a2b(-a1), a2b(a2), a2b(-a3));
|
||||
delay(2000);
|
||||
|
||||
//Nach 2 Sekunden greift der Arm
|
||||
s2.write(0);
|
||||
delay(2000);
|
||||
|
||||
pullUp();
|
||||
|
||||
delay(1000);
|
||||
} else {
|
||||
Serial.println("No solution found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
float b2a(float b){
|
||||
return b / 180.0 * PI - HALF_PI;
|
||||
}
|
||||
|
||||
// Quick conversion from radians to the Braccio angle system
|
||||
float a2b(float a) {
|
||||
return (a + HALF_PI) * 180 / PI;
|
||||
}
|
||||
|
||||
long convertServo(long l){
|
||||
|
||||
long ret = map(l, -180, -80 , 180 , 80);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,61 @@
|
||||
import datetime
|
||||
from ultralytics import YOLO
|
||||
import cv2 as cv
|
||||
|
||||
|
||||
#define some constants
|
||||
CONFIDENCE_THRESHOLD = 0.8
|
||||
GREEN = (0, 255,0)
|
||||
|
||||
#initialize the video capture object
|
||||
video_cap = cv.VideoCapture(0)
|
||||
|
||||
#load the pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
|
||||
while True:
|
||||
#start time to compute the fps
|
||||
start = datetime.datetime.now()
|
||||
ret, frame = video_cap.read()
|
||||
|
||||
#if there are no more frames to process, break out of the loop
|
||||
if not ret:
|
||||
break
|
||||
|
||||
#run the YOLO model on the frame
|
||||
detections = model(frame)[0]
|
||||
|
||||
#loop over the detections
|
||||
for data in detections.boxes.data.tolist():
|
||||
#extract the confidence (i.e., probability) associated with the detection
|
||||
confidence = data[4]
|
||||
|
||||
#filter out weak detections by ensuring the
|
||||
#confidence is grater than the minimum confidence
|
||||
if float(confidence) < CONFIDENCE_THRESHOLD:
|
||||
continue
|
||||
|
||||
#if the confidence is greater than the minimum confidence,
|
||||
#draw the bounding box on the frame
|
||||
xmin, ymin, xmax, ymax = int(data[0]), int(data[1]), int(data[2]), int(data[3])
|
||||
cv.rectangle(frame, (xmin, ymin), (xmax, ymax), GREEN, 2)
|
||||
|
||||
#end of time to compute the fps
|
||||
end = datetime.datetime.now()
|
||||
#show the time it took to process 1 frame
|
||||
total = (end - start).total_seconds()
|
||||
print(f"Time to process 1 frame: {total * 1000:.0f} milliseconds")
|
||||
|
||||
#calculate the frame per second and draw it on the frame
|
||||
fps = f"FPS: {1 / total:.2f}"
|
||||
cv.putText(frame, fps, (50,50), cv.FONT_HERSHEY_SIMPLEX, 2, (0, 0, 255), 8)
|
||||
|
||||
#show the frame to our screen
|
||||
cv.imshow("Frame", frame)
|
||||
if cv.waitKey(1) == 'e':
|
||||
break
|
||||
|
||||
video_cap.release()
|
||||
cv.destroyAllWindows()
|
||||
|
||||
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
#include <InverseK.h>
|
||||
#include <Servo.h>
|
||||
|
||||
#define SERVOVELOCITY 1
|
||||
#define LEDPIN 13
|
||||
|
||||
//https://github.com/cgxeiji/CGx-InverseK
|
||||
|
||||
Servo s6,s5,s4,s3,s2;
|
||||
int x,y,z;
|
||||
String s;
|
||||
|
||||
float a0, a1, a2, a3, temp1, temp2, temp3, temp4;
|
||||
int servo6Pos, servo5Pos, servo4Pos, servo3Pos, servo6Vel, servo5Vel,servo4Vel,servo3Vel;
|
||||
|
||||
void moveToPos(int servo6End, int servo5End, int servo4End, int servo3End){
|
||||
|
||||
servo6Vel = servo6Pos > servo6End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
servo5Vel = servo5Pos > servo5End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
servo4Vel = servo4Pos > servo4End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
servo3Vel = servo3Pos > servo3End ? SERVOVELOCITY * (-1) : SERVOVELOCITY;
|
||||
|
||||
bool b6 = false, b5 = false, b4 = false, b3 = false;
|
||||
|
||||
while(true){
|
||||
|
||||
if(servo6Pos != servo6End){
|
||||
servo6Pos+=servo6Vel;
|
||||
s6.write(servo6Pos);
|
||||
//Serial.println("S6: "+ String(servo6Pos) + " - " + String(servo6End));
|
||||
}else b6 = true;
|
||||
|
||||
if(servo5Pos != servo5End){
|
||||
servo5Pos+=servo5Vel;
|
||||
s5.write(servo5Pos);
|
||||
//Serial.println("S5: "+ String(servo5Pos) + " - " + String(servo5End));
|
||||
} else b5 = true;
|
||||
|
||||
if(servo4Pos != servo4End){
|
||||
servo4Pos+=servo4Vel;
|
||||
s4.write(servo4Pos);
|
||||
//Serial.println("S4: "+ String(servo4Pos) + " - " + String(servo4End));
|
||||
} else b4 = true;
|
||||
|
||||
|
||||
delay(50);
|
||||
|
||||
if(b6 && b5 && b4){
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
while(true){
|
||||
if(servo3Pos != servo3End){
|
||||
servo3Pos+=servo3Vel;
|
||||
s3.write(servo3Pos);
|
||||
// Serial.println("S3: "+ String(servo3Pos) + " - " + String(servo3Pos));
|
||||
} else b3 = true;
|
||||
|
||||
delay(50);
|
||||
|
||||
if(b3){
|
||||
|
||||
|
||||
Serial.println("Moved!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void setup() {
|
||||
//9600 GEHT NICHT! IN DIE DOKU
|
||||
Serial.begin(115200);
|
||||
//Serial.setTimeout(1);
|
||||
s6.attach(6);
|
||||
s5.attach(5);
|
||||
s4.attach(4);
|
||||
s3.attach(3);
|
||||
s2.attach(2);
|
||||
|
||||
|
||||
s6.write(10);
|
||||
servo6Pos = 10;
|
||||
s5.write(170);
|
||||
servo5Pos = 170;
|
||||
s4.write(90);
|
||||
servo4Pos = 90;
|
||||
s3.write(10);
|
||||
servo3Pos = 10;
|
||||
s2.write(90);
|
||||
|
||||
pinMode(LEDPIN, OUTPUT);
|
||||
|
||||
//Definition der Bestandteile des Arms für die Inverse Kinematik
|
||||
Link base, upperarm, forearm, hand;
|
||||
|
||||
base.init(20, b2a(0), b2a(180.0));
|
||||
upperarm.init(122, b2a(0.0), b2a(180.0));
|
||||
forearm.init(80, b2a(0.0), b2a(180.0));
|
||||
hand.init(170, b2a(0.0), b2a(180.0));
|
||||
|
||||
InverseK.attach(base, upperarm, forearm, hand);
|
||||
|
||||
|
||||
|
||||
String s;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void errorLED(){
|
||||
|
||||
digitalWrite(LEDPIN, HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(LEDPIN, LOW);
|
||||
delay(1000);
|
||||
digitalWrite(LEDPIN, HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(LEDPIN, LOW);
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
void loop() {
|
||||
if(Serial.available()){
|
||||
// put your main code here, to run repeatedly:
|
||||
s = Serial.readString();
|
||||
if(sscanf(s.c_str(),"%d %d %d",&x,&y,&z) == 3){
|
||||
digitalWrite(LEDPIN, HIGH);
|
||||
|
||||
delay(3000);
|
||||
if(x == 0 && y == 0 && z == 0){
|
||||
moveToPos(90, 90, 10, 170);
|
||||
s2.write(90);
|
||||
}
|
||||
else if(x == 1 && y == 1 && z == 1){
|
||||
moveToPos(10,170,90, 10);
|
||||
///s2.write(90);
|
||||
}
|
||||
else if(x == -1 && y == -1 && z == -1){
|
||||
moveToPos(90, 130, 50, 130);
|
||||
delay(3000);
|
||||
s2.write(90);
|
||||
delay(1000);
|
||||
moveToPos(90, 130, 50, 70);
|
||||
delay(1000);
|
||||
moveToPos(10,170,90, 10);
|
||||
}else if(x == 90 && y == 90 && z == 90){
|
||||
moveToPos(90,90,90,90);
|
||||
s2.write(90);
|
||||
}else{
|
||||
|
||||
//Serial.print("x: "); Serial.print(x); Serial.print("\n");
|
||||
//Serial.print("y: "); Serial.print(y); Serial.print("\n");
|
||||
//Serial.print("z: "); Serial.print(z); Serial.print("\n");
|
||||
|
||||
if(InverseK.solve(x, y, z, a0, a1, a2, a3)) {
|
||||
//Serial.println(a2b(a0));
|
||||
//Serial.println(a2b(a1));
|
||||
// Serial.println(a2b(a2));
|
||||
// Serial.println(a2b(a3));
|
||||
moveToPos(a2b(-a0),a2b(-a1),a2b(a2),a2b(-a3));
|
||||
//s6.write(a2b(-a0));
|
||||
//s5.write(a2b(-a1));
|
||||
//s4.write(a2b(a2));
|
||||
//s3.write(a2b(-a3));
|
||||
delay(1000);
|
||||
s2.write(0);
|
||||
delay(2000);
|
||||
moveToPos(90,90,40, 170);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
errorLED();
|
||||
}
|
||||
|
||||
digitalWrite(LEDPIN, LOW);
|
||||
}
|
||||
}
|
||||
float b2a(float b){
|
||||
return b / 180.0 * PI - HALF_PI;
|
||||
}
|
||||
|
||||
// Quick conversion from radians to the Braccio angle system
|
||||
float a2b(float a) {
|
||||
return (a + HALF_PI) * 180 / PI;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable → Regular
+47
-69
@@ -31,117 +31,95 @@ ARUCO_DICT = {
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11
|
||||
}
|
||||
|
||||
|
||||
def talker():
|
||||
# construct the argument parser and parse the argument
|
||||
#construct the argument parser and parse the argument
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
default="DICT_ARUCO_ORIGINAL",
|
||||
help="type of ArCUo tag to detect",
|
||||
)
|
||||
ap.add_argument("-t", "--type", type=str, default="DICT_7X7_50", help="type of ArCUo tag to detect")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
# verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
#verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
# load the ArUCo dictionary and grab hte ArUCo parameters
|
||||
|
||||
#load the ArUCo dictionary and grab hte ArUCo parameters
|
||||
print("[INFO] detecting '{}' tags...".format(args["type"]))
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
arucoParams = cv.aruco.DetectorParameters()
|
||||
detector = cv.aruco.ArucoDetector(arucoDict, arucoParams)
|
||||
|
||||
# initialize the video stream and allow the camera sensor to warm up
|
||||
#initialize the video stream and allow the camera sensor to warm up
|
||||
print("[INFO] starting video stream...")
|
||||
vs = VideoStream(src=0).start()
|
||||
time.sleep(1.0)
|
||||
|
||||
pub = rospy.Publisher("turtle1/cmd_vel", Twist, queue_size=10)
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
rate = rospy.Rate(10) #
|
||||
time.sleep(2.0)
|
||||
|
||||
pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=10)
|
||||
rospy.init_node('turtle_control', anonymous=True)
|
||||
rate = rospy.Rate(10) #
|
||||
t = Twist()
|
||||
while not rospy.is_shutdown():
|
||||
# grab the frame from the threaded video and resize it
|
||||
# to have a maximum width of 1000 pixels
|
||||
#grab the frame from the threaded video and resize it
|
||||
#to have a maximum width of 1000 pixels
|
||||
frame = vs.read()
|
||||
frame = imutils.resize(frame)
|
||||
rate.sleep()
|
||||
|
||||
# detect ArUCo markers in the input frame
|
||||
frame = imutils.resize(frame, width=1000)
|
||||
|
||||
#detect ArUCo markers in the input frame
|
||||
(corners, ids, rejected) = detector.detectMarkers(frame)
|
||||
print(ids)
|
||||
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
|
||||
#verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
# flatten the ArUCo IDs list
|
||||
#flatten the ArUCo IDs list
|
||||
ids = ids.flatten()
|
||||
if [1] in ids:
|
||||
t.angular.z = 0.1
|
||||
t.linear.x = 0.5
|
||||
pub.publish(t)
|
||||
# loop over the detected ArUCo corners
|
||||
for markerCorner, markerID in zip(corners, ids):
|
||||
# extract the marker corners (Which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
corners = markerCorner.reshape((4, 2))
|
||||
rate.sleep()
|
||||
#loop over the detected ArUCo corners
|
||||
for(markerCorner, markerID) in zip(corners, ids):
|
||||
#extract the marker corners (Which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
corners = markerCorner.reshape((4,2))
|
||||
(topLeft, topRight, bottomRight, bottomLeft) = corners
|
||||
# convert each of the (x,y)-coordinates pairs to integers
|
||||
|
||||
#convert each of the (x,y)-coordinates pairs to integers
|
||||
topRight = (int(topRight[0]), int(topRight[1]))
|
||||
bottomRight = (int(bottomRight[0]), int(bottomRight[1]))
|
||||
bottomLeft = (int(bottomLeft[0]), int(bottomLeft[1]))
|
||||
topLeft = (int(topLeft[0]), int(topLeft[1]))
|
||||
|
||||
# draw the bounding box of the ArUCo detection
|
||||
cv.line(frame, topLeft, topRight, (0, 255, 0), 2)
|
||||
cv.line(frame, topRight, bottomRight, (0, 255, 0), 2)
|
||||
cv.line(frame, bottomRight, bottomLeft, (0, 255, 0), 2)
|
||||
cv.line(frame, bottomLeft, topLeft, (0, 255, 0), 2)
|
||||
|
||||
# compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
|
||||
#draw the bounding box of the ArUCo detection
|
||||
cv.line(frame, topLeft, topRight, (0,255,0), 2)
|
||||
cv.line(frame, topRight, bottomRight, (0,255,0), 2)
|
||||
cv.line(frame, bottomRight, bottomLeft, (0,255,0), 2)
|
||||
cv.line(frame, bottomLeft, topLeft, (0,255,0), 2)
|
||||
|
||||
#compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
cX = int((topLeft[0] + bottomRight[0]) / 2.0)
|
||||
cY = int((topLeft[1] + bottomRight[1]) / 2.0)
|
||||
cv.circle(frame, (cX, cY), 4, (0, 0, 255), -1)
|
||||
|
||||
# draw the ArUCo marker ID on the frame
|
||||
cv.putText(
|
||||
frame,
|
||||
str(markerID),
|
||||
(topLeft[0], topLeft[1] - 15),
|
||||
cv.FONT_HERSHEY_SIMPLEX,
|
||||
0.5,
|
||||
(0, 255, 0),
|
||||
2,
|
||||
)
|
||||
idString = "IDs:" + str(ids)
|
||||
cv.putText(
|
||||
frame,
|
||||
idString,
|
||||
(50, 50),
|
||||
cv.FONT_HERSHEY_SIMPLEX,
|
||||
1,
|
||||
(40, 10, 100),
|
||||
3,
|
||||
cv.LINE_AA,
|
||||
)
|
||||
|
||||
# show the output frame
|
||||
cv.circle(frame, (cX,cY), 4, (0,0,255), -1)
|
||||
|
||||
#draw the ArUCo marker ID on the frame
|
||||
cv.putText(frame, str(markerID), (topLeft[0], topLeft[1]-15), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 2)
|
||||
|
||||
#show the output frame
|
||||
cv.imshow("Frame", frame)
|
||||
key = cv.waitKey(1) & 0xFF
|
||||
|
||||
# if the 'q' key was pressed, break from the loop
|
||||
|
||||
#if the 'q' key was pressed, break from the loop
|
||||
if key == ord("q"):
|
||||
break
|
||||
# do a bit of cleanup
|
||||
|
||||
#do a bit of cleanup
|
||||
cv.destroyAllWindows()
|
||||
vs.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
@@ -0,0 +1,97 @@
|
||||
import argparse
|
||||
import imutils
|
||||
import cv2 as cv
|
||||
import sys
|
||||
|
||||
#construct the argument parser and parse the arguments
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("-i", "--image", required=True, help="path to imput image containing ArUCo tag")
|
||||
ap.add_argument("-t", "--type", type=str, default="DICT_ARUCO_ORIGINAL", help="type of ArUCo tag to detect")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
# define names of each possible ArUco tag OpenCV supports
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11
|
||||
}
|
||||
|
||||
#load the input image from disk and resize it
|
||||
print("[INFO] loading image...")
|
||||
image = cv.imread(args["image"])
|
||||
#image = imutils.resize(image, width=600)
|
||||
|
||||
#verfiy that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
#load the ArUCo dictionary, grab the ArUCo parameters, and detect the markers
|
||||
print("[INFO] detecting '{}' tags...".format(args["type"]))
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
arucoParams = cv.aruco.DetectorParameters()
|
||||
detector = cv.aruco.ArucoDetector(arucoDict, arucoParams)
|
||||
(corners, ids, rejected) = detector.detectMarkers(image)
|
||||
|
||||
#verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
#flattens the ArUCo IDs list
|
||||
ids = ids.flatten()
|
||||
|
||||
#loop over the detected ArUCo corners
|
||||
for (markerCorner, markerID) in zip(corners, ids):
|
||||
#extract the marker corners (which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
if markerID != 1:
|
||||
corners = markerCorner.reshape((4,2))
|
||||
(topLeft, topRight, bottomRight, bottomLeft) = corners
|
||||
|
||||
#convert each of the (x,y)-coordinates paris to integers
|
||||
topRight = (int(topRight[0]), int(topRight[1]))
|
||||
bottomRight = (int(bottomRight[0]), int(bottomRight[1]))
|
||||
bottomLeft = (int(bottomLeft[0]), int(bottomLeft[1]))
|
||||
topLeft = (int(topLeft[0]), int(topLeft[1]))
|
||||
number_of_operations = 0
|
||||
for x in range(topLeft[0], topRight[0]+1):
|
||||
for y in range(topLeft[1], bottomLeft[1]+1):
|
||||
number_of_operations += 1
|
||||
for y in range(topLeft[1], topRight[1]+1):
|
||||
for x in range(topLeft[0], bottomLeft[0]+1):
|
||||
number_of_operations += 1
|
||||
print(number_of_operations)
|
||||
#draw the bounding box of the ArUCo detection
|
||||
cv.line(image, topLeft, topRight, (0,255,0), 2)
|
||||
cv.line(image, topRight, bottomRight, (0,255,0), 2)
|
||||
cv.line(image, bottomRight, bottomLeft, (0,255,0), 2)
|
||||
cv.line(image, bottomLeft, topLeft, (0,255,0), 2)
|
||||
|
||||
#compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
cX = int((topLeft[0] + bottomRight[0]) / 2.0)
|
||||
cY = int((topLeft[1] + bottomRight[1]) / 2.0)
|
||||
cv.circle(image, (cX, cY), 4, (0,0,255), -1)
|
||||
|
||||
#draw the ArUCo marker ID in the image
|
||||
cv.putText(image, str(markerID), (topLeft[0], topLeft[1]-15), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 2)
|
||||
print("[INFO] ArUCo marker ID: {}".format(markerID))
|
||||
|
||||
#show the output image
|
||||
cv.imshow("Image", image)
|
||||
cv.waitKey(0)
|
||||
cv.destroyAllWindows()
|
||||
@@ -0,0 +1,105 @@
|
||||
from imutils.video import VideoStream
|
||||
import argparse
|
||||
import imutils
|
||||
import time
|
||||
import cv2 as cv
|
||||
import sys
|
||||
|
||||
#construct the argument parser and parse the argument
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("-t", "--type", type=str, default="DICT_ARCUO_ORIGINAL", help="type of ArCUo tag to detect")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
# define names of each possible ArUco tag OpenCV supports
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11
|
||||
}
|
||||
|
||||
#verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
#load the ArUCo dictionary and grab hte ArUCo parameters
|
||||
print("[INFO] detecting '{}' tags...".format(args["type"]))
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
arucoParams = cv.aruco.DetectorParameters()
|
||||
detector = cv.aruco.ArucoDetector(arucoDict, arucoParams)
|
||||
|
||||
#initialize the video stream and allow the camera sensor to warm up
|
||||
print("[INFO] starting video stream...")
|
||||
vs = VideoStream(src=0).start()
|
||||
time.sleep(2.0)
|
||||
|
||||
#loop over frames from the video stream
|
||||
while True:
|
||||
#grab the frame from the threaded video and resize it
|
||||
#to have a maximum width of 1000 pixels
|
||||
frame = vs.read()
|
||||
frame = imutils.resize(frame, width=1000)
|
||||
|
||||
#detect ArUCo markers in the input frame
|
||||
(corners, ids, rejected) = detector.detectMarkers(frame)
|
||||
|
||||
#verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
#flatten the ArUCo IDs list
|
||||
ids = ids.flatten()
|
||||
|
||||
#loop over the detected ArUCo corners
|
||||
for(markerCorner, markerID) in zip(corners, ids):
|
||||
#extract the marker corners (Which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
corners = markerCorner.reshape((4,2))
|
||||
(topLeft, topRight, bottomRight, bottomLeft) = corners
|
||||
|
||||
#convert each of the (x,y)-coordinates pairs to integers
|
||||
topRight = (int(topRight[0]), int(topRight[1]))
|
||||
bottomRight = (int(bottomRight[0]), int(bottomRight[1]))
|
||||
bottomLeft = (int(bottomLeft[0]), int(bottomLeft[1]))
|
||||
topLeft = (int(topLeft[0]), int(topLeft[1]))
|
||||
|
||||
#draw the bounding box of the ArUCo detection
|
||||
cv.line(frame, topLeft, topRight, (0,255,0), 2)
|
||||
cv.line(frame, topRight, bottomRight, (0,255,0), 2)
|
||||
cv.line(frame, bottomRight, bottomLeft, (0,255,0), 2)
|
||||
cv.line(frame, bottomLeft, topLeft, (0,255,0), 2)
|
||||
|
||||
#compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
cX = int((topLeft[0] + bottomRight[0]) / 2.0)
|
||||
cY = int((topLeft[1] + bottomRight[1]) / 2.0)
|
||||
cv.circle(frame, (cX,cY), 4, (0,0,255), -1)
|
||||
|
||||
#draw the ArUCo marker ID on the frame
|
||||
cv.putText(frame, str(markerID), (topLeft[0], topLeft[1]-15), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 2)
|
||||
|
||||
#show the output frame
|
||||
cv.imshow("Frame", frame)
|
||||
key = cv.waitKey(1) & 0xFF
|
||||
|
||||
#if the 'q' key was pressed, break from the loop
|
||||
if key == ord("q"):
|
||||
break
|
||||
|
||||
#do a bit of cleanup
|
||||
cv.destroyAllWindows()
|
||||
vs.stop()
|
||||
@@ -0,0 +1,55 @@
|
||||
import numpy as np
|
||||
import argparse
|
||||
import cv2 as cv
|
||||
import sys
|
||||
|
||||
#construct the argument parser and parse them
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("-o", "--output", required=True, help="path to output image containing ArUCo tag")
|
||||
ap.add_argument("-i", "--id", type=int, required=True, help="ID of AruCo tag to generate")
|
||||
ap.add_argument("-t", "--type", type=str, default="DICT_ARCUCO_ORIGINAL", help="type of ArUCo tag to generate")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
#define names of each possible ArUco tag OpenCV supports
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11
|
||||
}
|
||||
|
||||
#verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
#load the ArUCo dictionary
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
|
||||
#allocate memory for the output ArUCo tag and then draw the ArUCo tag on the output image
|
||||
print("[INFO] generatin ArUCo tag type '{}' with ID '{}'".format(args["type"], args["id"]))
|
||||
tag = np.zeros((300, 300, 1), dtype="uint8")
|
||||
cv.aruco.generateImageMarker(arucoDict, args["id"], 300, tag, 1)
|
||||
|
||||
#write the generated ArUCo tag to disk and then display it to our screen
|
||||
cv.imwrite(args["output"], tag)
|
||||
cv.imshow("ArUCo tag", tag)
|
||||
cv.waitKey(0)
|
||||
cv.destroyAllWindows()
|
||||
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env python3
|
||||
# license removed for brevity
|
||||
import rospy
|
||||
from geometry_msgs.msg import Twist
|
||||
from imutils.video import VideoStream
|
||||
import argparse
|
||||
import imutils
|
||||
import time
|
||||
import cv2 as cv
|
||||
import sys
|
||||
|
||||
# define names of each possible ArUco tag OpenCV supports
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11
|
||||
}
|
||||
|
||||
def talker():
|
||||
#construct the argument parser and parse the argument
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("-t", "--type", type=str, default="DICT_7X7_50", help="type of ArCUo tag to detect")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
#verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
#load the ArUCo dictionary and grab hte ArUCo parameters
|
||||
print("[INFO] detecting '{}' tags...".format(args["type"]))
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
arucoParams = cv.aruco.DetectorParameters()
|
||||
detector = cv.aruco.ArucoDetector(arucoDict, arucoParams)
|
||||
|
||||
#initialize the video stream and allow the camera sensor to warm up
|
||||
print("[INFO] starting video stream...")
|
||||
vs = VideoStream(src=0).start()
|
||||
time.sleep(2.0)
|
||||
|
||||
pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=10)
|
||||
rospy.init_node('turtle_control', anonymous=True)
|
||||
rate = rospy.Rate(10) #
|
||||
t = Twist()
|
||||
while not rospy.is_shutdown():
|
||||
#grab the frame from the threaded video and resize it
|
||||
#to have a maximum width of 1000 pixels
|
||||
frame = vs.read()
|
||||
frame = imutils.resize(frame, width=1000)
|
||||
|
||||
#detect ArUCo markers in the input frame
|
||||
(corners, ids, rejected) = detector.detectMarkers(frame)
|
||||
print(ids)
|
||||
|
||||
|
||||
#verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
#flatten the ArUCo IDs list
|
||||
ids = ids.flatten()
|
||||
if [1] in ids:
|
||||
t.angular.z = 0.1
|
||||
t.linear.x = 0.5
|
||||
pub.publish(t)
|
||||
rate.sleep()
|
||||
#loop over the detected ArUCo corners
|
||||
for(markerCorner, markerID) in zip(corners, ids):
|
||||
#extract the marker corners (Which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
corners = markerCorner.reshape((4,2))
|
||||
(topLeft, topRight, bottomRight, bottomLeft) = corners
|
||||
|
||||
#convert each of the (x,y)-coordinates pairs to integers
|
||||
topRight = (int(topRight[0]), int(topRight[1]))
|
||||
bottomRight = (int(bottomRight[0]), int(bottomRight[1]))
|
||||
bottomLeft = (int(bottomLeft[0]), int(bottomLeft[1]))
|
||||
topLeft = (int(topLeft[0]), int(topLeft[1]))
|
||||
|
||||
#draw the bounding box of the ArUCo detection
|
||||
cv.line(frame, topLeft, topRight, (0,255,0), 2)
|
||||
cv.line(frame, topRight, bottomRight, (0,255,0), 2)
|
||||
cv.line(frame, bottomRight, bottomLeft, (0,255,0), 2)
|
||||
cv.line(frame, bottomLeft, topLeft, (0,255,0), 2)
|
||||
|
||||
#compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
cX = int((topLeft[0] + bottomRight[0]) / 2.0)
|
||||
cY = int((topLeft[1] + bottomRight[1]) / 2.0)
|
||||
cv.circle(frame, (cX,cY), 4, (0,0,255), -1)
|
||||
|
||||
#draw the ArUCo marker ID on the frame
|
||||
cv.putText(frame, str(markerID), (topLeft[0], topLeft[1]-15), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 2)
|
||||
|
||||
#show the output frame
|
||||
cv.imshow("Frame", frame)
|
||||
key = cv.waitKey(1) & 0xFF
|
||||
|
||||
#if the 'q' key was pressed, break from the loop
|
||||
if key == ord("q"):
|
||||
break
|
||||
|
||||
#do a bit of cleanup
|
||||
cv.destroyAllWindows()
|
||||
vs.stop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
+295
@@ -0,0 +1,295 @@
|
||||
<mxfile host="app.diagrams.net" modified="2024-02-21T17:23:41.588Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0" etag="X6EpYg_yTce0Boi178gv" version="23.1.5" type="device">
|
||||
<diagram name="Seite-1" id="oQn1qHlHMxwWOluxqzLg">
|
||||
<mxGraphModel dx="1977" dy="646" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-1" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="150" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-2" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="150" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-3" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="150" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-4" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-5" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-6" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-7" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-8" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-9" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-10" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-11" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-12" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-13" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-14" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-15" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-16" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-17" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-18" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-19" value="" style="endArrow=none;html=1;rounded=0;entryX=0.621;entryY=0.721;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-28" target="w0R4334MU0p3O2GxfyLS-2">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="260" as="sourcePoint" />
|
||||
<mxPoint x="360" y="210" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-20" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-8" target="w0R4334MU0p3O2GxfyLS-5">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="260" as="sourcePoint" />
|
||||
<mxPoint x="360" y="210" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-21" value="" style="endArrow=none;html=1;rounded=0;entryX=0.936;entryY=0.493;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-11" target="w0R4334MU0p3O2GxfyLS-8">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="260" as="sourcePoint" />
|
||||
<mxPoint x="360" y="210" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-22" value="" style="endArrow=none;html=1;rounded=0;exitX=0.507;exitY=0.321;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-14" target="w0R4334MU0p3O2GxfyLS-11">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="260" as="sourcePoint" />
|
||||
<mxPoint x="360" y="210" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-23" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-17" target="w0R4334MU0p3O2GxfyLS-14">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="260" as="sourcePoint" />
|
||||
<mxPoint x="360" y="210" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-24" value="" style="endArrow=none;html=1;rounded=0;entryX=0.364;entryY=0.75;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-18" target="w0R4334MU0p3O2GxfyLS-3">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="260" as="sourcePoint" />
|
||||
<mxPoint x="360" y="210" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-29" value="" style="endArrow=none;html=1;rounded=0;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-5" target="w0R4334MU0p3O2GxfyLS-28">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="160" y="200" as="sourcePoint" />
|
||||
<mxPoint x="160" y="160" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-28" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="150" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-30" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="150" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-31" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-32" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-33" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-34" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-35" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-36" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-37" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-38" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-39" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-40" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-41" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-42" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-43" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="190" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-44" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-45" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-46" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="30" y="150" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-47" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="30" y="190" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-48" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="30" y="230" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-49" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="30" y="270" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-50" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="30" y="310" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-51" value="" style="shape=waypoint;sketch=0;fillStyle=solid;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="30" y="350" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-53" value="" style="endArrow=none;html=1;rounded=0;entryX=0.279;entryY=0.55;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-46" target="w0R4334MU0p3O2GxfyLS-30">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="280" as="sourcePoint" />
|
||||
<mxPoint x="360" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-54" value="" style="endArrow=none;html=1;rounded=0;entryX=0.279;entryY=0.55;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="40" y="199.71" as="sourcePoint" />
|
||||
<mxPoint x="120" y="199.71" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-60" value="" style="endArrow=none;html=1;rounded=0;exitX=0.879;exitY=0.921;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.993;entryY=0.693;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-48" target="w0R4334MU0p3O2GxfyLS-36">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="280" as="sourcePoint" />
|
||||
<mxPoint x="360" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-61" value="" style="endArrow=none;html=1;rounded=0;entryX=0.993;entryY=0.864;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-49" target="w0R4334MU0p3O2GxfyLS-39">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="280" as="sourcePoint" />
|
||||
<mxPoint x="360" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-62" value="" style="endArrow=none;html=1;rounded=0;exitX=0.993;exitY=0.721;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-50" target="w0R4334MU0p3O2GxfyLS-42">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="280" as="sourcePoint" />
|
||||
<mxPoint x="360" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-63" value="" style="endArrow=none;html=1;rounded=0;exitX=0.193;exitY=1.15;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.964;entryY=0.293;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-51" target="w0R4334MU0p3O2GxfyLS-45">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="310" y="280" as="sourcePoint" />
|
||||
<mxPoint x="360" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-64" value="" style="endArrow=none;html=1;rounded=0;exitX=0.65;exitY=0.979;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-43" target="w0R4334MU0p3O2GxfyLS-65">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="290" y="290" as="sourcePoint" />
|
||||
<mxPoint x="200" y="520" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-65" value="Arduino Common Ground" style="pointerEvents=1;verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;html=1;verticalAlign=top;shape=mxgraph.electrical.signal_sources.signal_ground;" vertex="1" parent="1">
|
||||
<mxGeometry x="177.5" y="520" width="45" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-70" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.58;exitY=0.135;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.9;entryY=0.49;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-66" target="w0R4334MU0p3O2GxfyLS-28">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="420" y="160" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="621" y="120" />
|
||||
<mxPoint x="160" y="120" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-66" value="5V DC Source" style="pointerEvents=1;verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;html=1;verticalAlign=top;shape=mxgraph.electrical.signal_sources.dc_source_1;rotation=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="580" y="235" width="70" height="75" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-71" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.58;exitY=0.935;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="w0R4334MU0p3O2GxfyLS-66">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="290" y="340" as="sourcePoint" />
|
||||
<mxPoint x="200" y="360" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="620" y="360" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-72" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="145" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-74" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="185" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-75" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="225" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-76" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="265" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-77" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="305" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-78" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="110" y="345" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-79" value="Servo 6" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="210" y="145" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-80" value="Servo 5" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="210" y="185" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-81" value="Servo 4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="210" y="225" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-82" value="Servo 3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="210" y="265" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-83" value="Servo 2" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="210" y="305" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-84" value="Servo 1<br>Currently Unused" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="130" y="390" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-85" value="Servo 6 Data Pin" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="-30" y="145" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-86" value="Servo 5 Data Pin" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="-30" y="185" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-87" value="Servo 4 Data Pin" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="-30" y="225" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-88" value="Servo 3 Data Pin" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="-30" y="265" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-89" value="Servo 2 Data Pin" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="-30" y="305" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="w0R4334MU0p3O2GxfyLS-90" value="Servo 1 Data Pin" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="-30" y="345" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
@@ -1,16 +0,0 @@
|
||||
Grundlegende Anleitung:
|
||||
|
||||
|
||||
cd catkin_ws
|
||||
source ./devel/setup.bash
|
||||
roscore
|
||||
|
||||
roslaunch turtlebot_bringup minimal.launch
|
||||
rosrun turtle_control turtle_control_node
|
||||
==============
|
||||
Docker anleitung:
|
||||
1. Nur Debian/Ubuntu(amd64) unterstützt.
|
||||
Ubuntu https://docs.docker.com/engine/install/ubuntu/
|
||||
Debain https://docs.docker.com/engine/install/debian/
|
||||
2. Diesen git branch clonen/herunterladen
|
||||
3. Im Verzeichnis Docker ein terminal öffnen und "bash setupDocker.sh" ausführen
|
||||
@@ -1,52 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Taken from here:http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
|
||||
# USE: chmod +x
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
|
||||
|
||||
class image_converter:
|
||||
def __init__(self):
|
||||
self.image_pub = rospy.Publisher("image_topic_2", Image)
|
||||
|
||||
self.bridge = CvBridge()
|
||||
self.image_sub = rospy.Subscriber("image_topic", Image, self.callback)
|
||||
|
||||
def callback(self, data):
|
||||
try:
|
||||
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(rows, cols, channels) = cv_image.shape
|
||||
if cols > 60 and rows > 60:
|
||||
cv2.circle(cv_image, (50, 50), 10, 255)
|
||||
|
||||
cv2.imshow("Image window", cv_image)
|
||||
cv2.waitKey(3)
|
||||
|
||||
try:
|
||||
self.image_pub.publish(self.bridge.cv2_to_imgmsg(cv_image, "bgr8"))
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def main(args):
|
||||
ic = image_converter()
|
||||
rospy.init_node("image_converter", anonymous=True)
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
-33314
File diff suppressed because it is too large
Load Diff
@@ -1,148 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# license removed for brevity
|
||||
import rospy
|
||||
from geometry_msgs.msg import Twist
|
||||
from imutils.video import VideoStream
|
||||
import argparse
|
||||
import imutils
|
||||
import time
|
||||
import cv2 as cv
|
||||
import sys
|
||||
|
||||
# define names of each possible ArUco tag OpenCV supports
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11,
|
||||
}
|
||||
|
||||
|
||||
def talker():
|
||||
# construct the argument parser and parse the argument
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
default="DICT_ARUCO_ORIGINAL",
|
||||
help="type of ArCUo tag to detect",
|
||||
)
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
# verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
# load the ArUCo dictionary and grab hte ArUCo parameters
|
||||
print("[INFO] detecting '{}' tags...".format(args["type"]))
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
arucoParams = cv.aruco.DetectorParameters_create()
|
||||
# detector = cv.aruco.ArucoDetector(arucoDict, arucoParams)
|
||||
|
||||
# initialize the video stream and allow the camera sensor to warm up
|
||||
print("[INFO] starting video stream...")
|
||||
vs = VideoStream(src=0).start()
|
||||
time.sleep(2.0)
|
||||
|
||||
pub = rospy.Publisher("turtle1/cmd_vel", Twist, queue_size=10)
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
rate = rospy.Rate(10) #
|
||||
t = Twist()
|
||||
self.storedMarkerPoints = []
|
||||
while not rospy.is_shutdown():
|
||||
# grab the frame from the threaded video and resize it
|
||||
# to have a maximum width of 1000 pixels
|
||||
frame = vs.read()
|
||||
frame = imutils.resize(frame, width=1000)
|
||||
|
||||
# detect ArUCo markers in the input frame
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(
|
||||
frame, arucoDict, parameters=arucoParams
|
||||
)
|
||||
print(ids)
|
||||
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
# flatten the ArUCo IDs list
|
||||
ids = ids.flatten()
|
||||
if [1] in ids:
|
||||
t.angular.z = 0.1
|
||||
t.linear.x = 0.5
|
||||
pub.publish(t)
|
||||
rate.sleep()
|
||||
# loop over the detected ArUCo corners
|
||||
for markerCorner, markerID in zip(corners, ids):
|
||||
# extract the marker corners (Which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
corners = markerCorner.reshape((4, 2))
|
||||
(topLeft, topRight, bottomRight, bottomLeft) = corners
|
||||
# convert each of the (x,y)-coordinates pairs to integers
|
||||
topRight = (int(topRight[0]), int(topRight[1]))
|
||||
bottomRight = (int(bottomRight[0]), int(bottomRight[1]))
|
||||
bottomLeft = (int(bottomLeft[0]), int(bottomLeft[1]))
|
||||
topLeft = (int(topLeft[0]), int(topLeft[1]))
|
||||
|
||||
# draw the bounding box of the ArUCo detection
|
||||
cv.line(frame, topLeft, topRight, (0, 255, 0), 2)
|
||||
cv.line(frame, topRight, bottomRight, (0, 255, 0), 2)
|
||||
cv.line(frame, bottomRight, bottomLeft, (0, 255, 0), 2)
|
||||
cv.line(frame, bottomLeft, topLeft, (0, 255, 0), 2)
|
||||
|
||||
# compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
cX = int((topLeft[0] + bottomRight[0]) / 2.0)
|
||||
cY = int((topLeft[1] + bottomRight[1]) / 2.0)
|
||||
cv.circle(frame, (cX, cY), 4, (0, 0, 255), -1)
|
||||
|
||||
# draw the ArUCo marker ID on the frame
|
||||
cv.putText(
|
||||
frame,
|
||||
str(markerID),
|
||||
(topLeft[0], topLeft[1] - 15),
|
||||
cv.FONT_HERSHEY_SIMPLEX,
|
||||
0.5,
|
||||
(0, 255, 0),
|
||||
2,
|
||||
)
|
||||
storedSize = len(self.storedMarkerPoints)
|
||||
if storedSize < 20:
|
||||
self.storedMarkerPoints += (cX,cY)
|
||||
if storedSize > 5:
|
||||
self.storedMarkerPoints.pop(0)
|
||||
for x in self.storedMarkerPoints:
|
||||
cv.circle(frame, x, 4, (255, 0, 0), -1)
|
||||
|
||||
# show the output frame
|
||||
cv.imshow("Frame", frame)
|
||||
key = cv.waitKey(1) & 0xFF
|
||||
|
||||
# if the 'q' key was pressed, break from the loop
|
||||
if key == ord("q"):
|
||||
break
|
||||
# do a bit of cleanup
|
||||
cv.destroyAllWindows()
|
||||
vs.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
@@ -1,127 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import argparse
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv2.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv2.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv2.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv2.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv2.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv2.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv2.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv2.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv2.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv2.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv2.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv2.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv2.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv2.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv2.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv2.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv2.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv2.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv2.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv2.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv2.aruco.DICT_APRILTAG_36h11,
|
||||
}
|
||||
|
||||
|
||||
class image_converter:
|
||||
def __init__(self):
|
||||
# self.image_pub = rospy.Publisher("image_topic_2",Image)
|
||||
self.bridge = CvBridge()
|
||||
self.image_sub = rospy.Subscriber(
|
||||
"/camera/color/image_raw", Image, self.callback
|
||||
)
|
||||
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
default="DICT_4X4_50",
|
||||
help="type of ArCUo tag to detect",
|
||||
)
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
### For turtle controll
|
||||
self.pub = rospy.Publisher("/cmd_vel_mux/input/navi", Twist, queue_size=10)
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
self.rate = rospy.Rate(200) # update
|
||||
self.t = Twist()
|
||||
|
||||
### Markers haven been detected, now do something
|
||||
def markDetected(self, ids):
|
||||
ids = ids.flatten()
|
||||
if [1] in ids: # ID:1
|
||||
self.t.angular.z = 0.0
|
||||
self.t.linear.x = 0.3
|
||||
elif [2] in ids:
|
||||
self.t.angular.z = 0.0
|
||||
self.t.linear.x = -0.3
|
||||
elif [3] in ids:
|
||||
self.t.angular.z = 0.9
|
||||
self.t.linear.x = 0.0
|
||||
else:
|
||||
return
|
||||
self.pub.publish(self.t)
|
||||
self.rate.sleep()
|
||||
|
||||
def callback(self, data):
|
||||
try:
|
||||
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(rows, cols, channels) = cv_image.shape
|
||||
if cols > 60 and rows > 60:
|
||||
#cv2.circle(cv_image, (50, 50), 10, 255)
|
||||
pass
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(
|
||||
cv_image, self.arucoDict, parameters=self.arucoParams
|
||||
)
|
||||
|
||||
idString = "IDs:" + str(ids)
|
||||
cv2.putText(cv_image, idString, (50,50), cv2.FONT_HERSHEY_SIMPLEX , 1, (200, 100, 0), 3, cv2.LINE_AA)
|
||||
#####
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
self.markDetected(ids)
|
||||
else:
|
||||
self.t.angular.z = 0.8
|
||||
self.t.linear.x = 0.2
|
||||
self.pub.publish(self.t)
|
||||
self.rate.sleep()
|
||||
#####
|
||||
|
||||
|
||||
cv2.imshow("Image window", cv_image)
|
||||
cv2.waitKey(3)
|
||||
|
||||
|
||||
def main(args):
|
||||
ic = image_converter()
|
||||
# rospy.init_node('image_converter', anonymous=True)
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
Binary file not shown.
@@ -0,0 +1,253 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 550
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
self.last_depth += depth_image[j][i]
|
||||
self.number_of_operations += 1
|
||||
self.last_depth /= self.number_of_operations
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 550
|
||||
|
||||
class Tutel_Depth():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Tutel_control
|
||||
#self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
#self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.lastConernerTime = time.time()
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_depth", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (255,255,255), 2)
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
print(depth_image[j][i])
|
||||
self.last_depth += depth_image[j][i]
|
||||
self.number_of_operations += 1
|
||||
self.last_depth /= self.number_of_operations
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
#cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
return image
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = Tutel_Depth(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,260 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
#print(str(max(depth_values)) + " !!!!!!!!!!!!!!!!!!!")
|
||||
if k > (max(depth_values) - 10):
|
||||
#print("hello world!")
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth = [0, self.last_depth/self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
#cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
|
||||
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
|
||||
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if self.depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
if k < in range(0, max(depth_image)-9): pass
|
||||
else:
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 550
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] == max(depth_image):
|
||||
self.last_depth += depth_image[j][i]
|
||||
self.number_of_operations += 1
|
||||
self.last_depth /= self.number_of_operations
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
|
||||
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
|
||||
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
if k == max(depth_values):
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth = [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > 100:
|
||||
depth_values.append(depth_image[j][i])
|
||||
self.last_depth = max(depth_values)
|
||||
print(self.depth_counter, self.last_depth)
|
||||
#cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
start = time.time()
|
||||
while ((time.time() - start) < 10) or !self.search:
|
||||
self.pub.publish(self.t)
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
|
||||
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
|
||||
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
if k > (max(depth_values) - 10):
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Only a few cm")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
start = time.time()
|
||||
while (time.time() - start) < 3:
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
start = time.time()
|
||||
while ((time.time() - start) < 10) or !self.search:
|
||||
self.pub.publish(self.t)
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
|
||||
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
|
||||
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
if k > (max(depth_values) - 10):
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Only a few cm")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
start = time.time()
|
||||
while (time.time() - start) < 3:
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 550
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] == max(depth_image):
|
||||
self.last_depth += depth_image[j][i]
|
||||
self.number_of_operations += 1
|
||||
self.last_depth /= self.number_of_operations
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
start = time.time()
|
||||
while ((time.time() - start) < 10) or !self.search:
|
||||
self.pub.publish(self.t)
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
|
||||
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
|
||||
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
if k == max(depth_values):
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth = [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Only a few cm")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
start = time.time()
|
||||
while (time.time() - start) < 3:
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH_CAMERA_MIN_THRESHOLD = 460
|
||||
DEPTH_CAMERA_MAX_THRESHOLD = 750
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal/maximal depth we recognize, still testing for values!
|
||||
self.max_threshold = DEPTH_CAMERA_MAX_THRESHOLD
|
||||
self.min_threshold = DEPTH_CAMERA_MIN_THRESHOLD
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
#self.movement_counter = 0
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
self.search_time = time.time()
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
self.pixel_length = 0
|
||||
self.pixel_depth = 10.0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
cv2.rotate(rgb_image, cv2.ROTATE_180, rgb_image)
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
self.search = False
|
||||
if self.search:
|
||||
if(time.time() - self.search_time) > 31.5:
|
||||
self.search_time = time.time()
|
||||
#start = time.time()
|
||||
if (time.time() - self.search_time) < 34.415925:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.2 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
#self.movement_counter += 1
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
self.search = False
|
||||
else:
|
||||
self.t.linear.x = 0.2 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.search_time = time.time()
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
#self.movement_counter = 0
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.15 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.15 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Search_State: " + str(self.search)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
cv2.rotate(depth_image, cv2.ROTATE_180, depth_image)
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
#self.number_of_operations = 0
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: self.x = (self.top_left[0],self.top_right[0])
|
||||
else: self.x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1])
|
||||
else: self.y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0])
|
||||
else: self.x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: self.y = (self.bottom_right[1],self.bottom_left[1])
|
||||
depth_values = []
|
||||
for i in range(self.x[0], self.x[1]):
|
||||
for j in range(self.y[0], self.y[1]):
|
||||
if depth_image[j][i] > self.min_threshold and depth_image[j][i] < self.max_threshold:
|
||||
depth_values.append(depth_image[j][i])
|
||||
self.pixel_length = (self.x[1] - self.x[0] + self.y[1] - self.y[0]) / 2
|
||||
#Approximation function for the amount of marker side's pixel for a specific distance to the camera
|
||||
#f(x)=2914.2987x^-1.0159, with x := distance between camera and marker. Values rounded down to 4 digits.
|
||||
self.pixel_depth = ((self.pixel_length/2914.2987)**(-1/1.0159))*10 #*10 to get the depth value in mm as the depth image delivers them in mm
|
||||
print(self.pixel_depth)
|
||||
if self.pixel_depth > self.max_threshold:
|
||||
if (self.pixel_depth > self.last_depth-50 and self.pixel_depth < self.last_depth-50) or self.last_depth == 10:
|
||||
self.last_depth = self.pixel_depth
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
else:
|
||||
if len(depth_values)>0 and ((max(depth_values) > self.last_depth-50 and max(depth_values) < self.last_depth+50) or self.last_depth == 10):
|
||||
self.last_depth = max(depth_values)
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
print(self.depth_counter, self.last_depth)
|
||||
#cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.min_threshold and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Only a few cm")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
start = time.time()
|
||||
while (time.time() - start) < 1.0:
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
while(True):self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
#self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
self.t.linear.x = 0.15 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_right[0] < thresh_left or
|
||||
self.bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.15 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif(self.top_left[0] > thresh_right or
|
||||
self.bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.15 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: tutel_max_value_pure.py /cmd_vel_mux/input/navi /camera/color/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH_CAMERA_MIN_THRESHOLD = 400
|
||||
DEPTH_CAMERA_MAX_THRESHOLD = 700
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal/maximal depth we recognize, still testing for values!
|
||||
self.max_threshold = DEPTH_CAMERA_MAX_THRESHOLD
|
||||
self.min_threshold = DEPTH_CAMERA_MIN_THRESHOLD
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
#self.movement_counter = 0
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
self.search_time = time.time()
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
self.pixel_length = 0
|
||||
self.pixel_depth = 10.0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
self.search = False
|
||||
if self.search:
|
||||
if(time.time() - self.search_time) > 31.5:
|
||||
self.search_time = time.time()
|
||||
#start = time.time()
|
||||
if (time.time() - self.search_time) < 34.415925:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.2 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
#self.movement_counter += 1
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
self.search = False
|
||||
else:
|
||||
self.t.linear.x = 0.2 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.search_time = time.time()
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
#self.movement_counter = 0
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
self.last_depth = 10.0
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
#x and y are swapped, because
|
||||
depth_values = []
|
||||
for i in range(self.x[0], self.x[1]):
|
||||
for j in range(self.y[0], self.y[1]):
|
||||
if depth_image[j][i] > self.min_threshold and depth_image[j][i] < self.max_threshold:
|
||||
depth_values.append(depth_image[j][i])
|
||||
if len(depth_values)>0 and ((max(depth_values) > self.last_depth-100 and max(depth_values) < self.last_depth+100) or self.last_depth == 10):
|
||||
self.last_depth = max(depth_values)
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
print(self.depth_counter, self.last_depth)
|
||||
if self.last_depth < self.min_threshold and self.last_depth != 10:
|
||||
self.last_depth = self.pixel_length
|
||||
if self.last_depth <= 50 and self.last_depth != 10:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
|
||||
|
||||
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: self.x = (self.top_left[0],self.top_right[0])
|
||||
else: self.x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1])
|
||||
else: self.y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0])
|
||||
else: self.x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: self.y = (self.bottom_right[1],self.bottom_left[1])
|
||||
|
||||
self.pixel_length = (self.x[1] - self.x[0] + self.y[1] - self.y[0]) / 2
|
||||
#Approximation function for the amount of marker side's pixel for a specific distance to the camera
|
||||
#f(x)=2914.2987x^-1.0159, with x := distance between camera and marker. Values rounded down to 4 digits.
|
||||
self.pixel_depth = ((pixel_length/2914.2987)**(-1/1.0159))*10 #*10 to get the depth value in mm as the depth image delivers them in mm
|
||||
if self.pixel_depth > self.max_threshold or self.pixel_depth < self.min_threshold:
|
||||
if (self.pixel_depth > self.last_depth-100 and self.pixel_depth < self.last_depth-100) or self.last_depth == 10:
|
||||
self.last_depth = self.pixel_depth
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
else: self.depth_state = True
|
||||
|
||||
#self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if (self.x[0] > thresh_left and self.x[1] < thresh_right):
|
||||
self.t.linear.x = 0.15 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.x[1] < thresh_left:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.x[0] > thresh_right:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: tutel_max_value_pure_test_version.py /cmd_vel_mux/input/navi /camera/color/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,430 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = -1
|
||||
DEPTH_CAMERA_MIN_THRESHOLD = 470
|
||||
DEPTH_CAMERA_MAX_THRESHOLD = 750
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = '/dev/ttyACM3'
|
||||
BAUD = 115200
|
||||
#marker ids found in the room: 0, 63, 1024
|
||||
WHITELIST_OBJECT = [1, 6, 123]
|
||||
WHITELIST_PLACE = [234, 497, 666]
|
||||
SEARCH = ["no", "object", "place"]
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, verbose : str = "no", velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to -1 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.verbose = verbose
|
||||
self.target_id = TARGET
|
||||
self.last_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal/maximal depth we recognize, still testing for values!
|
||||
self.max_threshold = DEPTH_CAMERA_MAX_THRESHOLD
|
||||
self.min_threshold = DEPTH_CAMERA_MIN_THRESHOLD
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#+self.com=3
|
||||
self.device = DEVICE
|
||||
self.baud = BAUD
|
||||
self.board = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
time.sleep(5)
|
||||
answer =''
|
||||
self.board.write(bytes("0","utf-8"))
|
||||
while answer != b'1':
|
||||
answer = self.board.readline()
|
||||
print(answer)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
self.fresh_start = True
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = SEARCH[1]
|
||||
self.search_time = time.time()
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
self.pixel_length = 0
|
||||
self.pixel_depth = 10.0
|
||||
self.routine = False
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(30)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
#subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
if self.verbose == "window" or self.verbose == "both": cv2.rotate(rgb_image, cv2.ROTATE_180, rgb_image)
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
#if self.fresh_start is True:
|
||||
# print("I HAD A NIGHTMARE, THE WOLF EATING THE RAVEN")
|
||||
# self.t.linear.x = 0.2 * self.vel_fac
|
||||
# while(time.time() - self.search_time) < 1:
|
||||
# self.pub.publish(self.t)
|
||||
# self.fresh_start = False
|
||||
# self.search_time = time.time()
|
||||
if not self.routine:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("NO SEARCH JUST DETECT")
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x in WHITELIST_OBJECT:
|
||||
self.target_id = id_x
|
||||
self.search = SEARCH[0]
|
||||
#print("TARGET ID = " + str(self.target_id))
|
||||
break
|
||||
if self.search == "object":
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("SEARCH TIME")
|
||||
if (time.time() - self.search_time) < 31.415925:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("LOOKING AROUND")
|
||||
self.t.linear.x = 0.00 * self.vel_fac
|
||||
self.t.angular.z = 0.15 * self.vel_fac
|
||||
else:
|
||||
if self.verbose == "terminal" or self.verbose == "both":print("TIMES UP")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.search_time = time.time()
|
||||
self.pub.publish(self.t)
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("DID I FIND THE ANSWER TO ALL MY QUESTIONS OR GRAVENIMAGE OF ME?")
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x in WHITELIST_OBJECT:
|
||||
self.target_id = id_x
|
||||
self.search = SEARCH[0]
|
||||
break
|
||||
elif self.search == "no":
|
||||
if corners:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("I SAW SOMETHING")
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("I NEED TO GO LEFT!")
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.15 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("I NEED TO GO RIGHT")
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.15 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.search == "place":
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("SEARCH TIME")
|
||||
if (time.time() - self.search_time) < 31.415925:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("LOOKING AROUND")
|
||||
self.t.linear.x = 0.00 * self.vel_fac
|
||||
self.t.angular.z = 0.15 * self.vel_fac
|
||||
else:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("TIMES UP")
|
||||
self.t.linear.x = 0.15 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.search_time = time.time()
|
||||
self.pub.publish(self.t)
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("DID I FIND THE ANSWER TO ALL MY QUESTIONS OR GRAVENIMAGE OF ME?")
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x in WHITELIST_PLACE:
|
||||
if (self.last_id == WHITELIST_OBJECT[0] and id_x == WHITELIST_PLACE[0]) or (self.last_id == WHITELIST_OBJECT[1] and id_x == WHITELIST_PLACE[1]) or (self.last_id == WHITELIST_OBJECT[2] and id_x == WHITELIST_PLACE[2]):
|
||||
self.target_id = id_x
|
||||
self.search = SEARCH[0]
|
||||
break
|
||||
else:
|
||||
self.search = SEARCH[2]
|
||||
pass
|
||||
else:
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x in WHITELIST_OBJECT:
|
||||
self.target_id = id_x
|
||||
self.search = SEARCH[0]
|
||||
break
|
||||
#if self.verbose == "terminal" or self.verbose == "both": print("Routine initialised")
|
||||
#some additional info on screen
|
||||
if self.verbose == "window" or self.verbose == "both":
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Search_State: " + str(self.search)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
if self.verbose == "window" or self.verbose == "both": cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.verbose == "window" or self.verbose == "both": cv2.rotate(depth_image, cv2.ROTATE_180, depth_image)
|
||||
#x and y are swapped, because
|
||||
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: self.x = (self.top_left[0],self.top_right[0])
|
||||
else: self.x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1])
|
||||
else: self.y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0])
|
||||
else: self.x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: self.y = (self.bottom_right[1],self.bottom_left[1])
|
||||
#self.pixel_length = (self.x[1] - self.x[0] + self.y[1] - self.y[0]) / 2
|
||||
#Approximation function for the amount of marker side's pixel for a specific distance to the camera
|
||||
#f(x)=2914.2987x^-1.0159, with x := distance between camera and marker. Values rounded down to 4 digits.
|
||||
#self.pixel_depth = ((self.pixel_length/2914.29872964688)**(-1/1.01590290349592))*10 #*10 to get the depth value in mm as the depth image delivers them in mm
|
||||
#self.pixel_length = (abs(self.top_left[0]-self.top_right[0]) + abs(self.top_left[1] - self.bottom_left[1]) + abs(self.top_right[1]-self.bottom_right[1]) + abs(self.bottom_right[0]-self.bottom_left[0]))/4
|
||||
#self.pixel_depth = ((self.pixel_length/2675.4910012317)**(-1/0.993434027))*10
|
||||
pixels = (abs(self.top_left[0]-self.top_right[0]), abs(self.top_left[1] - self.bottom_left[1]), abs(self.top_right[1]-self.bottom_right[1]), abs(self.bottom_right[0]-self.bottom_left[0]))
|
||||
self.pixel_length = max(pixels)
|
||||
self.pixel_depth = ((self.pixel_length/2858.4636643479)**(-1/1.0056840993))*10
|
||||
#self.pixel_depth = (self.pixel_depth + ((((self.x[1] - self.x[0] + self.y[1] - self.y[0]) / 2)/2914.29872964688)**(-1/1.01590290349592))*10)/2
|
||||
depth_values = []
|
||||
for i in range(self.x[0], self.x[1]):
|
||||
for j in range(self.y[0], self.y[1]):
|
||||
if depth_image[j][i] > self.min_threshold and depth_image[j][i] < self.max_threshold and depth_image[j][i] < self.pixel_depth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
print(self.pixel_depth, depth_values, self.last_depth)
|
||||
if self.pixel_depth > self.max_threshold:
|
||||
if self.pixel_depth < self.last_depth or self.last_depth == 10:
|
||||
self.last_depth = self.pixel_depth
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
else:
|
||||
if len(depth_values)>0 and ((max(depth_values) > self.min_threshold and max(depth_values) < self.last_depth) or self.last_depth == 10):
|
||||
self.last_depth = max(depth_values)
|
||||
elif (len(depth_values)>0 and max(depth_values) < self.min_threshold) or len(depth_values)<1:
|
||||
self.last_depth = self.pixel_depth
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
if self.verbose == "terminal" or self.verbose == "both": print(self.depth_counter, self.last_depth)
|
||||
if self.last_depth < self.min_threshold and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if self.verbose == "terminal" or self.verbose == "both": print(self.last_depth)
|
||||
self.routine = True
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("Only a few cm")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
start = time.time()
|
||||
while (time.time() - start) < 0.55:
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.move_arm()
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("We reached our destination")
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: self.x = (self.top_left[0],self.top_right[0])
|
||||
else: self.x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1])
|
||||
else: self.y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0])
|
||||
else: self.x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: self.y = (self.bottom_right[1],self.bottom_left[1])
|
||||
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
|
||||
#self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
#if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
|
||||
#(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
|
||||
#(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
|
||||
#(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
|
||||
#print("ATTACK")
|
||||
#self.t.linear.x = 0.15 * self.vel_fac
|
||||
#self.t.angular.z = 0.0 * self.vel_fac
|
||||
#self.pub.publish(self.t)
|
||||
#elif(self.top_right[0] < thresh_left or
|
||||
#self.bottom_right[0] < thresh_left):
|
||||
#print("LEFT")
|
||||
#self.t.linear.x = 0.0 * self.vel_fac
|
||||
#self.t.angular.z = 0.2 * self.vel_fac
|
||||
#self.pub.publish(self.t)
|
||||
#elif(self.top_left[0] > thresh_right or
|
||||
#self.bottom_left[0] > thresh_right):
|
||||
#print("RIGHT")
|
||||
#self.t.linear.x = 0.0 * self.vel_fac
|
||||
#self.t.angular.z = -0.2 * self.vel_fac
|
||||
#self.pub.publish(self.t)
|
||||
if self.last_depth > 1000:
|
||||
if self.x[1] < self.w//2 - 80:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("LEFT")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.15
|
||||
elif self.x[0] > self.w//2 + 80:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("RIGHT")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.15
|
||||
else:
|
||||
self.t.linear.x = 0.1
|
||||
self.t.angular.z = 0.0
|
||||
if self.last_depth > 700:
|
||||
if self.x[1] < self.w//2 - 50:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("LEFT")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.15
|
||||
elif self.x[0] > self.w//2 + 50:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("RIGHT")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.15
|
||||
else:
|
||||
self.t.linear.x = 0.1
|
||||
self.t.angular.z = 0.0
|
||||
else:
|
||||
marker_x = ((self.x[0] + (self.x[1]-self.x[0])//2 - 5), (self.x[0] + (self.x[1]-self.x[0])//2 + 5))
|
||||
if marker_x[1] < self.w//2:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("LEFT")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.15
|
||||
elif marker_x[0] > self.w//2:
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("RIGHT")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.15
|
||||
else:
|
||||
self.t.linear.x = 0.1
|
||||
self.t.angular.z = 0.0
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
grabbed =''
|
||||
self.board.flush()
|
||||
self.board.write(bytes("250 0 -145", "utf-8"))
|
||||
time.sleep(1)
|
||||
if self.verbose == "terminal" or self.verbose == "both": print("move arm")
|
||||
while grabbed != b'2\r\n':
|
||||
grabbed = self.board.readline()
|
||||
print(grabbed)
|
||||
self.search = SEARCH[2]
|
||||
self.routine =False
|
||||
print(self.routine)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 4 or len(sys.argv) > 5:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic> and optional <verbose-flag>")
|
||||
print("Like: tutel_max_value_pure.py /cmd_vel_mux/input/navi /camera/color/image_raw /camera/depth/image_raw <verbose-flag>")
|
||||
return 1
|
||||
elif len(sys.argv) == 4:
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
else:
|
||||
ic = tutel(str(sys.argv[1]), str(sys.argv[2]), str(sys.argv[3]), str(sys.argv[4]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = -1
|
||||
DEPTH_CAMERA_MIN_THRESHOLD = 460
|
||||
DEPTH_CAMERA_MAX_THRESHOLD = 750
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, tutel_topic : str, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.vel_fac = velocity_factor
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal/maximal depth we recognize, still testing for values!
|
||||
self.max_threshold = DEPTH_CAMERA_MAX_THRESHOLD
|
||||
self.min_threshold = DEPTH_CAMERA_MIN_THRESHOLD
|
||||
|
||||
#Serial Pipeline init
|
||||
#self.com = self.init_serial()
|
||||
#self.device = DEVICE+str(self.com)
|
||||
#self.baud = BAUD
|
||||
#self.serial_pipeline = serial.Serial(self.device, self.baud, timeout = 1)
|
||||
|
||||
#Tutel_control
|
||||
self.pub = rospy.Publisher(tutel_topic, Twist, queue_size = 1)
|
||||
self.wait_publishers(astra_rgb_topic, astra_depth_topic)
|
||||
self.t = Twist()
|
||||
#self.movement_counter = 0
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.position = POSITIONS[-1]
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
self.search_time = time.time()
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
self.pixel_length = 0
|
||||
self.pixel_depth = 10.0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#finding specific port for arduino communication
|
||||
def init_serial(self):
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
port = DEVICE+str(com)
|
||||
baud = BAUD
|
||||
board = serial.Serial(port, baud)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
cv2.rotate(rgb_image, cv2.ROTATE_180, rgb_image)
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0 and id_x != 1023:
|
||||
self.target_id = id_x
|
||||
self.search = False
|
||||
break
|
||||
if self.search:
|
||||
if(time.time() - self.search_time) > 31.5:
|
||||
self.search_time = time.time()
|
||||
#start = time.time()
|
||||
if (time.time() - self.search_time) < 31.415925:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.2 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
#self.movement_counter += 1
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0 and id_x != 1023:
|
||||
self.target_id = id_x
|
||||
self.search = False
|
||||
break
|
||||
else:
|
||||
self.t.linear.x = 0.2 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.search_time = time.time()
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0 and id_x != 1023:
|
||||
self.target_id = id_x
|
||||
self.search = False
|
||||
break
|
||||
else:
|
||||
if corners:
|
||||
#self.movement_counter = 0
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
if self.position is POSITIONS[0]:
|
||||
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.position is POSITIONS[1]:
|
||||
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.3 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#some additional info on screen
|
||||
id_str = "IDs: " + str(ids) + " Target_ID:" + str(self.target_id)
|
||||
cv2.putText(rgb_image, id_str, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
info_str = "Resolution: " + str(self.w) + "x" + str(self.h) + " Search_State: " + str(self.search) + " Max_Min_Depth: " + str(self.maxMinDepth)
|
||||
cv2.putText(rgb_image, info_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
cv2.rotate(depth_image, cv2.ROTATE_180, depth_image)
|
||||
if self.depth_counter == 0:
|
||||
self.last_depth = 10.0
|
||||
self.x = (0,0)
|
||||
self.y = (0,0)
|
||||
#x and y are swapped, because
|
||||
depth_values = []
|
||||
for i in range(self.x[0], self.x[1]):
|
||||
for j in range(self.y[0], self.y[1]):
|
||||
if depth_image[j][i] > self.min_threshold and depth_image[j][i] < self.max_threshold:
|
||||
depth_values.append(depth_image[j][i])
|
||||
if len(depth_values)>0 and ((max(depth_values) > self.last_depth-100 and max(depth_values) < self.last_depth+100) or self.last_depth == 10):
|
||||
self.last_depth = max(depth_values)
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
print(self.depth_counter, self.last_depth)
|
||||
if self.last_depth < self.min_threshold and self.last_depth != 10:
|
||||
self.last_depth = self.pixel_length
|
||||
if self.last_depth <= 50 and self.last_depth != 10:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
|
||||
|
||||
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: self.x = (self.top_left[0],self.top_right[0])
|
||||
else: self.x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1])
|
||||
else: self.y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0])
|
||||
else: self.x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: self.y = (self.bottom_right[1],self.bottom_left[1])
|
||||
|
||||
self.pixel_length = (self.x[1] - self.x[0] + self.y[1] - self.y[0]) / 2
|
||||
#Approximation function for the amount of marker side's pixel for a specific distance to the camera
|
||||
#f(x)=2914.2987x^-1.0159, with x := distance between camera and marker. Values rounded down to 4 digits.
|
||||
self.pixel_depth = ((pixel_length/2914.2987)**(-1/1.0159))*10 #*10 to get the depth value in mm as the depth image delivers them in mm
|
||||
if self.pixel_depth > self.max_threshold or self.pixel_depth < self.min_threshold:
|
||||
if (self.pixel_depth > self.last_depth-100 and self.pixel_depth < self.last_depth-100) or self.last_depth == 10:
|
||||
self.last_depth = self.pixel_depth
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
else: self.depth_state = True
|
||||
|
||||
#self.last_marker_position = ((self.top_left), (self.bottom_right))
|
||||
if (self.x[0] > thresh_left and self.x[1] < thresh_right):
|
||||
self.t.linear.x = 0.15 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.x[1] < thresh_left:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
elif self.x[0] > thresh_right:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = -0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > self.top_left[0]:
|
||||
self.position = POSITIONS[0]
|
||||
elif self.w - int(self.w / 2) < self.top_left[0]:
|
||||
self.position = POSITIONS[1]
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: tutel_max_value_pure_test_version.py /cmd_vel_mux/input/navi /camera/color/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
self.number_of_pixels = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
|
||||
#some additional info on screen
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
pixel_str = "Number_of_pixel:" + str(self.number_of_pixel)
|
||||
cv2.putText(rgb_image, pixel_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#x and y are swapped, because
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
self.number_of_pixels += 1
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
if len(depth_values)>0 and max(depth_values) in range(self.last_depth-100, self.last_depth+100):
|
||||
self.last_depth = max(depth_values)
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
print(self.depth_counter, self.last_depth, self.number_of_pixels)
|
||||
self.number_of_operations = 0
|
||||
self.number_of_pixels = 0
|
||||
#cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv)!=3:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: depth_reader.py /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
kleiner Laptop/Laptop auf dem Bot = ROSMASTER
|
||||
großer Laptop/Laptop im Netz = ROSSLAVE
|
||||
|
||||
normalerweise sollte es in diesem Setup laufen.
|
||||
Falls nicht an den jeweiligen Laptops export Befehle ausführen.
|
||||
Abfragen der eigenen IP: ip addr
|
||||
Punkt 4. "inet"
|
||||
|
||||
ROSSLAVE ist der catkin_ws relativ uninteressant,
|
||||
nodes in Form von python scripts können auch über python3 ausgeführt werden.
|
||||
|
||||
ROSMASTER:
|
||||
(export ROS_IP = eigeneIP)
|
||||
roscore
|
||||
cd catkin_ws
|
||||
source ./devel/setup.bash
|
||||
roslaunch <camera>
|
||||
(roslaunch lidar)
|
||||
|
||||
ROSSLAVE:
|
||||
(cd catkin_ws)
|
||||
(source ./devel/setup.bash)
|
||||
export ROS_MASTER_URI=http://ROSMASTER_IP:11311
|
||||
export ROS_IP=eigeneIP
|
||||
NODE starten, roslaunch oder python3
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
roslaunch hls_lfcd_lds_driver hlds_laser.launch
|
||||
|
||||
gmapping mit "scan"
|
||||
rosrun gmapping slam_gmapping scan:=scan
|
||||
fixed frame in rviz = "laser"
|
||||
|
||||
https://dabit-industries.github.io/turtlebot2-tutorials/06-Gmapping.html
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
Joint 1 bis Joint 2: 16.4mm
|
||||
Joint 2 bis Joint 3: 75.7mm
|
||||
Joint 3 bis Joint 4: 47mm
|
||||
Joint 4 bis Joint 5: 50mm
|
||||
Joint 5 bis Endeffektor: 32mm
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Creates a catkin workspace for the Turtlebot under ros noetic
|
||||
echo "Basic ros noetic packages must be already installed!"
|
||||
echo "Only Bash supported, no sh!"
|
||||
echo "This will create a catkin_ws folder and automaticly install packages. Press Enter to continue"
|
||||
read nothing
|
||||
|
||||
sudo apt update
|
||||
|
||||
sudo apt install -y python3 python-is-python3 git
|
||||
sudo apt install -y liborocos-kdl-dev
|
||||
sudo apt install -y ros-noetic-joy python3-catkin python3-rosdep
|
||||
|
||||
mkdir -p ~/catkin_ws/src
|
||||
cd catkin_ws
|
||||
catkin_make
|
||||
cd src
|
||||
|
||||
# Clone the required repositories
|
||||
git clone https://github.com/turtlebot/turtlebot.git
|
||||
git clone https://github.com/turtlebot/turtlebot_msgs.git
|
||||
git clone https://github.com/turtlebot/turtlebot_apps.git
|
||||
git clone https://github.com/turtlebot/turtlebot_simulator
|
||||
|
||||
# Following https://github.com/yujinrobot/kobuki/issues/427
|
||||
git clone https://github.com/yujinrobot/yujin_ocs.git
|
||||
# Remove all but 'yocs_cmd_vel_mux', 'yocs_controllers', and 'yocs_velocity_smoother'
|
||||
mv yujin_ocs/yocs_cmd_vel_mux yujin_ocs/yocs_controllers yujin_ocs/yocs_velocity_smoother .
|
||||
rm -rf yujin_ocs
|
||||
|
||||
# Add the battery monitor package
|
||||
git clone https://github.com/ros-drivers/linux_peripheral_interfaces.git
|
||||
mv linux_peripheral_interfaces/laptop_battery_monitor ./
|
||||
rm -rf linux_peripheral_interfaces
|
||||
# You need to MANUALLY, for now, apply the changes proposed in https://github.com/ros-drivers/linux_peripheral_interfaces/pull/18
|
||||
|
||||
|
||||
# Clone the MELODIC branch of the kobuki git
|
||||
git clone https://github.com/yujinrobot/kobuki.git
|
||||
|
||||
rosdep install --from-paths . --ignore-src -r -y
|
||||
|
||||
# Build the packages
|
||||
cd ..
|
||||
source ./devel/setup.bash
|
||||
catkin_make
|
||||
cd build
|
||||
make install
|
||||
cd ..
|
||||
echo "DONE!"
|
||||
@@ -40,6 +40,7 @@ ARUCO_DICT = {
|
||||
|
||||
class image_converter:
|
||||
def __init__(self):
|
||||
# self.image_pub = rospy.Publisher("image_topic_2",Image)
|
||||
self.bridge = CvBridge()
|
||||
self.image_sub = rospy.Subscriber(
|
||||
"/camera/color/image_raw", Image, self.callback
|
||||
@@ -50,7 +51,7 @@ class image_converter:
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
default="DICT_ARUCO_ORIGINAL",
|
||||
default="DICT_4X4_50",
|
||||
help="type of ArCUo tag to detect",
|
||||
)
|
||||
args = vars(ap.parse_args())
|
||||
@@ -6,7 +6,6 @@ import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import argparse
|
||||
import time
|
||||
import numpy as np
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
@@ -65,8 +64,6 @@ class image_converter:
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
self.rate = rospy.Rate(10) # update
|
||||
self.t = Twist()
|
||||
self.leftright = 0
|
||||
self.lastConernerTime = time.time()
|
||||
### Markers haven been detected, now do something
|
||||
def markDetected(self, ids, img, corners):
|
||||
# cv2.circle(img, (self.w//2, self.h//2), 100, (255, 255, 255), -1)
|
||||
@@ -129,11 +126,6 @@ class image_converter:
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.3
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > top_left[0]:
|
||||
self.leftright = 1
|
||||
elif self.w - int(self.w / 2) < top_left[0]:
|
||||
self.leftright = 2
|
||||
|
||||
#print(corners[0][0])
|
||||
ids = ids.flatten()
|
||||
#if [1] in ids: # ID:1
|
||||
@@ -172,18 +164,6 @@ class image_converter:
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
cv_image = self.markDetected(ids, cv_image, corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif (self.lastConernerTime - time.time()) < 1./2:
|
||||
if self.leftright == 1:
|
||||
cv2.rectangle(cv_image, (0, 0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.3
|
||||
self.pub.publish(self.t)
|
||||
elif self.leftright == 2:
|
||||
cv2.rectangle(cv_image, (self.w-20, 0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.3
|
||||
self.pub.publish(self.t)
|
||||
#else:
|
||||
#self.t.angular.z = 0.8
|
||||
#self.t.linear.x = 0.2
|
||||
@@ -0,0 +1,220 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
class marker_attacker():
|
||||
def wait_for_subscribers(self):
|
||||
while self.pub.get_num_connections() == 0:
|
||||
print("Waiting for subscriber on {}".format(self.pub.name))
|
||||
rospy.sleep(1)
|
||||
if rospy.is_shutdown():
|
||||
raise Exception("Got shutdown request before subscribers connected")
|
||||
def wait_for_publisher(self,astra_camera_rgb_topic,astra_camera_depth_topic):
|
||||
while 1:
|
||||
x = rospy.get_published_topics()
|
||||
if any(astra_camera_depth_topic in subl for subl in x) and any(astra_camera_depth_topic in subl for subl in x):
|
||||
break
|
||||
print("Waiting for {} and {}".format(astra_camera_rgb_topic,astra_camera_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def __init__(self, turlte_bot_topic : str, astra_camera_rgb_topic : str, astra_camera_depth_topic : str ,speed_emul : float = 1, start_id : int = 0):
|
||||
|
||||
self.speed_mul = speed_emul
|
||||
self.target_id = start_id #We target one tag at a time
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
self.maxMinDepth = 550
|
||||
self.com = self.init_serial()
|
||||
DEVICE = '/dev/ttyACM'+str(self.com)
|
||||
BAUD = 9600
|
||||
self.s = serial.Serial(DEVICE, BAUD, timeout=1)
|
||||
### For turtle controll
|
||||
self.pub = rospy.Publisher(turlte_bot_topic, Twist, queue_size=1)
|
||||
# self.wait_for_subscribers()
|
||||
self.wait_for_publisher(astra_camera_rgb_topic,astra_camera_depth_topic)
|
||||
self.t = Twist()
|
||||
self.leftright = 0
|
||||
self.lastConernerTime = time.time()
|
||||
self.bridge = CvBridge()
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
self.rate = rospy.Rate(15) # update rate can be increased
|
||||
|
||||
self.depth_point = (-1,-1) #This is the point from where we get the depth
|
||||
self.last_depth = 10 #This is the last depth from the depth_point
|
||||
|
||||
self.depth_counter = 0 #Make sure we are really there by counting how many time we got this result
|
||||
self.rState = 0
|
||||
self.image_sub = rospy.Subscriber(
|
||||
astra_camera_rgb_topic, Image, self.callback_rgb
|
||||
)
|
||||
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_image_sub = rospy.Subscriber(astra_camera_depth_topic,Image,self.callback_depth)
|
||||
|
||||
### Markers haven been detected, now do something
|
||||
def markDetected(self, img, corners):
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
for markerCorner in corners:
|
||||
(top_left, top_right, bottom_right, bottom_left) = markerCorner.reshape((4,2))
|
||||
top_left = (int(top_left[0]), int(top_left[1]))
|
||||
top_right = (int(top_right[0]), int(top_right[1]))
|
||||
bottom_right = (int(bottom_right[0]), int(bottom_right[1]))
|
||||
bottom_left = (int(bottom_left[0]), int(bottom_left[1]))
|
||||
cv2.line(img, top_left, bottom_right, (0,255,0), 2)
|
||||
cv2.line(img, top_right, bottom_left, (0,255,0), 2)
|
||||
self.depth_point = (int((top_left[0] + bottom_right[0]) / 2), int((top_left[1] + bottom_right[1]) / 2))
|
||||
|
||||
cv2.circle(img, self.depth_point, 8, (0,0,255), -1)
|
||||
|
||||
self.lastMarkerPos = ((top_left),(bottom_right))
|
||||
if ((top_left[0] > thresh_left and top_left[0] < thresh_right) or
|
||||
(top_right[0] > thresh_left and top_right[0] < thresh_right) or
|
||||
(bottom_left[0] > thresh_left and bottom_left[0] < thresh_right) or
|
||||
(bottom_right[0] > thresh_left and bottom_right[0] < thresh_right)):
|
||||
self.t.linear.x = 0.1 * self.speed_mul
|
||||
self.t.angular.z = 0.0
|
||||
self.pub.publish(self.t)
|
||||
elif(top_right[0] < thresh_left or
|
||||
bottom_right[0] < thresh_left):
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.3 * self.speed_mul
|
||||
self.pub.publish(self.t)
|
||||
elif(top_left[0] > thresh_right or
|
||||
bottom_left[0] > thresh_right):
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.3 * self.speed_mul
|
||||
self.pub.publish(self.t)
|
||||
if int(self.w / 2) > top_left[0]:
|
||||
self.leftright = 1
|
||||
elif self.w - int(self.w / 2) < top_left[0]:
|
||||
self.leftright = 2
|
||||
|
||||
return img
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = cv_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
#(rows, cols, channels) = cv_image.shape
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(
|
||||
cv_image, self.arucoDict, parameters=self.arucoParams
|
||||
)
|
||||
|
||||
if self.rState == 0:
|
||||
#This is a searching state, we are searching for right tag
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.4 * self.speed_mul
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
i = np.where(ids == self.target_id)
|
||||
if len(i[0]) > 0:
|
||||
self.rState = 1
|
||||
elif self.rState == 1:
|
||||
#####
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
if corners:
|
||||
#Now seleted the corners of the tag with the right id
|
||||
i = np.where(ids == self.target_id)
|
||||
if len(i[0]) > 0:
|
||||
fitting_corners = corners[i[0][0]]
|
||||
cv_image = self.markDetected(cv_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
|
||||
elif (self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_point = (-1,-1) #Indicates that we dont need depth to be processed
|
||||
if self.leftright == 1:
|
||||
cv2.rectangle(cv_image, (0, 0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.3 * self.speed_mul
|
||||
self.pub.publish(self.t)
|
||||
elif self.leftright == 2:
|
||||
cv2.rectangle(cv_image, (self.w-20, 0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.3 * self.speed_mul
|
||||
self.pub.publish(self.t)
|
||||
|
||||
#Give some additional informations
|
||||
idString = "IDs:" + str(ids) + " TargetID:" + str(self.target_id)
|
||||
cv2.putText(cv_image, idString, (10,30), cv2.FONT_HERSHEY_TRIPLEX, 1, (255, 0, 0), 2, cv2.LINE_8)
|
||||
depthString = "DepthPoint:" + str(self.depth_point[0]) +"x" +str(self.depth_point[1]) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(cv_image, depthString, (10,60), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (255, 0, 0), 2, cv2.LINE_8)
|
||||
|
||||
depthString = "Res:" + str(self.w) + "x" + str(self.h) + " RState:" + str(self.rState) + " MMDepth:" + str(self.maxMinDepth)
|
||||
cv2.putText(cv_image, depthString, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (255, 0, 0), 2, cv2.LINE_8)
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Window", cv_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_point != (-1,-1):
|
||||
#It would be possible to convert this to 32FC1
|
||||
#32FC1 means that each pixel value is stored as one channel floating point with single precision
|
||||
#In 32FC1 each pixel is 4 bytes. Apart from that its a numpy array
|
||||
cv_depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
# Here x and y are swapped. I dont know why.
|
||||
self.last_depth = cv_depth_image[self.depth_point[1]][self.depth_point[0]]
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1 #Sometimes the data is inacurate make sure we get the data at least 5times
|
||||
if self.depth_counter > 4:
|
||||
print("We are really there")
|
||||
#self.target_id += 1
|
||||
#self.target_id = self.target_id % 2
|
||||
self.move_arm(self)
|
||||
#self.depth_counter = 0
|
||||
#self.last_depth = 10
|
||||
#self.depth_point = (-1,-1)
|
||||
#self.leftright = -1
|
||||
#self.rState = 0 #Start searching for the next tag
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
#We dont need to sleep twice
|
||||
#self.rate.sleep()
|
||||
|
||||
def init_serial():
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser","/dev/ttyACM"+str(com),"-k"])
|
||||
try:
|
||||
PORT = '/dev/ttyACM' + str(com)
|
||||
BAUD = 9600
|
||||
board = serial.Serial(PORT, BAUD)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = marker_attacker(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -6,6 +6,7 @@ import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import argparse
|
||||
import time
|
||||
import numpy as np
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
@@ -40,6 +41,7 @@ ARUCO_DICT = {
|
||||
|
||||
class image_converter:
|
||||
def __init__(self):
|
||||
# self.image_pub = rospy.Publisher("image_topic_2",Image)
|
||||
self.bridge = CvBridge()
|
||||
self.image_sub = rospy.Subscriber(
|
||||
"/camera/color/image_raw", Image, self.callback
|
||||
@@ -61,17 +63,16 @@ class image_converter:
|
||||
### For turtle controll
|
||||
self.pub = rospy.Publisher("/cmd_vel_mux/input/navi", Twist, queue_size=10)
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
self.rate = rospy.Rate(200) # update
|
||||
self.rate = rospy.Rate(10) # update
|
||||
self.t = Twist()
|
||||
self.storedMarkerPoints = []
|
||||
|
||||
self.leftright = 0
|
||||
self.lastConernerTime = time.time()
|
||||
### Markers haven been detected, now do something
|
||||
def markDetected(self, ids, img, corners):
|
||||
(h, w) = img.shape[:2]
|
||||
cv2.circle(img, (w//2, h//2), 100, (255, 255, 255), -1)
|
||||
thresh_left = w//2 - 100
|
||||
thresh_right = w//2 + 100
|
||||
cv2.line(img, (thresh_left, h//2), (thresh_right, h//2), (0,0,0), 2)
|
||||
# cv2.circle(img, (self.w//2, self.h//2), 100, (255, 255, 255), -1)
|
||||
thresh_left = self.w//2 - 100
|
||||
thresh_right = self.w//2 + 100
|
||||
# cv2.line(img, (thresh_left, self.h//2), (thresh_right, self.h//2), (0,0,0), 2)
|
||||
for markerCorner in corners:
|
||||
corners = markerCorner.reshape((4,2))
|
||||
(top_left, top_right, bottom_right, bottom_left) = corners
|
||||
@@ -80,54 +81,65 @@ class image_converter:
|
||||
bottom_right = (int(bottom_right[0]), int(bottom_right[1]))
|
||||
bottom_left = (int(bottom_left[0]), int(bottom_left[1]))
|
||||
cv2.circle(img, top_left, 10, (0,255,0), -1)
|
||||
print("top_left(",top_left[0],",",top_left[1],")")
|
||||
print("top_right(",top_right[0],",",top_right[1],")")
|
||||
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
if ((top_left[0] > thresh_left and top_left[0] < thresh_right) or
|
||||
# print("top_left(",top_left[0],",",top_left[1],")")
|
||||
# print("top_right(",top_right[0],",",top_right[1],")")
|
||||
# print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
# print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
print(top_right[0] - top_left[0])
|
||||
if abs(top_right[0] - top_left[0]) >= 10:
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.0
|
||||
self.pub.publish(self.t)
|
||||
cv2.putText(img, "GRAB MARKER", (100,100), cv2.FONT_HERSHEY_SIMPLEX , 1, (200, 100, 0), 3, cv2.LINE_AA)
|
||||
elif ((top_left[0] > thresh_left and top_left[0] < thresh_right) or
|
||||
(top_right[0] > thresh_left and top_right[0] < thresh_right) or
|
||||
(bottom_left[0] > thresh_left and bottom_left[0] < thresh_right) or
|
||||
(bottom_right[0] > thresh_left and bottom_right[0] < thresh_right)):
|
||||
print("##########################")
|
||||
print("Object found")
|
||||
print("top_left(",top_left[0],",",top_left[1],")")
|
||||
print("top_right(",top_right[0],",",top_right[1],")")
|
||||
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
print(thresh_left)
|
||||
print(thresh_right)
|
||||
print("##############################################")
|
||||
# print("##########################")
|
||||
# print("Object found")
|
||||
# print("top_left(",top_left[0],",",top_left[1],")")
|
||||
# print("top_right(",top_right[0],",",top_right[1],")")
|
||||
# print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
# print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
# print(thresh_left)
|
||||
# print(thresh_right)
|
||||
# print("##############################################")
|
||||
self.t.linear.x = 0.1
|
||||
self.t.angular.z = 0.0
|
||||
self.pub.publish(self.t)
|
||||
self.rate.sleep()
|
||||
elif(top_right[0] < thresh_left or
|
||||
bottom_right[0] < thresh_left):
|
||||
print("##########################")
|
||||
print("Object found")
|
||||
print("top_left(",top_left[0],",",top_left[1],")")
|
||||
print("top_right(",top_right[0],",",top_right[1],")")
|
||||
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
print(thresh_left)
|
||||
print(thresh_right)
|
||||
print("##############################################")
|
||||
self.t.angular.z = 0.2
|
||||
# print("##########################")
|
||||
# print("Object found")
|
||||
# print("top_left(",top_left[0],",",top_left[1],")")
|
||||
# print("top_right(",top_right[0],",",top_right[1],")")
|
||||
## print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
# print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
# print(thresh_left)
|
||||
# print(thresh_right)
|
||||
# print("##############################################")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.3
|
||||
self.pub.publish(self.t)
|
||||
self.rate.sleep()
|
||||
elif(top_left[0] > thresh_right or
|
||||
bottom_left[0] > thresh_right):
|
||||
print("##########################")
|
||||
print("Object found")
|
||||
print("top_left(",top_left[0],",",top_left[1],")")
|
||||
print("top_right(",top_right[0],",",top_right[1],")")
|
||||
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
print(thresh_left)
|
||||
print(thresh_right)
|
||||
print("##############################################")
|
||||
self.t.angular.z = -0.2
|
||||
# print("##########################")
|
||||
# print("Object found")
|
||||
# print("top_left(",top_left[0],",",top_left[1],")")
|
||||
# print("top_right(",top_right[0],",",top_right[1],")")
|
||||
# print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
|
||||
# print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
|
||||
# print(thresh_left)
|
||||
# print(thresh_right)
|
||||
# print("##############################################")
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.3
|
||||
self.pub.publish(self.t)
|
||||
self.rate.sleep()
|
||||
if int(self.w / 2) > top_left[0]:
|
||||
self.leftright = 1
|
||||
elif self.w - int(self.w / 2) < top_left[0]:
|
||||
self.leftright = 2
|
||||
|
||||
#print(corners[0][0])
|
||||
ids = ids.flatten()
|
||||
#if [1] in ids: # ID:1
|
||||
@@ -148,6 +160,7 @@ class image_converter:
|
||||
def callback(self, data):
|
||||
try:
|
||||
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
(self.h, self.w) = cv_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
@@ -163,15 +176,21 @@ class image_converter:
|
||||
cv2.putText(cv_image, idString, (50,50), cv2.FONT_HERSHEY_SIMPLEX , 1, (200, 100, 0), 3, cv2.LINE_AA)
|
||||
#####
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
|
||||
if len(corners) > 0:
|
||||
cv_image = self.markDetected(ids, cv_image, corners)
|
||||
storedSize = len(self.storedMarkerPoints)
|
||||
if storedSize < 20:
|
||||
self.storedMarkerPoints += corners
|
||||
if storedSize > 5:
|
||||
self.storedMarkerPoints.pop(0)
|
||||
|
||||
|
||||
self.lastConernerTime = time.time()
|
||||
elif (self.lastConernerTime - time.time()) < 1./2:
|
||||
if self.leftright == 1:
|
||||
cv2.rectangle(cv_image, (0, 0), (20, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = 0.3
|
||||
self.pub.publish(self.t)
|
||||
elif self.leftright == 2:
|
||||
cv2.rectangle(cv_image, (self.w-20, 0), (self.w, self.h), (0,0,255), cv2.FILLED)
|
||||
self.t.linear.x = 0.0
|
||||
self.t.angular.z = -0.3
|
||||
self.pub.publish(self.t)
|
||||
#else:
|
||||
#self.t.angular.z = 0.8
|
||||
#self.t.linear.x = 0.2
|
||||
@@ -183,12 +202,14 @@ class image_converter:
|
||||
#####
|
||||
|
||||
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Image window", cv_image)
|
||||
cv2.waitKey(3)
|
||||
|
||||
|
||||
def main(args):
|
||||
ic = image_converter()
|
||||
# rospy.init_node('image_converter', anonymous=True)
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
@@ -1,95 +0,0 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
import time
|
||||
cap = cv2.VideoCapture(0)
|
||||
k = np.ones((3, 3), np.uint8)
|
||||
t0 = cap.read()[1]
|
||||
t1 = cap.read()[1]
|
||||
allcontours = []
|
||||
whiteBackground = 0
|
||||
autoClear = 0
|
||||
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH ))
|
||||
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT ))
|
||||
thresholdW = int(width / 2)
|
||||
outputTitleB = "Press ESC to exit. Try a or e or r or (m or l) or (i or k)"
|
||||
sense = 35
|
||||
maxContoursBuffer = 500
|
||||
cColor1 = 255
|
||||
addToColor = 1
|
||||
activeDetect = 1
|
||||
holdLeftRight = 0 # 1 = L, 2 = R
|
||||
frame_rate = 12
|
||||
prev = 0
|
||||
|
||||
while(True):
|
||||
time_elapsed = time.time() - prev
|
||||
if time_elapsed > 1./frame_rate:
|
||||
prev = time.time()
|
||||
else:
|
||||
continue
|
||||
d=cv2.absdiff(t1, t0)
|
||||
grey = cv2.cvtColor(d, cv2.COLOR_BGR2GRAY)
|
||||
blur = cv2.GaussianBlur(grey, (3, 3), 0)
|
||||
ret, th = cv2.threshold( blur,sense, 255,
|
||||
cv2.THRESH_BINARY)
|
||||
dilated = cv2.dilate(th, k, iterations=4)
|
||||
contours, hierarchy = cv2.findContours(dilated,
|
||||
cv2.RETR_TREE,
|
||||
cv2.CHAIN_APPROX_NONE)
|
||||
t2=t0
|
||||
if whiteBackground == 1:
|
||||
cv2.rectangle(t2, (0,0), (width,height), (10,10,10), cv2.FILLED)
|
||||
|
||||
cColor1 = 1
|
||||
for x in allcontours:
|
||||
cColor1 += 0.5
|
||||
cv2.drawContours(t2, x, -1, (cColor1,0,0), 3)
|
||||
|
||||
if activeDetect == 1:
|
||||
if len(allcontours) < maxContoursBuffer:
|
||||
allcontours += contours[:20] #Add a max. of n data points
|
||||
if contours:
|
||||
if thresholdW > allcontours[-1][0][0][0]:
|
||||
holdLeftRight = 1
|
||||
elif width - thresholdW < allcontours[-1][0][0][0]:
|
||||
holdLeftRight = 2
|
||||
allcontours = allcontours[8:]
|
||||
|
||||
if holdLeftRight == 1:
|
||||
cv2.rectangle(t2, (0,0), (20,height), (0,0,255), cv2.FILLED)
|
||||
elif holdLeftRight == 2:
|
||||
cv2.rectangle(t2, (width-20,0), (width,height), (0,0,255), cv2.FILLED)
|
||||
|
||||
cv2.drawContours(t2, contours, -1, (0, 255, 0), 2)
|
||||
imS = cv2.resize(t2, (1060, 700))
|
||||
cv2.imshow(outputTitleB, imS)
|
||||
#t0=t2
|
||||
t0=t1
|
||||
t1=cap.read()[1]
|
||||
cKey = cv2.waitKey(15)
|
||||
if cKey == 27 :
|
||||
break
|
||||
elif cKey == ord('a'):
|
||||
whiteBackground = 1 - whiteBackground
|
||||
elif cKey == ord('m'):
|
||||
sense += 1
|
||||
print(sense)
|
||||
elif cKey == ord('r'):
|
||||
allcontours = []
|
||||
print("reset")
|
||||
elif cKey == ord('l'):
|
||||
sense -= 1
|
||||
print(sense)
|
||||
elif cKey == ord('e'):
|
||||
activeDetect = 1 - activeDetect
|
||||
print("Is active:" + str(activeDetect))
|
||||
elif cKey == ord('i'):
|
||||
addToColor += 1
|
||||
print("Current addColor:" + str(addToColor))
|
||||
elif cKey == ord('k'):
|
||||
addToColor -= 1
|
||||
print("Current addColor:" + str(addToColor))
|
||||
|
||||
|
||||
cv2.destroyAllWindows()
|
||||
cap.release()
|
||||
@@ -1,165 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# license removed for brevity
|
||||
import rospy
|
||||
from geometry_msgs.msg import Twist
|
||||
from imutils.video import VideoStream
|
||||
import argparse
|
||||
import imutils
|
||||
import time
|
||||
import cv2 as cv
|
||||
import sys
|
||||
|
||||
# define names of each possible ArUco tag OpenCV supports
|
||||
ARUCO_DICT = {
|
||||
"DICT_4X4_50": cv.aruco.DICT_4X4_50,
|
||||
"DICT_4X4_100": cv.aruco.DICT_4X4_100,
|
||||
"DICT_4X4_250": cv.aruco.DICT_4X4_250,
|
||||
"DICT_4X4_1000": cv.aruco.DICT_4X4_1000,
|
||||
"DICT_5X5_50": cv.aruco.DICT_5X5_50,
|
||||
"DICT_5X5_100": cv.aruco.DICT_5X5_100,
|
||||
"DICT_5X5_250": cv.aruco.DICT_5X5_250,
|
||||
"DICT_5X5_1000": cv.aruco.DICT_5X5_1000,
|
||||
"DICT_6X6_50": cv.aruco.DICT_6X6_50,
|
||||
"DICT_6X6_100": cv.aruco.DICT_6X6_100,
|
||||
"DICT_6X6_250": cv.aruco.DICT_6X6_250,
|
||||
"DICT_6X6_1000": cv.aruco.DICT_6X6_1000,
|
||||
"DICT_7X7_50": cv.aruco.DICT_7X7_50,
|
||||
"DICT_7X7_100": cv.aruco.DICT_7X7_100,
|
||||
"DICT_7X7_250": cv.aruco.DICT_7X7_250,
|
||||
"DICT_7X7_1000": cv.aruco.DICT_7X7_1000,
|
||||
"DICT_ARUCO_ORIGINAL": cv.aruco.DICT_ARUCO_ORIGINAL,
|
||||
"DICT_APRILTAG_16h5": cv.aruco.DICT_APRILTAG_16h5,
|
||||
"DICT_APRILTAG_25h9": cv.aruco.DICT_APRILTAG_25h9,
|
||||
"DICT_APRILTAG_36h10": cv.aruco.DICT_APRILTAG_36h10,
|
||||
"DICT_APRILTAG_36h11": cv.aruco.DICT_APRILTAG_36h11,
|
||||
}
|
||||
|
||||
|
||||
def talker():
|
||||
# construct the argument parser and parse the argument
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
default="DICT_ARUCO_ORIGINAL",
|
||||
help="type of ArCUo tag to detect",
|
||||
)
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
# verify that the supplied ArUCo tag exists and is supported by OpenCV
|
||||
if ARUCO_DICT.get(args["type"], None) is None:
|
||||
print("[INFO] ArUCo tag of '{}' is not supported".format(args["type"]))
|
||||
sys.exit(0)
|
||||
|
||||
# load the ArUCo dictionary and grab hte ArUCo parameters
|
||||
print("[INFO] detecting '{}' tags...".format(args["type"]))
|
||||
arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]])
|
||||
arucoParams = cv.aruco.DetectorParameters()
|
||||
detector = cv.aruco.ArucoDetector(arucoDict, arucoParams)
|
||||
|
||||
# initialize the video stream and allow the camera sensor to warm up
|
||||
print("[INFO] starting video stream...")
|
||||
vs = VideoStream(src=0).start()
|
||||
|
||||
pub = rospy.Publisher("turtle1/cmd_vel", Twist, queue_size=10)
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
rate = rospy.Rate(10)
|
||||
t = Twist()
|
||||
|
||||
keepLeftRight = 0 #1 = L, 2 = R
|
||||
frame = vs.read()
|
||||
frame = imutils.resize(frame)
|
||||
(h, w) = frame.shape[:2]
|
||||
threshold = int(w/2)
|
||||
while not rospy.is_shutdown():
|
||||
# grab the frame from the threaded video and resize it
|
||||
# to have a maximum width of 1000 pixels
|
||||
frame = vs.read()
|
||||
frame = imutils.resize(frame)
|
||||
# detect ArUCo markers in the input frame
|
||||
(corners, ids, rejected) = detector.detectMarkers(frame)
|
||||
|
||||
# verify *at least* one ArUCo marker was detected
|
||||
if len(corners) > 0:
|
||||
# flatten the ArUCo IDs list
|
||||
ids = ids.flatten()
|
||||
if [1] in ids:
|
||||
t.angular.z = 0.1
|
||||
t.linear.x = 0.5
|
||||
pub.publish(t)
|
||||
# loop over the detected ArUCo corners
|
||||
for markerCorner, markerID in zip(corners, ids):
|
||||
# extract the marker corners (Which are always returned in top-left, top-right, bottom-right, and bottom-left order)
|
||||
corners = markerCorner.reshape((4, 2))
|
||||
(topLeft, topRight, bottomRight, bottomLeft) = corners
|
||||
# convert each of the (x,y)-coordinates pairs to integers
|
||||
topRight = (int(topRight[0]), int(topRight[1]))
|
||||
bottomRight = (int(bottomRight[0]), int(bottomRight[1]))
|
||||
bottomLeft = (int(bottomLeft[0]), int(bottomLeft[1]))
|
||||
topLeft = (int(topLeft[0]), int(topLeft[1]))
|
||||
|
||||
# draw the bounding box of the ArUCo detection
|
||||
cv.line(frame, topLeft, topRight, (0, 255, 0), 2)
|
||||
cv.line(frame, topRight, bottomRight, (0, 255, 0), 2)
|
||||
cv.line(frame, bottomRight, bottomLeft, (0, 255, 0), 2)
|
||||
cv.line(frame, bottomLeft, topLeft, (0, 255, 0), 2)
|
||||
|
||||
# compute and draw the center (x,y)-coordinates of the ArUCo marker
|
||||
cX = int((topLeft[0] + bottomRight[0]) / 2.0)
|
||||
cY = int((topLeft[1] + bottomRight[1]) / 2.0)
|
||||
cv.circle(frame, (cX, cY), 4, (0, 0, 255), -1)
|
||||
|
||||
# draw the ArUCo marker ID on the frame
|
||||
cv.putText(
|
||||
frame,
|
||||
str(markerID),
|
||||
(topLeft[0], topLeft[1] - 15),
|
||||
cv.FONT_HERSHEY_SIMPLEX,
|
||||
0.5,
|
||||
(0, 255, 0),
|
||||
2,
|
||||
)
|
||||
if threshold > cX:
|
||||
keepLeftRight = 1
|
||||
elif w - threshold < cX:
|
||||
keepLeftRight = 2
|
||||
else:
|
||||
pass
|
||||
#No maker detected should turn now!
|
||||
if keepLeftRight == 1:
|
||||
cv.rectangle(frame, (0,0), (20,h), (0,0,255), cv.FILLED)
|
||||
elif keepLeftRight == 2:
|
||||
cv.rectangle(frame, (w-20,0), (w,h), (0,0,255), cv.FILLED)
|
||||
|
||||
|
||||
idString = "IDs:" + str(ids)
|
||||
cv.putText(
|
||||
frame,
|
||||
idString,
|
||||
(50, 50),
|
||||
cv.FONT_HERSHEY_SIMPLEX,
|
||||
1,
|
||||
(40, 10, 100),
|
||||
3,
|
||||
cv.LINE_AA,
|
||||
)
|
||||
rate.sleep()
|
||||
|
||||
# show the output frame
|
||||
cv.imshow("Frame", frame)
|
||||
key = cv.waitKey(1) & 0xFF
|
||||
|
||||
# if the 'q' key was pressed, break from the loop
|
||||
if key == ord("q"):
|
||||
break
|
||||
# do a bit of cleanup
|
||||
cv.destroyAllWindows()
|
||||
vs.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
@@ -0,0 +1,10 @@
|
||||
grosser Lenovo Laptop == "Master"
|
||||
kleiner Lenovo Laptop == "Slave"
|
||||
Auf Master: -roscore
|
||||
-astra camera node starten
|
||||
-turtlebot bringup
|
||||
|
||||
Auf Slave: -turtle node starten
|
||||
|
||||
Master kommt mit Hardware auf den Turtlebot.
|
||||
Slave zeigt den Videostream uebers Netzwerk an.
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <Servo.h>
|
||||
|
||||
#define LED 13
|
||||
char msg;
|
||||
Servo s;
|
||||
Servo s3;
|
||||
unsigned int rr = 0;
|
||||
void setup() {
|
||||
//start serial connection
|
||||
Serial.begin(9600);
|
||||
pinMode(LED, OUTPUT);
|
||||
s.attach(2);
|
||||
s3.attach(3);
|
||||
}
|
||||
|
||||
void move0()
|
||||
{
|
||||
s.write(0);
|
||||
s3.write(0);
|
||||
}
|
||||
|
||||
void move1()
|
||||
{
|
||||
s.write(180);
|
||||
s3.write(180);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
msg = Serial.read();
|
||||
if(msg == '1'){
|
||||
digitalWrite(LED, HIGH);
|
||||
move0();
|
||||
// s.write(rr);
|
||||
// s3.write(rr);
|
||||
// rr = (rr +10) % 180;
|
||||
delay(500);
|
||||
move1();
|
||||
digitalWrite(LED, LOW);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
# license removed for brevity
|
||||
import rospy
|
||||
from geometry_msgs.msg import Twist
|
||||
from imutils.video import VideoStream
|
||||
import argparse
|
||||
import imutils
|
||||
import time
|
||||
import cv2
|
||||
import sys
|
||||
import serial
|
||||
import numpy as np
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
import subprocess
|
||||
|
||||
def init():
|
||||
arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
vs = VideoStream(src=0).start()
|
||||
time.sleep(2.0)
|
||||
com = init_serial()
|
||||
#pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=10)
|
||||
#rospy.init_node('turtle_control', anonymous=True)
|
||||
#rate = rospy.Rate(10) #
|
||||
#t = Twist()
|
||||
return arucoDict, arucoParams, vs, com, #pub, rate, t
|
||||
|
||||
|
||||
def init_serial():
|
||||
for com in range(0,4):
|
||||
subprocess.run(["fuser", "/dev/ttyACM"+str(com), "-k"])
|
||||
try:
|
||||
PORT = '/dev/ttyACM' + str(com)
|
||||
BAUD = 9600
|
||||
board = serial.Serial(PORT, BAUD)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
return com
|
||||
|
||||
def talker(dictionary, params, videostream, port):
|
||||
DEVICE = '/dev/ttyACM' + str(port)
|
||||
#DEVICE = '/dev/ttyACM0'
|
||||
BAUD = 9600
|
||||
ser = serial.Serial(DEVICE, BAUD, timeout=1)
|
||||
#greeting = '0'
|
||||
#while 1:
|
||||
# if greeting == b'1':
|
||||
# break
|
||||
# print(greeting)
|
||||
# greeting = ser.read()
|
||||
#ser.write('0'.encode("utf-8"))
|
||||
while 1:
|
||||
frame = videostream.read()
|
||||
frame = imutils.resize(frame)
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(frame, dictionary, parameters=params)
|
||||
if len(corners) > 0:
|
||||
frame = marker_detected(frame, corners, port)
|
||||
cv2.imshow("markerXserial", frame)
|
||||
cv2.waitKey(1)
|
||||
|
||||
def marker_detected(frame, corners, port):
|
||||
(h, w) = frame.shape[:2]
|
||||
thresh_left = w//2 -100
|
||||
thresh_right = w//2 +100
|
||||
for markerCorner in corners:
|
||||
(tl, tr, bl, br) = markerCorner.reshape(4,2)
|
||||
tl = (int(tl[0]), int(tl[1]))
|
||||
tr = (int(tr[0]), int(tr[1]))
|
||||
bl = (int(bl[0]), int(bl[1]))
|
||||
br = (int(br[0]), int(br[1]))
|
||||
cv2.line(frame, tl, br, (0,255,0), 2)
|
||||
cv2.line(frame, tr, bl, (0,255,0), 2)
|
||||
depth_point = (int((tl[0]+br[0])//2), int((tl[1]+br[1])//2))
|
||||
cv2.circle(frame, depth_point, 8, (255,0,0), -1)
|
||||
if((tl[0] > thresh_left and tl[0] < thresh_right) or
|
||||
(tr[0] > thresh_left and tr[0] < thresh_right) or
|
||||
(bl[0] > thresh_left and bl[0] < thresh_right) or
|
||||
(br[0] > thresh_left and br[0] < thresh_right)):
|
||||
print('stop123')
|
||||
DEVICE = '/dev/ttyACM'+str(port)
|
||||
BAUD = 9600
|
||||
ser2 = serial.Serial(DEVICE, BAUD, timeout=1)
|
||||
ser2.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
#time.sleep(10)
|
||||
elif(tr[0] < thresh_left or br[0] < thresh_left):
|
||||
#ser.write('0'.encode('utf-8'))
|
||||
print('need to go right')
|
||||
#time.sleep(10)
|
||||
elif(tl[0] > thresh_right or bl[0] > thresh_right):
|
||||
#ser.write('0'.encode('utf-8'))
|
||||
print('need to go left')
|
||||
#time.sleep(10)
|
||||
return frame
|
||||
|
||||
def main():
|
||||
(dictionary, params, vs, com) = init()
|
||||
print(com)
|
||||
talker(dictionary=dictionary, params=params, videostream=vs, port=com)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
#include <Servo.h>
|
||||
|
||||
Servo servo;
|
||||
char msg;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
servo.attach(8);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
msg = Serial.read();
|
||||
if(msg == 'u')servo.write(0);
|
||||
else if(msg == 'l')servo.write(20);
|
||||
else if(msg == 'r')servo.write(180);
|
||||
else if(msg == 'd')servo.write(90);
|
||||
//delay(3000);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import serial
|
||||
import pygame as pg
|
||||
import sys
|
||||
|
||||
pg.init()
|
||||
display = pg.display.set_mode((300,300))
|
||||
|
||||
for com in range(0,4):
|
||||
try:
|
||||
PORT = '/dev/ttyUSB'+str(com)
|
||||
BAUD = 9600
|
||||
board = serial.Serial(PORT,BAUD)
|
||||
board.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
DEVICE = '/dev/ttyUSB'+str(com)
|
||||
BAUD = 9600
|
||||
ser = serial.Serial(DEVICE, BAUD, timeout = 1)
|
||||
|
||||
while(True):
|
||||
for event in pg.event.get():
|
||||
if event.type == pg.QUIT:
|
||||
pg.quit()
|
||||
sys.exit()
|
||||
|
||||
if event.type == pg.KEYDOWN:
|
||||
if event.key == pg.K_UP:
|
||||
ser.write('u'.encode('utf-8'))
|
||||
elif event.key == pg.K_LEFT:
|
||||
ser.write('l'.encode('utf-8'))
|
||||
elif event.key == pg.K_RIGHT:
|
||||
ser.write('r'.encode('utf-8'))
|
||||
elif event.key == pg.K_DOWN:
|
||||
ser.write('d'.encode('utf-8'))
|
||||
@@ -0,0 +1,52 @@
|
||||
import time
|
||||
|
||||
tl = (220, 520)
|
||||
tr = (320, 520)
|
||||
br = (320, 620)
|
||||
bl = (215, 620)
|
||||
|
||||
number_of_operation = 0
|
||||
if (tl[0] - bl[0]) in range (-10,10):
|
||||
x = [(tr[0],tl[0]), (tl[0],tr[0])][tl[0]<tr[0]]
|
||||
y = [(bl[1],tl[1]), (tl[1],bl[1])][tl[1]<bl[1]]
|
||||
elif (tl[0] - tr[0]) in range (-10,10):
|
||||
if bl[0] < tl[0]: x = (bl[0],tl[0])
|
||||
else: x = (tl[0],bl[0])
|
||||
if bl[1] < br[1]: y = (bl[1],br[1])
|
||||
else: y = (br[1],bl[1])
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
number_of_operation += 1
|
||||
number_of_operation = [0, number_of_operation/number_of_operation][number_of_operation > 0]
|
||||
print(number_of_operation)
|
||||
|
||||
tl = (320, 520)
|
||||
tr = (325, 620)
|
||||
br = (220, 620)
|
||||
bl = (229, 520)
|
||||
number_of_operation = 0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
if (tl[0] - bl[0]) in range (-10,10):
|
||||
if tl[0] < tr[0]: x = (tl[0],tr[0])
|
||||
else: x = (tr[0],tl[0])
|
||||
if tl[1] < bl[1]: y = (tl[1],bl[1])
|
||||
else: y = (bl[1],tl[1])
|
||||
elif (tl[0] - tr[0]) in range (-10,10):
|
||||
if bl[0] < tl[0]: x = (bl[0],tl[0])
|
||||
else: x = (tl[0],bl[0])
|
||||
if bl[1] < br[1]: y = (bl[1],br[1])
|
||||
else: y = (br[1],bl[1])
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
number_of_operation += 1
|
||||
print(number_of_operation)
|
||||
|
||||
|
||||
l = (0,0,0,0,20,42,320)
|
||||
for i in l:
|
||||
print(max(l))
|
||||
|
||||
start = time.time()
|
||||
while(time.time() - start) < 3:
|
||||
print(time.time() - start)
|
||||
Executable → Regular
+4
-2
@@ -4,6 +4,9 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/**
|
||||
* This tutorial demonstrates simple sending of messages over the ROS system.
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/**
|
||||
@@ -58,7 +61,7 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
geometry_msgs::Twist msg;
|
||||
|
||||
msg.linear.x = 0.9;
|
||||
msg.linear.x = 0.1;
|
||||
msg.angular.z = 0.1;
|
||||
|
||||
/**
|
||||
@@ -72,7 +75,6 @@ int main(int argc, char **argv)
|
||||
ros::spinOnce();
|
||||
|
||||
loop_rate.sleep();
|
||||
std::cout << "DOING IT" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
pixel_obere_kante = [26, 28.5, 30.5, 32, 34.5, 36, 38.5, 42, 46, 50, 55, 61.5, 69, 79, 92.5, 111, 139.5, 186, 276]
|
||||
pixel_durchschnitt = [27.5, 28.75, 30.5, 32, 34.25, 36.75, 39.25, 42.5, 46.375, 50, 55.25, 61, 68.75, 78.75, 91.64666667, 110.25, 137, 181.75, 266.25]
|
||||
pixel_max = [28, 29, 31, 33, 35, 37, 40, 43, 46, 51, 56, 62, 70, 80, 93, 113, 141, 188, 281]
|
||||
|
||||
def approximation_obere_kante(y):
|
||||
return (y/2914.2987296469)**(-1/1.0159029035)
|
||||
|
||||
def approximation_durchschnitt(y):
|
||||
return (y/2675.4910012317)**(-1/0.993434027)
|
||||
|
||||
def approximation_max(y):
|
||||
return (y/2858.4636643479)**(-1/1.0056840993)
|
||||
|
||||
def main():
|
||||
i = 100
|
||||
for y in pixel_obere_kante:
|
||||
obere_kante = approximation_obere_kante(y)
|
||||
durchschnitt = approximation_durchschnitt(y)
|
||||
maximum = approximation_max(y)
|
||||
mittel_obere_kante_durchschnitt = (obere_kante + durchschnitt)/2
|
||||
mittel_obere_kante_maximum = (obere_kante + maximum)/2
|
||||
mittel_durchschnitt_maximum = (durchschnitt + maximum)/2
|
||||
mittel_all = (obere_kante + durchschnitt + maximum)/3
|
||||
abweichung_obere_kante = abs(i - obere_kante)
|
||||
abweichung_durchschnitt = abs(i - durchschnitt)
|
||||
abweichung_maximum = abs(i - maximum)
|
||||
abweichung_mittel_obere_kante_durchschnitt = abs(i - mittel_obere_kante_durchschnitt)
|
||||
abweichung_mittel_obere_kante_maximum = abs(i - mittel_obere_kante_maximum)
|
||||
abweichung_durchschnitt_maximum = abs(i - mittel_durchschnitt_maximum)
|
||||
abweichung_all = abs(i - mittel_all)
|
||||
print("Gewünschtes Ergebnis: " + str(i))
|
||||
print("Approximation Obere Kante: " + str(obere_kante))
|
||||
print("Approximation Durchschnitt: " + str(durchschnitt))
|
||||
print("Approximation Max: " + str(maximum))
|
||||
print("Durchschnitt Obere Kante und Durchschnitt: " + str(mittel_obere_kante_durchschnitt))
|
||||
print("Durchschnitt Obere Kante und Maximum: " + str(mittel_obere_kante_maximum))
|
||||
print("Durchschnitt Durchschnitt und Maximum: " + str(mittel_durchschnitt_maximum))
|
||||
print("Durchschnitt Alle: " + str(mittel_all))
|
||||
print("Abweichung Obere Kante: " + str(abweichung_obere_kante))
|
||||
print("Abweichung Durchschnitt: " + str(abweichung_durchschnitt))
|
||||
print("Abweichung Maximum: " + str(abweichung_maximum))
|
||||
print("Abweichung Durchschnitt Obere Kante und Durchschnitt: " + str(abweichung_mittel_obere_kante_durchschnitt))
|
||||
print("Abweichung Durchschnitt Obere Kante und Maximum: " + str(abweichung_mittel_obere_kante_maximum))
|
||||
print("Abweichung Durschnitt Durchschnitt und Maximum: " + str(abweichung_durchschnitt_maximum))
|
||||
print("Abweichung Alle: " + str(abweichung_all))
|
||||
i = i - 5
|
||||
i = 100
|
||||
for y in pixel_durchschnitt:
|
||||
obere_kante = approximation_obere_kante(y)
|
||||
durchschnitt = approximation_durchschnitt(y)
|
||||
maximum = approximation_max(y)
|
||||
mittel_obere_kante_durchschnitt = (obere_kante + durchschnitt)/2
|
||||
mittel_obere_kante_maximum = (obere_kante + maximum)/2
|
||||
mittel_durchschnitt_maximum = (durchschnitt + maximum)/2
|
||||
mittel_all = (obere_kante + durchschnitt + maximum)/3
|
||||
abweichung_obere_kante = abs(i - obere_kante)
|
||||
abweichung_durchschnitt = abs(i - durchschnitt)
|
||||
abweichung_maximum = abs(i - maximum)
|
||||
abweichung_mittel_obere_kante_durchschnitt = abs(i - mittel_obere_kante_durchschnitt)
|
||||
abweichung_mittel_obere_kante_maximum = abs(i - mittel_obere_kante_maximum)
|
||||
abweichung_durchschnitt_maximum = abs(i - mittel_durchschnitt_maximum)
|
||||
abweichung_all = abs(i - mittel_all)
|
||||
print("Gewünschtes Ergebnis: " + str(i))
|
||||
print("Approximation Obere Kante: " + str(obere_kante))
|
||||
print("Approximation Durchschnitt: " + str(durchschnitt))
|
||||
print("Approximation Max: " + str(maximum))
|
||||
print("Durchschnitt Obere Kante und Durchschnitt: " + str(mittel_obere_kante_durchschnitt))
|
||||
print("Durchschnitt Obere Kante und Maximum: " + str(mittel_obere_kante_maximum))
|
||||
print("Durchschnitt Durchschnitt und Maximum: " + str(mittel_durchschnitt_maximum))
|
||||
print("Durchschnitt Alle: " + str(mittel_all))
|
||||
print("Abweichung Obere Kante: " + str(abweichung_obere_kante))
|
||||
print("Abweichung Durchschnitt: " + str(abweichung_durchschnitt))
|
||||
print("Abweichung Maximum: " + str(abweichung_maximum))
|
||||
print("Abweichung Durchschnitt Obere Kante und Durchschnitt: " + str(abweichung_mittel_obere_kante_durchschnitt))
|
||||
print("Abweichung Durchschnitt Obere Kante und Maximum: " + str(abweichung_mittel_obere_kante_maximum))
|
||||
print("Abweichung Durschnitt Durchschnitt und Maximum: " + str(abweichung_durchschnitt_maximum))
|
||||
print("Abweichung Alle: " + str(abweichung_all))
|
||||
i = i - 5
|
||||
i = 100
|
||||
for y in pixel_max:
|
||||
obere_kante = approximation_obere_kante(y)
|
||||
durchschnitt = approximation_durchschnitt(y)
|
||||
maximum = approximation_max(y)
|
||||
mittel_obere_kante_durchschnitt = (obere_kante + durchschnitt)/2
|
||||
mittel_obere_kante_maximum = (obere_kante + maximum)/2
|
||||
mittel_durchschnitt_maximum = (durchschnitt + maximum)/2
|
||||
mittel_all = (obere_kante + durchschnitt + maximum)/3
|
||||
abweichung_obere_kante = abs(i - obere_kante)
|
||||
abweichung_durchschnitt = abs(i - durchschnitt)
|
||||
abweichung_maximum = abs(i - maximum)
|
||||
abweichung_mittel_obere_kante_durchschnitt = abs(i - mittel_obere_kante_durchschnitt)
|
||||
abweichung_mittel_obere_kante_maximum = abs(i - mittel_obere_kante_maximum)
|
||||
abweichung_durchschnitt_maximum = abs(i - mittel_durchschnitt_maximum)
|
||||
abweichung_all = abs(i - mittel_all)
|
||||
print("Gewünschtes Ergebnis: " + str(i))
|
||||
print("Approximation Obere Kante: " + str(obere_kante))
|
||||
print("Approximation Durchschnitt: " + str(durchschnitt))
|
||||
print("Approximation Max: " + str(maximum))
|
||||
print("Durchschnitt Obere Kante und Durchschnitt: " + str(mittel_obere_kante_durchschnitt))
|
||||
print("Durchschnitt Obere Kante und Maximum: " + str(mittel_obere_kante_maximum))
|
||||
print("Durchschnitt Durchschnitt und Maximum: " + str(mittel_durchschnitt_maximum))
|
||||
print("Durchschnitt Alle: " + str(mittel_all))
|
||||
print("Abweichung Obere Kante: " + str(abweichung_obere_kante))
|
||||
print("Abweichung Durchschnitt: " + str(abweichung_durchschnitt))
|
||||
print("Abweichung Maximum: " + str(abweichung_maximum))
|
||||
print("Abweichung Durchschnitt Obere Kante und Durchschnitt: " + str(abweichung_mittel_obere_kante_durchschnitt))
|
||||
print("Abweichung Durchschnitt Obere Kante und Maximum: " + str(abweichung_mittel_obere_kante_maximum))
|
||||
print("Abweichung Durschnitt Durchschnitt und Maximum: " + str(abweichung_durchschnitt_maximum))
|
||||
print("Abweichung Alle: " + str(abweichung_all))
|
||||
i = i - 5
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,193 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import roslib
|
||||
import sys
|
||||
import rospy
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
import serial
|
||||
import subprocess
|
||||
from std_msgs.msg import String
|
||||
from sensor_msgs.msg import Image
|
||||
from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
|
||||
|
||||
class tutel():
|
||||
def __init__(self, astra_rgb_topic : str, astra_depth_topic : str, velocity_factor : float = 1.0):
|
||||
#needed variables, velocity factor is a multiplier for the bot, might be changed later
|
||||
#target_id used to remember the last id the tutel found, set to 0 at the beginning
|
||||
self.target_id = TARGET
|
||||
|
||||
#auruco init, best dictionary we found atm
|
||||
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
|
||||
self.arucoParams = cv2.aruco.DetectorParameters_create()
|
||||
|
||||
#minimal depth we recognize, still testing for values!
|
||||
self.maxMinDepth = DEPTH
|
||||
|
||||
#cv related
|
||||
#rgb related
|
||||
self.lastConernerTime = time.time()
|
||||
self.rgb_bridge = CvBridge()
|
||||
self.search = True
|
||||
#depth related
|
||||
self.depth_bridge = CvBridge()
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
self.top_left = (-1,-1)
|
||||
self.top_right = (-1,-1)
|
||||
self.bottom_right = (-1,-1)
|
||||
self.bottom_left = (-1,-1)
|
||||
self.number_of_operations = 0
|
||||
self.number_of_pixels = 0
|
||||
|
||||
#ros node related
|
||||
rospy.init_node("turtle_control", anonymous=True)
|
||||
|
||||
#update rate can be increased
|
||||
self.rate = rospy.Rate(15)
|
||||
|
||||
#Sub init
|
||||
self.rgb_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
|
||||
self.depth_sub = rospy.Subscriber(astra_depth_topic, Image, self.callback_depth)
|
||||
|
||||
#we wait for both publishers, camera topics, to send information
|
||||
def wait_publishers(self, astra_rgb_topic, astra_depth_topic):
|
||||
while True:
|
||||
if any(astra_rgb_topic in topic_list for topic_list in rospy.get_published_topics()) and any(astra_depth_topic in topic_list for topic_list in rospy.get_published_topics()):
|
||||
break
|
||||
print("Waiting for {} and {} to start.".format(astra_rgb_topic, astra_depth_topic))
|
||||
rospy.sleep(1)
|
||||
|
||||
def callback_rgb(self, data):
|
||||
try:
|
||||
rgb_image = self.rgb_bridge.imgmsg_to_cv2(data, "bgr8")
|
||||
cv2.rotate(rgb_image, cv2.ROTATE_180, rgb_image)
|
||||
(self.h, self.w) = rgb_image.shape[:2]
|
||||
except CvBridgeError as e:
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
for id_x in ids:
|
||||
if id_x != 0:
|
||||
self.target_id = id_x
|
||||
break
|
||||
x = np.where(ids == self.target_id)
|
||||
if len(x[0]) > 0:
|
||||
fitting_corners = corners[x[0][0]]
|
||||
rgb_image = self.markDetected(rgb_image, fitting_corners)
|
||||
self.lastConernerTime = time.time()
|
||||
elif(self.lastConernerTime - time.time()) < 1./2:
|
||||
self.depth_state = False
|
||||
|
||||
#some additional info on screen
|
||||
depth_str = "Depth_State:" + str(self.depth_state) + " Depth:" + str(self.last_depth)
|
||||
cv2.putText(rgb_image, depth_str, (10,60), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
pixel_str = "Number_of_pixel:" + str(self.number_of_pixels)
|
||||
cv2.putText(rgb_image, pixel_str, (10,90), cv2.FONT_HERSHEY_TRIPLEX, 1, (255,0,0), 2, cv2.LINE_8)
|
||||
cv2.line(rgb_image, (self.w//2, 0), (self.w//2, self.h), (0,255,0), 2)
|
||||
self.rate.sleep()
|
||||
cv2.imshow("Tutel", rgb_image)
|
||||
cv2.waitKey(1)
|
||||
|
||||
|
||||
def callback_depth(self, data):
|
||||
if self.depth_state:
|
||||
depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough")
|
||||
cv2.rotate(depth_image, cv2.ROTATE_180, depth_image)
|
||||
if self.depth_counter == 0:
|
||||
#pass
|
||||
self.last_depth = 10.0
|
||||
x = (0,0)
|
||||
y = (0,0)
|
||||
#x and y are swapped, because
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
self.number_of_pixels += 1
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
|
||||
if len(depth_values)>0 and ((max(depth_values) > self.last_depth-100 and max(depth_values) < self.last_depth+100) or self.last_depth == 10):
|
||||
self.last_depth = max(depth_values)
|
||||
print(max(depth_values))
|
||||
else:
|
||||
self.last_depth = self.last_depth
|
||||
lengths = [abs(self.top_left[0]-self.top_right[0]), abs(self.top_left[1] - self.bottom_left[1]), abs(self.top_right[1]-self.bottom_right[1]), abs(self.bottom_right[0]-self.bottom_left[0])]
|
||||
#pixel_length = (abs(self.top_left[0]-self.top_right[0]) + abs(self.top_left[1] - self.bottom_left[1]) + abs(self.top_right[1]-self.bottom_right[1]) + abs(self.bottom_right[0]-self.bottom_left[0]))/4
|
||||
pixel_length = max(lengths)
|
||||
print(self.last_depth, self.number_of_pixels, pixel_length)
|
||||
self.number_of_operations = 0
|
||||
self.number_of_pixels = 0
|
||||
pixel_length = 0
|
||||
#cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
self.depth_counter = 0
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
|
||||
def markDetected(self, image, corners):
|
||||
for markerCorner in corners:
|
||||
(self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2))
|
||||
self.top_left = (int(self.top_left[0]), int(self.top_left[1]))
|
||||
self.top_right = (int(self.top_right[0]), int(self.top_right[1]))
|
||||
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
|
||||
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
|
||||
|
||||
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
|
||||
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
|
||||
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
|
||||
|
||||
self.depth_state = True
|
||||
return image
|
||||
|
||||
|
||||
def move_arm(self):
|
||||
self.s.write('1'.encode('utf-8'))
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv)!=3:
|
||||
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
|
||||
print("Like: depth_reader.py /camera/rgb/image_raw /camera/depth/image_raw")
|
||||
return 1
|
||||
ic = tutel(str(sys.argv[1]),str(sys.argv[2]))
|
||||
try:
|
||||
rospy.spin()
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down")
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
thresh = 255
|
||||
for x in range(tl.x, tr.x+1):
|
||||
for y in range(tl.y, bl.y+1):
|
||||
darkness += depth.raw.image[x,y]
|
||||
nop += 1
|
||||
for y in range(tl.y, tr.y+1):
|
||||
for x in range(tl.x, bl.x+1):
|
||||
darkness += depth.raw.image[x,y]
|
||||
nop += 1
|
||||
darkness /= nop
|
||||
if darkness > thresh:
|
||||
t.linear.x = 0.0
|
||||
t.angular.z = 0.0
|
||||
Binary file not shown.
@@ -1,721 +0,0 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: /home/dennis/catkin_ws/src/turtle_control
|
||||
# It was generated by CMake: /usr/bin/cmake
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//Builds the googlemock subproject
|
||||
BUILD_GMOCK:BOOL=ON
|
||||
|
||||
//Build dynamically-linked binaries
|
||||
BUILD_SHARED_LIBS:BOOL=ON
|
||||
|
||||
//Catkin enable testing
|
||||
CATKIN_ENABLE_TESTING:BOOL=ON
|
||||
|
||||
//Prefix to apply to package generated via gendebian
|
||||
CATKIN_PACKAGE_PREFIX:STRING=
|
||||
|
||||
//Catkin skip testing
|
||||
CATKIN_SKIP_TESTING:BOOL=OFF
|
||||
|
||||
//Replace the CMake install command with a custom implementation
|
||||
// using symlinks instead of copying resources
|
||||
CATKIN_SYMLINK_INSTALL:BOOL=OFF
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_ADDR2LINE:FILEPATH=/usr/bin/addr2line
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_AR:FILEPATH=/usr/bin/ar
|
||||
|
||||
//Choose the type of build, options are: None Debug Release RelWithDebInfo
|
||||
// MinSizeRel ...
|
||||
CMAKE_BUILD_TYPE:STRING=
|
||||
|
||||
//Enable/Disable color output during build.
|
||||
CMAKE_COLOR_MAKEFILE:BOOL=ON
|
||||
|
||||
//CXX compiler
|
||||
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
|
||||
|
||||
//A wrapper around 'ar' adding the appropriate '--plugin' option
|
||||
// for the GCC compiler
|
||||
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-9
|
||||
|
||||
//A wrapper around 'ranlib' adding the appropriate '--plugin' option
|
||||
// for the GCC compiler
|
||||
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-9
|
||||
|
||||
//Flags used by the CXX compiler during all build types.
|
||||
CMAKE_CXX_FLAGS:STRING=
|
||||
|
||||
//Flags used by the CXX compiler during DEBUG builds.
|
||||
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
|
||||
|
||||
//Flags used by the CXX compiler during MINSIZEREL builds.
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELEASE builds.
|
||||
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
||||
|
||||
//C compiler
|
||||
CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
|
||||
|
||||
//A wrapper around 'ar' adding the appropriate '--plugin' option
|
||||
// for the GCC compiler
|
||||
CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-9
|
||||
|
||||
//A wrapper around 'ranlib' adding the appropriate '--plugin' option
|
||||
// for the GCC compiler
|
||||
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-9
|
||||
|
||||
//Flags used by the C compiler during all build types.
|
||||
CMAKE_C_FLAGS:STRING=
|
||||
|
||||
//Flags used by the C compiler during DEBUG builds.
|
||||
CMAKE_C_FLAGS_DEBUG:STRING=-g
|
||||
|
||||
//Flags used by the C compiler during MINSIZEREL builds.
|
||||
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
||||
|
||||
//Flags used by the C compiler during RELEASE builds.
|
||||
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
||||
|
||||
//Flags used by the C compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_DLLTOOL:FILEPATH=CMAKE_DLLTOOL-NOTFOUND
|
||||
|
||||
//Flags used by the linker during all build types.
|
||||
CMAKE_EXE_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during DEBUG builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during MINSIZEREL builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during RELEASE builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during RELWITHDEBINFO builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Enable/Disable output of compile commands during generation.
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
|
||||
|
||||
//User executables (bin)
|
||||
CMAKE_INSTALL_BINDIR:PATH=bin
|
||||
|
||||
//Read-only architecture-independent data (DATAROOTDIR)
|
||||
CMAKE_INSTALL_DATADIR:PATH=
|
||||
|
||||
//Read-only architecture-independent data root (share)
|
||||
CMAKE_INSTALL_DATAROOTDIR:PATH=share
|
||||
|
||||
//Documentation root (DATAROOTDIR/doc/PROJECT_NAME)
|
||||
CMAKE_INSTALL_DOCDIR:PATH=
|
||||
|
||||
//C header files (include)
|
||||
CMAKE_INSTALL_INCLUDEDIR:PATH=include
|
||||
|
||||
//Info documentation (DATAROOTDIR/info)
|
||||
CMAKE_INSTALL_INFODIR:PATH=
|
||||
|
||||
//Object code libraries (lib)
|
||||
CMAKE_INSTALL_LIBDIR:PATH=lib
|
||||
|
||||
//Program executables (libexec)
|
||||
CMAKE_INSTALL_LIBEXECDIR:PATH=libexec
|
||||
|
||||
//Locale-dependent data (DATAROOTDIR/locale)
|
||||
CMAKE_INSTALL_LOCALEDIR:PATH=
|
||||
|
||||
//Modifiable single-machine data (var)
|
||||
CMAKE_INSTALL_LOCALSTATEDIR:PATH=var
|
||||
|
||||
//Man documentation (DATAROOTDIR/man)
|
||||
CMAKE_INSTALL_MANDIR:PATH=
|
||||
|
||||
//C header files for non-gcc (/usr/include)
|
||||
CMAKE_INSTALL_OLDINCLUDEDIR:PATH=/usr/include
|
||||
|
||||
//Install path prefix, prepended onto install directories.
|
||||
CMAKE_INSTALL_PREFIX:PATH=/usr/local
|
||||
|
||||
//Run-time variable data (LOCALSTATEDIR/run)
|
||||
CMAKE_INSTALL_RUNSTATEDIR:PATH=
|
||||
|
||||
//System admin executables (sbin)
|
||||
CMAKE_INSTALL_SBINDIR:PATH=sbin
|
||||
|
||||
//Modifiable architecture-independent data (com)
|
||||
CMAKE_INSTALL_SHAREDSTATEDIR:PATH=com
|
||||
|
||||
//Read-only single-machine data (etc)
|
||||
CMAKE_INSTALL_SYSCONFDIR:PATH=etc
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_LINKER:FILEPATH=/usr/bin/ld
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// all build types.
|
||||
CMAKE_MODULE_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// DEBUG builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// MINSIZEREL builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELEASE builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELWITHDEBINFO builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_NM:FILEPATH=/usr/bin/nm
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=turtle_control
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION:STATIC=1.10.0
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_MAJOR:STATIC=1
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_MINOR:STATIC=10
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_PATCH:STATIC=0
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_TWEAK:STATIC=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_READELF:FILEPATH=/usr/bin/readelf
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during all build types.
|
||||
CMAKE_SHARED_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//If set, runtime paths are not added when installing shared libraries,
|
||||
// but are added when building.
|
||||
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
|
||||
|
||||
//If set, runtime paths are not added when using shared libraries.
|
||||
CMAKE_SKIP_RPATH:BOOL=NO
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during all build types.
|
||||
CMAKE_STATIC_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_STRIP:FILEPATH=/usr/bin/strip
|
||||
|
||||
//If this value is on, makefiles will be generated without the
|
||||
// .SILENT directive, and all commands will be echoed to the console
|
||||
// during the make. This is useful for debugging only. With Visual
|
||||
// Studio IDE projects all commands are done without /nologo.
|
||||
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
|
||||
|
||||
//Path to a program.
|
||||
DOXYGEN_EXECUTABLE:FILEPATH=DOXYGEN_EXECUTABLE-NOTFOUND
|
||||
|
||||
//Path to a program.
|
||||
EMPY_EXECUTABLE:FILEPATH=EMPY_EXECUTABLE-NOTFOUND
|
||||
|
||||
//Empy script
|
||||
EMPY_SCRIPT:STRING=/usr/lib/python3/dist-packages/em.py
|
||||
|
||||
//Path to a library.
|
||||
GMOCK_LIBRARY:FILEPATH=GMOCK_LIBRARY-NOTFOUND
|
||||
|
||||
//Path to a library.
|
||||
GMOCK_LIBRARY_DEBUG:FILEPATH=GMOCK_LIBRARY_DEBUG-NOTFOUND
|
||||
|
||||
//Path to a library.
|
||||
GMOCK_MAIN_LIBRARY:FILEPATH=GMOCK_MAIN_LIBRARY-NOTFOUND
|
||||
|
||||
//Path to a library.
|
||||
GMOCK_MAIN_LIBRARY_DEBUG:FILEPATH=GMOCK_MAIN_LIBRARY_DEBUG-NOTFOUND
|
||||
|
||||
//The directory containing a CMake configuration file for GMock.
|
||||
GMock_DIR:PATH=GMock_DIR-NOTFOUND
|
||||
|
||||
//Path to a file.
|
||||
GTEST_INCLUDE_DIR:PATH=/usr/include
|
||||
|
||||
//Path to a library.
|
||||
GTEST_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libgtest.a
|
||||
|
||||
//Path to a library.
|
||||
GTEST_LIBRARY_DEBUG:FILEPATH=GTEST_LIBRARY_DEBUG-NOTFOUND
|
||||
|
||||
//Path to a library.
|
||||
GTEST_MAIN_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libgtest_main.a
|
||||
|
||||
//Path to a library.
|
||||
GTEST_MAIN_LIBRARY_DEBUG:FILEPATH=GTEST_MAIN_LIBRARY_DEBUG-NOTFOUND
|
||||
|
||||
//The directory containing a CMake configuration file for GTest.
|
||||
GTest_DIR:PATH=GTest_DIR-NOTFOUND
|
||||
|
||||
//Enable installation of googletest. (Projects embedding googletest
|
||||
// may want to turn this OFF.)
|
||||
INSTALL_GTEST:BOOL=OFF
|
||||
|
||||
//lsb_release executable was found
|
||||
LSB_FOUND:BOOL=TRUE
|
||||
|
||||
//Path to a program.
|
||||
LSB_RELEASE_EXECUTABLE:FILEPATH=/usr/bin/lsb_release
|
||||
|
||||
//Path to a program.
|
||||
NOSETESTS:FILEPATH=/usr/bin/nosetests3
|
||||
|
||||
//Path to a program.
|
||||
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3
|
||||
|
||||
//Specify specific Python version to use ('major.minor' or 'major')
|
||||
PYTHON_VERSION:STRING=3
|
||||
|
||||
//Location of Python module em
|
||||
PY_EM:STRING=/usr/lib/python3/dist-packages/em.py
|
||||
|
||||
//Path to a library.
|
||||
RT_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/librt.so
|
||||
|
||||
//Enable debian style python package layout
|
||||
SETUPTOOLS_DEB_LAYOUT:BOOL=ON
|
||||
|
||||
//Name of the computer/site where compile is being run
|
||||
SITE:STRING=xubuntu
|
||||
|
||||
//LSB Distrib tag
|
||||
UBUNTU:BOOL=TRUE
|
||||
|
||||
//LSB Distrib - codename tag
|
||||
UBUNTU_FOCAL:BOOL=TRUE
|
||||
|
||||
//Path to a file.
|
||||
_gmock_INCLUDES:FILEPATH=/usr/src/googletest/googlemock/include/gmock/gmock.h
|
||||
|
||||
//Path to a file.
|
||||
_gmock_SOURCES:FILEPATH=/usr/src/gmock/src/gmock.cc
|
||||
|
||||
//Path to a file.
|
||||
_gtest_INCLUDES:FILEPATH=/usr/include/gtest/gtest.h
|
||||
|
||||
//Path to a file.
|
||||
_gtest_SOURCES:FILEPATH=/usr/src/gtest/src/gtest.cc
|
||||
|
||||
//The directory containing a CMake configuration file for catkin.
|
||||
catkin_DIR:PATH=/opt/ros/noetic/share/catkin/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for cpp_common.
|
||||
cpp_common_DIR:PATH=/opt/ros/noetic/share/cpp_common/cmake
|
||||
|
||||
//Value Computed by CMake
|
||||
gmock_BINARY_DIR:STATIC=/home/dennis/catkin_ws/src/turtle_control/gtest/googlemock
|
||||
|
||||
//Dependencies for the target
|
||||
gmock_LIB_DEPENDS:STATIC=general;gtest;
|
||||
|
||||
//Value Computed by CMake
|
||||
gmock_SOURCE_DIR:STATIC=/usr/src/googletest/googlemock
|
||||
|
||||
//Build all of Google Mock's own tests.
|
||||
gmock_build_tests:BOOL=OFF
|
||||
|
||||
//Dependencies for the target
|
||||
gmock_main_LIB_DEPENDS:STATIC=general;gmock;
|
||||
|
||||
//Value Computed by CMake
|
||||
googletest-distribution_BINARY_DIR:STATIC=/home/dennis/catkin_ws/src/turtle_control/gtest
|
||||
|
||||
//Value Computed by CMake
|
||||
googletest-distribution_SOURCE_DIR:STATIC=/usr/src/googletest
|
||||
|
||||
//Value Computed by CMake
|
||||
gtest_BINARY_DIR:STATIC=/home/dennis/catkin_ws/src/turtle_control/gtest/googletest
|
||||
|
||||
//Value Computed by CMake
|
||||
gtest_SOURCE_DIR:STATIC=/usr/src/googletest/googletest
|
||||
|
||||
//Build gtest's sample programs.
|
||||
gtest_build_samples:BOOL=OFF
|
||||
|
||||
//Build all of gtest's own tests.
|
||||
gtest_build_tests:BOOL=OFF
|
||||
|
||||
//Disable uses of pthreads in gtest.
|
||||
gtest_disable_pthreads:BOOL=OFF
|
||||
|
||||
//Use shared (DLL) run-time lib even when Google Test is built
|
||||
// as static lib.
|
||||
gtest_force_shared_crt:BOOL=OFF
|
||||
|
||||
//Build gtest with internal symbols hidden in shared libraries.
|
||||
gtest_hide_internal_symbols:BOOL=OFF
|
||||
|
||||
//Dependencies for the target
|
||||
gtest_main_LIB_DEPENDS:STATIC=general;gtest;
|
||||
|
||||
//Path to a library.
|
||||
lib:FILEPATH=/opt/ros/noetic/lib/libxmlrpcpp.so
|
||||
|
||||
//The directory containing a CMake configuration file for message_runtime.
|
||||
message_runtime_DIR:PATH=/opt/ros/noetic/share/message_runtime/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for rosconsole.
|
||||
rosconsole_DIR:PATH=/opt/ros/noetic/share/rosconsole/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for roscpp.
|
||||
roscpp_DIR:PATH=/opt/ros/noetic/share/roscpp/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for roscpp_serialization.
|
||||
roscpp_serialization_DIR:PATH=/opt/ros/noetic/share/roscpp_serialization/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for roscpp_traits.
|
||||
roscpp_traits_DIR:PATH=/opt/ros/noetic/share/roscpp_traits/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for rosgraph_msgs.
|
||||
rosgraph_msgs_DIR:PATH=/opt/ros/noetic/share/rosgraph_msgs/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for rospy.
|
||||
rospy_DIR:PATH=/opt/ros/noetic/share/rospy/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for rostime.
|
||||
rostime_DIR:PATH=/opt/ros/noetic/share/rostime/cmake
|
||||
|
||||
//The directory containing a CMake configuration file for std_msgs.
|
||||
std_msgs_DIR:PATH=/opt/ros/noetic/share/std_msgs/cmake
|
||||
|
||||
//Value Computed by CMake
|
||||
turtle_control_BINARY_DIR:STATIC=/home/dennis/catkin_ws/src/turtle_control
|
||||
|
||||
//Value Computed by CMake
|
||||
turtle_control_SOURCE_DIR:STATIC=/home/dennis/catkin_ws/src/turtle_control
|
||||
|
||||
//The directory containing a CMake configuration file for xmlrpcpp.
|
||||
xmlrpcpp_DIR:PATH=/opt/ros/noetic/share/xmlrpcpp/cmake
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//catkin environment
|
||||
CATKIN_ENV:INTERNAL=/home/dennis/catkin_ws/src/turtle_control/catkin_generated/env_cached.sh
|
||||
CATKIN_TEST_RESULTS_DIR:INTERNAL=/home/dennis/catkin_ws/src/turtle_control/test_results
|
||||
//ADVANCED property for variable: CMAKE_ADDR2LINE
|
||||
CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_AR
|
||||
CMAKE_AR-ADVANCED:INTERNAL=1
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=/home/dennis/catkin_ws/src/turtle_control
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=16
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=3
|
||||
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
|
||||
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER
|
||||
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER_AR
|
||||
CMAKE_CXX_COMPILER_AR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER_RANLIB
|
||||
CMAKE_CXX_COMPILER_RANLIB-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_COMPILER
|
||||
CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_COMPILER_AR
|
||||
CMAKE_C_COMPILER_AR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_COMPILER_RANLIB
|
||||
CMAKE_C_COMPILER_RANLIB-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_DLLTOOL
|
||||
CMAKE_DLLTOOL-ADVANCED:INTERNAL=1
|
||||
//Executable file format
|
||||
CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
|
||||
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Test CMAKE_HAVE_LIBC_PTHREAD
|
||||
CMAKE_HAVE_LIBC_PTHREAD:INTERNAL=
|
||||
//Have library pthreads
|
||||
CMAKE_HAVE_PTHREADS_CREATE:INTERNAL=
|
||||
//Have library pthread
|
||||
CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1
|
||||
//Have include pthread.h
|
||||
CMAKE_HAVE_PTHREAD_H:INTERNAL=1
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=/home/dennis/catkin_ws/src/turtle_control
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_BINDIR
|
||||
CMAKE_INSTALL_BINDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_DATADIR
|
||||
CMAKE_INSTALL_DATADIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_DATAROOTDIR
|
||||
CMAKE_INSTALL_DATAROOTDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_DOCDIR
|
||||
CMAKE_INSTALL_DOCDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_INCLUDEDIR
|
||||
CMAKE_INSTALL_INCLUDEDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_INFODIR
|
||||
CMAKE_INSTALL_INFODIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_LIBDIR
|
||||
CMAKE_INSTALL_LIBDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_LIBEXECDIR
|
||||
CMAKE_INSTALL_LIBEXECDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_LOCALEDIR
|
||||
CMAKE_INSTALL_LOCALEDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_LOCALSTATEDIR
|
||||
CMAKE_INSTALL_LOCALSTATEDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_MANDIR
|
||||
CMAKE_INSTALL_MANDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_OLDINCLUDEDIR
|
||||
CMAKE_INSTALL_OLDINCLUDEDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_RUNSTATEDIR
|
||||
CMAKE_INSTALL_RUNSTATEDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_SBINDIR
|
||||
CMAKE_INSTALL_SBINDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_SHAREDSTATEDIR
|
||||
CMAKE_INSTALL_SHAREDSTATEDIR-ADVANCED:INTERNAL=1
|
||||
//Install .so files without execute permission.
|
||||
CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_SYSCONFDIR
|
||||
CMAKE_INSTALL_SYSCONFDIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_LINKER
|
||||
CMAKE_LINKER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
|
||||
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
|
||||
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_NM
|
||||
CMAKE_NM-ADVANCED:INTERNAL=1
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=4
|
||||
//ADVANCED property for variable: CMAKE_OBJCOPY
|
||||
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_OBJDUMP
|
||||
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RANLIB
|
||||
CMAKE_RANLIB-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_READELF
|
||||
CMAKE_READELF-ADVANCED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.16
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
||||
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
|
||||
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_RPATH
|
||||
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
|
||||
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STRIP
|
||||
CMAKE_STRIP-ADVANCED:INTERNAL=1
|
||||
//uname command
|
||||
CMAKE_UNAME:INTERNAL=/usr/bin/uname
|
||||
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
|
||||
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
//Details about finding PY_em
|
||||
FIND_PACKAGE_MESSAGE_DETAILS_PY_em:INTERNAL=[/usr/lib/python3/dist-packages/em.py][v()]
|
||||
//Details about finding PythonInterp
|
||||
FIND_PACKAGE_MESSAGE_DETAILS_PythonInterp:INTERNAL=[/usr/bin/python3][v3.8.10()]
|
||||
//Details about finding Threads
|
||||
FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()]
|
||||
GMOCK_FROM_SOURCE_FOUND:INTERNAL=TRUE
|
||||
GMOCK_FROM_SOURCE_INCLUDE_DIRS:INTERNAL=/usr/src/googletest/googlemock/include
|
||||
GMOCK_FROM_SOURCE_LIBRARIES:INTERNAL=gmock
|
||||
GMOCK_FROM_SOURCE_LIBRARY_DIRS:INTERNAL=/home/dennis/catkin_ws/src/turtle_control/gmock
|
||||
GMOCK_FROM_SOURCE_MAIN_LIBRARIES:INTERNAL=gmock_main
|
||||
//ADVANCED property for variable: GMOCK_LIBRARY
|
||||
GMOCK_LIBRARY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GMOCK_LIBRARY_DEBUG
|
||||
GMOCK_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GMOCK_MAIN_LIBRARY
|
||||
GMOCK_MAIN_LIBRARY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GMOCK_MAIN_LIBRARY_DEBUG
|
||||
GMOCK_MAIN_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
|
||||
GTEST_FROM_SOURCE_FOUND:INTERNAL=TRUE
|
||||
GTEST_FROM_SOURCE_INCLUDE_DIRS:INTERNAL=/usr/include
|
||||
GTEST_FROM_SOURCE_LIBRARIES:INTERNAL=gtest
|
||||
GTEST_FROM_SOURCE_LIBRARY_DIRS:INTERNAL=/home/dennis/catkin_ws/src/turtle_control/gtest
|
||||
GTEST_FROM_SOURCE_MAIN_LIBRARIES:INTERNAL=gtest_main
|
||||
//ADVANCED property for variable: GTEST_INCLUDE_DIR
|
||||
GTEST_INCLUDE_DIR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GTEST_LIBRARY
|
||||
GTEST_LIBRARY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GTEST_LIBRARY_DEBUG
|
||||
GTEST_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GTEST_MAIN_LIBRARY
|
||||
GTEST_MAIN_LIBRARY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: GTEST_MAIN_LIBRARY_DEBUG
|
||||
GTEST_MAIN_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: PYTHON_EXECUTABLE
|
||||
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
|
||||
//This needs to be in PYTHONPATH when 'setup.py install' is called.
|
||||
// And it needs to match. But setuptools won't tell us where
|
||||
// it will install things.
|
||||
PYTHON_INSTALL_DIR:INTERNAL=lib/python3/dist-packages
|
||||
//CMAKE_INSTALL_PREFIX during last run
|
||||
_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX:INTERNAL=/usr/local
|
||||
//ADVANCED property for variable: gmock_build_tests
|
||||
gmock_build_tests-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: gtest_build_samples
|
||||
gtest_build_samples-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: gtest_build_tests
|
||||
gtest_build_tests-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: gtest_disable_pthreads
|
||||
gtest_disable_pthreads-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: gtest_force_shared_crt
|
||||
gtest_force_shared_crt-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: gtest_hide_internal_symbols
|
||||
gtest_hide_internal_symbols-ADVANCED:INTERNAL=1
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
project(turtle_control)
|
||||
|
||||
## Compile as C++11, supported in ROS Kinetic and newer
|
||||
# add_compile_options(-std=c++11)
|
||||
|
||||
## Find catkin macros and libraries
|
||||
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
|
||||
## is used, also find other catkin packages
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
roscpp
|
||||
rospy
|
||||
)
|
||||
|
||||
## System dependencies are found with CMake's conventions
|
||||
# find_package(Boost REQUIRED COMPONENTS system)
|
||||
|
||||
|
||||
## Uncomment this if the package has a setup.py. This macro ensures
|
||||
## modules and global scripts declared therein get installed
|
||||
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
|
||||
# catkin_python_setup()
|
||||
|
||||
################################################
|
||||
## Declare ROS messages, services and actions ##
|
||||
################################################
|
||||
|
||||
## To declare and build messages, services or actions from within this
|
||||
## package, follow these steps:
|
||||
## * Let MSG_DEP_SET be the set of packages whose message types you use in
|
||||
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
|
||||
## * In the file package.xml:
|
||||
## * add a build_depend tag for "message_generation"
|
||||
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
|
||||
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
|
||||
## but can be declared for certainty nonetheless:
|
||||
## * add a exec_depend tag for "message_runtime"
|
||||
## * In this file (CMakeLists.txt):
|
||||
## * add "message_generation" and every package in MSG_DEP_SET to
|
||||
## find_package(catkin REQUIRED COMPONENTS ...)
|
||||
## * add "message_runtime" and every package in MSG_DEP_SET to
|
||||
## catkin_package(CATKIN_DEPENDS ...)
|
||||
## * uncomment the add_*_files sections below as needed
|
||||
## and list every .msg/.srv/.action file to be processed
|
||||
## * uncomment the generate_messages entry below
|
||||
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
|
||||
|
||||
## Generate messages in the 'msg' folder
|
||||
# add_message_files(
|
||||
# FILES
|
||||
# Message1.msg
|
||||
# Message2.msg
|
||||
# )
|
||||
|
||||
## Generate services in the 'srv' folder
|
||||
# add_service_files(
|
||||
# FILES
|
||||
# Service1.srv
|
||||
# Service2.srv
|
||||
# )
|
||||
|
||||
## Generate actions in the 'action' folder
|
||||
# add_action_files(
|
||||
# FILES
|
||||
# Action1.action
|
||||
# Action2.action
|
||||
# )
|
||||
|
||||
## Generate added messages and services with any dependencies listed here
|
||||
# generate_messages(
|
||||
# DEPENDENCIES
|
||||
# std_msgs # Or other packages containing msgs
|
||||
# )
|
||||
|
||||
################################################
|
||||
## Declare ROS dynamic reconfigure parameters ##
|
||||
################################################
|
||||
|
||||
## To declare and build dynamic reconfigure parameters within this
|
||||
## package, follow these steps:
|
||||
## * In the file package.xml:
|
||||
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
|
||||
## * In this file (CMakeLists.txt):
|
||||
## * add "dynamic_reconfigure" to
|
||||
## find_package(catkin REQUIRED COMPONENTS ...)
|
||||
## * uncomment the "generate_dynamic_reconfigure_options" section below
|
||||
## and list every .cfg file to be processed
|
||||
|
||||
## Generate dynamic reconfigure parameters in the 'cfg' folder
|
||||
# generate_dynamic_reconfigure_options(
|
||||
# cfg/DynReconf1.cfg
|
||||
# cfg/DynReconf2.cfg
|
||||
# )
|
||||
|
||||
###################################
|
||||
## catkin specific configuration ##
|
||||
###################################
|
||||
## The catkin_package macro generates cmake config files for your package
|
||||
## Declare things to be passed to dependent projects
|
||||
## INCLUDE_DIRS: uncomment this if your package contains header files
|
||||
## LIBRARIES: libraries you create in this project that dependent projects also need
|
||||
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
||||
catkin_package(
|
||||
# INCLUDE_DIRS include
|
||||
# LIBRARIES turtle_control
|
||||
# CATKIN_DEPENDS roscpp rospy
|
||||
# DEPENDS system_lib
|
||||
)
|
||||
|
||||
###########
|
||||
## Build ##
|
||||
###########
|
||||
|
||||
## Specify additional locations of header files
|
||||
## Your package locations should be listed before other locations
|
||||
include_directories(
|
||||
# include
|
||||
${catkin_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
## Declare a C++ library
|
||||
# add_library(${PROJECT_NAME}
|
||||
# src/${PROJECT_NAME}/turtle_control.cpp
|
||||
# )
|
||||
|
||||
## Add cmake target dependencies of the library
|
||||
## as an example, code may need to be generated before libraries
|
||||
## either from message generation or dynamic reconfigure
|
||||
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
|
||||
## Declare a C++ executable
|
||||
## With catkin_make all packages are built within a single CMake context
|
||||
## The recommended prefix ensures that target names across packages don't collide
|
||||
add_executable(${PROJECT_NAME}_node src/turtle_mover.cpp)
|
||||
|
||||
## Rename C++ executable without prefix
|
||||
## The above recommended prefix causes long target names, the following renames the
|
||||
## target back to the shorter version for ease of user use
|
||||
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
|
||||
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
|
||||
|
||||
## Add cmake target dependencies of the executable
|
||||
## same as for the library above
|
||||
add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
|
||||
## Specify libraries to link a library or executable target against
|
||||
target_link_libraries(${PROJECT_NAME}_node
|
||||
${catkin_LIBRARIES}
|
||||
)
|
||||
|
||||
#############
|
||||
## Install ##
|
||||
#############
|
||||
|
||||
# all install targets should use catkin DESTINATION variables
|
||||
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
|
||||
|
||||
## Mark executable scripts (Python etc.) for installation
|
||||
## in contrast to setup.py, you can choose the destination
|
||||
# catkin_install_python(PROGRAMS
|
||||
# scripts/my_python_script
|
||||
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
# )
|
||||
|
||||
## Mark executables for installation
|
||||
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
|
||||
# install(TARGETS ${PROJECT_NAME}_node
|
||||
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
# )
|
||||
|
||||
## Mark libraries for installation
|
||||
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||
# install(TARGETS ${PROJECT_NAME}
|
||||
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
|
||||
# )
|
||||
|
||||
## Mark cpp header files for installation
|
||||
# install(DIRECTORY include/${PROJECT_NAME}/
|
||||
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||
# FILES_MATCHING PATTERN "*.h"
|
||||
# PATTERN ".svn" EXCLUDE
|
||||
# )
|
||||
|
||||
## Mark other files for installation (e.g. launch and bag files, etc.)
|
||||
# install(FILES
|
||||
# # myfile1
|
||||
# # myfile2
|
||||
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
||||
# )
|
||||
|
||||
#############
|
||||
## Testing ##
|
||||
#############
|
||||
|
||||
## Add gtest based cpp test target and link libraries
|
||||
# catkin_add_gtest(${PROJECT_NAME}-test test/test_turtle_control.cpp)
|
||||
# if(TARGET ${PROJECT_NAME}-test)
|
||||
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
|
||||
# endif()
|
||||
|
||||
## Add folders to be run by python nosetests
|
||||
# catkin_add_nosetests(test)
|
||||
@@ -1,105 +0,0 @@
|
||||
# This file is configured by CMake automatically as DartConfiguration.tcl
|
||||
# If you choose not to use CMake, this file may be hand configured, by
|
||||
# filling in the required variables.
|
||||
|
||||
|
||||
# Configuration directories and files
|
||||
SourceDirectory: /home/dennis/catkin_ws/src/turtle_control
|
||||
BuildDirectory: /home/dennis/catkin_ws/src/turtle_control
|
||||
|
||||
# Where to place the cost data store
|
||||
CostDataFile:
|
||||
|
||||
# Site is something like machine.domain, i.e. pragmatic.crd
|
||||
Site: xubuntu
|
||||
|
||||
# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
|
||||
BuildName:
|
||||
|
||||
# Subprojects
|
||||
LabelsForSubprojects:
|
||||
|
||||
# Submission information
|
||||
SubmitURL:
|
||||
|
||||
# Dashboard start time
|
||||
NightlyStartTime:
|
||||
|
||||
# Commands for the build/test/submit cycle
|
||||
ConfigureCommand: "/usr/bin/cmake" "/home/dennis/catkin_ws/src/turtle_control"
|
||||
MakeCommand:
|
||||
DefaultCTestConfigurationType:
|
||||
|
||||
# version control
|
||||
UpdateVersionOnly:
|
||||
|
||||
# CVS options
|
||||
# Default is "-d -P -A"
|
||||
CVSCommand:
|
||||
CVSUpdateOptions:
|
||||
|
||||
# Subversion options
|
||||
SVNCommand:
|
||||
SVNOptions:
|
||||
SVNUpdateOptions:
|
||||
|
||||
# Git options
|
||||
GITCommand:
|
||||
GITInitSubmodules:
|
||||
GITUpdateOptions:
|
||||
GITUpdateCustom:
|
||||
|
||||
# Perforce options
|
||||
P4Command:
|
||||
P4Client:
|
||||
P4Options:
|
||||
P4UpdateOptions:
|
||||
P4UpdateCustom:
|
||||
|
||||
# Generic update command
|
||||
UpdateCommand:
|
||||
UpdateOptions:
|
||||
UpdateType:
|
||||
|
||||
# Compiler info
|
||||
Compiler: /usr/bin/c++
|
||||
CompilerVersion: 9.4.0
|
||||
|
||||
# Dynamic analysis (MemCheck)
|
||||
PurifyCommand:
|
||||
ValgrindCommand:
|
||||
ValgrindCommandOptions:
|
||||
MemoryCheckType:
|
||||
MemoryCheckSanitizerOptions:
|
||||
MemoryCheckCommand:
|
||||
MemoryCheckCommandOptions:
|
||||
MemoryCheckSuppressionFile:
|
||||
|
||||
# Coverage
|
||||
CoverageCommand:
|
||||
CoverageExtraFlags:
|
||||
|
||||
# Cluster commands
|
||||
SlurmBatchCommand:
|
||||
SlurmRunCommand:
|
||||
|
||||
# Testing options
|
||||
# TimeOut is the amount of time in seconds to wait for processes
|
||||
# to complete during testing. After TimeOut seconds, the
|
||||
# process will be summarily terminated.
|
||||
# Currently set to 25 minutes
|
||||
TimeOut:
|
||||
|
||||
# During parallel testing CTest will not start a new test if doing
|
||||
# so would cause the system load to exceed this value.
|
||||
TestLoad:
|
||||
|
||||
UseLaunchers:
|
||||
CurlOptions:
|
||||
# warning, if you add new options here that have to do with submit,
|
||||
# you have to update cmCTestSubmitCommand.cxx
|
||||
|
||||
# For CTest submissions that timeout, these options
|
||||
# specify behavior for retrying the submission
|
||||
CTestSubmitRetryDelay:
|
||||
CTestSubmitRetryCount:
|
||||
@@ -1,2 +0,0 @@
|
||||
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 0)
|
||||
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 0)
|
||||
@@ -1,7 +0,0 @@
|
||||
# CMake generated Testfile for
|
||||
# Source directory: /home/dennis/catkin_ws/src/turtle_control
|
||||
# Build directory: /home/dennis/catkin_ws/src/turtle_control
|
||||
#
|
||||
# This file includes the relevant testing commands required for
|
||||
# testing this directory and lists subdirectories to be tested as well.
|
||||
subdirs("gtest")
|
||||
@@ -1,576 +0,0 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
|
||||
.PHONY : default_target
|
||||
|
||||
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
|
||||
.NOTPARALLEL:
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
|
||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
||||
SUFFIXES =
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
|
||||
# Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E remove -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/dennis/catkin_ws/src/turtle_control
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/dennis/catkin_ws/src/turtle_control
|
||||
|
||||
#=============================================================================
|
||||
# Targets provided globally by CMake.
|
||||
|
||||
# Special rule for the target install/local
|
||||
install/local: preinstall
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
|
||||
.PHONY : install/local
|
||||
|
||||
# Special rule for the target install/local
|
||||
install/local/fast: preinstall/fast
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
|
||||
.PHONY : install/local/fast
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
||||
/usr/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : rebuild_cache
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache/fast: rebuild_cache
|
||||
|
||||
.PHONY : rebuild_cache/fast
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
|
||||
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
|
||||
.PHONY : edit_cache
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache/fast: edit_cache
|
||||
|
||||
.PHONY : edit_cache/fast
|
||||
|
||||
# Special rule for the target test
|
||||
test:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
|
||||
/usr/bin/ctest --force-new-ctest-process $(ARGS)
|
||||
.PHONY : test
|
||||
|
||||
# Special rule for the target test
|
||||
test/fast: test
|
||||
|
||||
.PHONY : test/fast
|
||||
|
||||
# Special rule for the target install/strip
|
||||
install/strip: preinstall
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
|
||||
.PHONY : install/strip
|
||||
|
||||
# Special rule for the target install/strip
|
||||
install/strip/fast: preinstall/fast
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
|
||||
.PHONY : install/strip/fast
|
||||
|
||||
# Special rule for the target list_install_components
|
||||
list_install_components:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
|
||||
.PHONY : list_install_components
|
||||
|
||||
# Special rule for the target list_install_components
|
||||
list_install_components/fast: list_install_components
|
||||
|
||||
.PHONY : list_install_components/fast
|
||||
|
||||
# Special rule for the target install
|
||||
install: preinstall
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
|
||||
/usr/bin/cmake -P cmake_install.cmake
|
||||
.PHONY : install
|
||||
|
||||
# Special rule for the target install
|
||||
install/fast: preinstall/fast
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
|
||||
/usr/bin/cmake -P cmake_install.cmake
|
||||
.PHONY : install/fast
|
||||
|
||||
# The main all target
|
||||
all: cmake_check_build_system
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/dennis/catkin_ws/src/turtle_control/CMakeFiles /home/dennis/catkin_ws/src/turtle_control/CMakeFiles/progress.marks
|
||||
$(MAKE) -f CMakeFiles/Makefile2 all
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/dennis/catkin_ws/src/turtle_control/CMakeFiles 0
|
||||
.PHONY : all
|
||||
|
||||
# The main clean target
|
||||
clean:
|
||||
$(MAKE) -f CMakeFiles/Makefile2 clean
|
||||
.PHONY : clean
|
||||
|
||||
# The main clean target
|
||||
clean/fast: clean
|
||||
|
||||
.PHONY : clean/fast
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall: all
|
||||
$(MAKE) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall/fast:
|
||||
$(MAKE) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall/fast
|
||||
|
||||
# clear depends
|
||||
depend:
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
||||
.PHONY : depend
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named turtle_control_node
|
||||
|
||||
# Build rule for target.
|
||||
turtle_control_node: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 turtle_control_node
|
||||
.PHONY : turtle_control_node
|
||||
|
||||
# fast build rule for target.
|
||||
turtle_control_node/fast:
|
||||
$(MAKE) -f CMakeFiles/turtle_control_node.dir/build.make CMakeFiles/turtle_control_node.dir/build
|
||||
.PHONY : turtle_control_node/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named std_msgs_generate_messages_py
|
||||
|
||||
# Build rule for target.
|
||||
std_msgs_generate_messages_py: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 std_msgs_generate_messages_py
|
||||
.PHONY : std_msgs_generate_messages_py
|
||||
|
||||
# fast build rule for target.
|
||||
std_msgs_generate_messages_py/fast:
|
||||
$(MAKE) -f CMakeFiles/std_msgs_generate_messages_py.dir/build.make CMakeFiles/std_msgs_generate_messages_py.dir/build
|
||||
.PHONY : std_msgs_generate_messages_py/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named std_msgs_generate_messages_nodejs
|
||||
|
||||
# Build rule for target.
|
||||
std_msgs_generate_messages_nodejs: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 std_msgs_generate_messages_nodejs
|
||||
.PHONY : std_msgs_generate_messages_nodejs
|
||||
|
||||
# fast build rule for target.
|
||||
std_msgs_generate_messages_nodejs/fast:
|
||||
$(MAKE) -f CMakeFiles/std_msgs_generate_messages_nodejs.dir/build.make CMakeFiles/std_msgs_generate_messages_nodejs.dir/build
|
||||
.PHONY : std_msgs_generate_messages_nodejs/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named std_msgs_generate_messages_cpp
|
||||
|
||||
# Build rule for target.
|
||||
std_msgs_generate_messages_cpp: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 std_msgs_generate_messages_cpp
|
||||
.PHONY : std_msgs_generate_messages_cpp
|
||||
|
||||
# fast build rule for target.
|
||||
std_msgs_generate_messages_cpp/fast:
|
||||
$(MAKE) -f CMakeFiles/std_msgs_generate_messages_cpp.dir/build.make CMakeFiles/std_msgs_generate_messages_cpp.dir/build
|
||||
.PHONY : std_msgs_generate_messages_cpp/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named rosgraph_msgs_generate_messages_nodejs
|
||||
|
||||
# Build rule for target.
|
||||
rosgraph_msgs_generate_messages_nodejs: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 rosgraph_msgs_generate_messages_nodejs
|
||||
.PHONY : rosgraph_msgs_generate_messages_nodejs
|
||||
|
||||
# fast build rule for target.
|
||||
rosgraph_msgs_generate_messages_nodejs/fast:
|
||||
$(MAKE) -f CMakeFiles/rosgraph_msgs_generate_messages_nodejs.dir/build.make CMakeFiles/rosgraph_msgs_generate_messages_nodejs.dir/build
|
||||
.PHONY : rosgraph_msgs_generate_messages_nodejs/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named tests
|
||||
|
||||
# Build rule for target.
|
||||
tests: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 tests
|
||||
.PHONY : tests
|
||||
|
||||
# fast build rule for target.
|
||||
tests/fast:
|
||||
$(MAKE) -f CMakeFiles/tests.dir/build.make CMakeFiles/tests.dir/build
|
||||
.PHONY : tests/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named clean_test_results
|
||||
|
||||
# Build rule for target.
|
||||
clean_test_results: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 clean_test_results
|
||||
.PHONY : clean_test_results
|
||||
|
||||
# fast build rule for target.
|
||||
clean_test_results/fast:
|
||||
$(MAKE) -f CMakeFiles/clean_test_results.dir/build.make CMakeFiles/clean_test_results.dir/build
|
||||
.PHONY : clean_test_results/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named std_msgs_generate_messages_lisp
|
||||
|
||||
# Build rule for target.
|
||||
std_msgs_generate_messages_lisp: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 std_msgs_generate_messages_lisp
|
||||
.PHONY : std_msgs_generate_messages_lisp
|
||||
|
||||
# fast build rule for target.
|
||||
std_msgs_generate_messages_lisp/fast:
|
||||
$(MAKE) -f CMakeFiles/std_msgs_generate_messages_lisp.dir/build.make CMakeFiles/std_msgs_generate_messages_lisp.dir/build
|
||||
.PHONY : std_msgs_generate_messages_lisp/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named run_tests
|
||||
|
||||
# Build rule for target.
|
||||
run_tests: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 run_tests
|
||||
.PHONY : run_tests
|
||||
|
||||
# fast build rule for target.
|
||||
run_tests/fast:
|
||||
$(MAKE) -f CMakeFiles/run_tests.dir/build.make CMakeFiles/run_tests.dir/build
|
||||
.PHONY : run_tests/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named download_extra_data
|
||||
|
||||
# Build rule for target.
|
||||
download_extra_data: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 download_extra_data
|
||||
.PHONY : download_extra_data
|
||||
|
||||
# fast build rule for target.
|
||||
download_extra_data/fast:
|
||||
$(MAKE) -f CMakeFiles/download_extra_data.dir/build.make CMakeFiles/download_extra_data.dir/build
|
||||
.PHONY : download_extra_data/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named doxygen
|
||||
|
||||
# Build rule for target.
|
||||
doxygen: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 doxygen
|
||||
.PHONY : doxygen
|
||||
|
||||
# fast build rule for target.
|
||||
doxygen/fast:
|
||||
$(MAKE) -f CMakeFiles/doxygen.dir/build.make CMakeFiles/doxygen.dir/build
|
||||
.PHONY : doxygen/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named roscpp_generate_messages_py
|
||||
|
||||
# Build rule for target.
|
||||
roscpp_generate_messages_py: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 roscpp_generate_messages_py
|
||||
.PHONY : roscpp_generate_messages_py
|
||||
|
||||
# fast build rule for target.
|
||||
roscpp_generate_messages_py/fast:
|
||||
$(MAKE) -f CMakeFiles/roscpp_generate_messages_py.dir/build.make CMakeFiles/roscpp_generate_messages_py.dir/build
|
||||
.PHONY : roscpp_generate_messages_py/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named roscpp_generate_messages_cpp
|
||||
|
||||
# Build rule for target.
|
||||
roscpp_generate_messages_cpp: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 roscpp_generate_messages_cpp
|
||||
.PHONY : roscpp_generate_messages_cpp
|
||||
|
||||
# fast build rule for target.
|
||||
roscpp_generate_messages_cpp/fast:
|
||||
$(MAKE) -f CMakeFiles/roscpp_generate_messages_cpp.dir/build.make CMakeFiles/roscpp_generate_messages_cpp.dir/build
|
||||
.PHONY : roscpp_generate_messages_cpp/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named roscpp_generate_messages_eus
|
||||
|
||||
# Build rule for target.
|
||||
roscpp_generate_messages_eus: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 roscpp_generate_messages_eus
|
||||
.PHONY : roscpp_generate_messages_eus
|
||||
|
||||
# fast build rule for target.
|
||||
roscpp_generate_messages_eus/fast:
|
||||
$(MAKE) -f CMakeFiles/roscpp_generate_messages_eus.dir/build.make CMakeFiles/roscpp_generate_messages_eus.dir/build
|
||||
.PHONY : roscpp_generate_messages_eus/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named rosgraph_msgs_generate_messages_py
|
||||
|
||||
# Build rule for target.
|
||||
rosgraph_msgs_generate_messages_py: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 rosgraph_msgs_generate_messages_py
|
||||
.PHONY : rosgraph_msgs_generate_messages_py
|
||||
|
||||
# fast build rule for target.
|
||||
rosgraph_msgs_generate_messages_py/fast:
|
||||
$(MAKE) -f CMakeFiles/rosgraph_msgs_generate_messages_py.dir/build.make CMakeFiles/rosgraph_msgs_generate_messages_py.dir/build
|
||||
.PHONY : rosgraph_msgs_generate_messages_py/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named roscpp_generate_messages_lisp
|
||||
|
||||
# Build rule for target.
|
||||
roscpp_generate_messages_lisp: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 roscpp_generate_messages_lisp
|
||||
.PHONY : roscpp_generate_messages_lisp
|
||||
|
||||
# fast build rule for target.
|
||||
roscpp_generate_messages_lisp/fast:
|
||||
$(MAKE) -f CMakeFiles/roscpp_generate_messages_lisp.dir/build.make CMakeFiles/roscpp_generate_messages_lisp.dir/build
|
||||
.PHONY : roscpp_generate_messages_lisp/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named std_msgs_generate_messages_eus
|
||||
|
||||
# Build rule for target.
|
||||
std_msgs_generate_messages_eus: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 std_msgs_generate_messages_eus
|
||||
.PHONY : std_msgs_generate_messages_eus
|
||||
|
||||
# fast build rule for target.
|
||||
std_msgs_generate_messages_eus/fast:
|
||||
$(MAKE) -f CMakeFiles/std_msgs_generate_messages_eus.dir/build.make CMakeFiles/std_msgs_generate_messages_eus.dir/build
|
||||
.PHONY : std_msgs_generate_messages_eus/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named roscpp_generate_messages_nodejs
|
||||
|
||||
# Build rule for target.
|
||||
roscpp_generate_messages_nodejs: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 roscpp_generate_messages_nodejs
|
||||
.PHONY : roscpp_generate_messages_nodejs
|
||||
|
||||
# fast build rule for target.
|
||||
roscpp_generate_messages_nodejs/fast:
|
||||
$(MAKE) -f CMakeFiles/roscpp_generate_messages_nodejs.dir/build.make CMakeFiles/roscpp_generate_messages_nodejs.dir/build
|
||||
.PHONY : roscpp_generate_messages_nodejs/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named rosgraph_msgs_generate_messages_cpp
|
||||
|
||||
# Build rule for target.
|
||||
rosgraph_msgs_generate_messages_cpp: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 rosgraph_msgs_generate_messages_cpp
|
||||
.PHONY : rosgraph_msgs_generate_messages_cpp
|
||||
|
||||
# fast build rule for target.
|
||||
rosgraph_msgs_generate_messages_cpp/fast:
|
||||
$(MAKE) -f CMakeFiles/rosgraph_msgs_generate_messages_cpp.dir/build.make CMakeFiles/rosgraph_msgs_generate_messages_cpp.dir/build
|
||||
.PHONY : rosgraph_msgs_generate_messages_cpp/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named rosgraph_msgs_generate_messages_eus
|
||||
|
||||
# Build rule for target.
|
||||
rosgraph_msgs_generate_messages_eus: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 rosgraph_msgs_generate_messages_eus
|
||||
.PHONY : rosgraph_msgs_generate_messages_eus
|
||||
|
||||
# fast build rule for target.
|
||||
rosgraph_msgs_generate_messages_eus/fast:
|
||||
$(MAKE) -f CMakeFiles/rosgraph_msgs_generate_messages_eus.dir/build.make CMakeFiles/rosgraph_msgs_generate_messages_eus.dir/build
|
||||
.PHONY : rosgraph_msgs_generate_messages_eus/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named rosgraph_msgs_generate_messages_lisp
|
||||
|
||||
# Build rule for target.
|
||||
rosgraph_msgs_generate_messages_lisp: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 rosgraph_msgs_generate_messages_lisp
|
||||
.PHONY : rosgraph_msgs_generate_messages_lisp
|
||||
|
||||
# fast build rule for target.
|
||||
rosgraph_msgs_generate_messages_lisp/fast:
|
||||
$(MAKE) -f CMakeFiles/rosgraph_msgs_generate_messages_lisp.dir/build.make CMakeFiles/rosgraph_msgs_generate_messages_lisp.dir/build
|
||||
.PHONY : rosgraph_msgs_generate_messages_lisp/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named gmock_main
|
||||
|
||||
# Build rule for target.
|
||||
gmock_main: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 gmock_main
|
||||
.PHONY : gmock_main
|
||||
|
||||
# fast build rule for target.
|
||||
gmock_main/fast:
|
||||
$(MAKE) -f gtest/googlemock/CMakeFiles/gmock_main.dir/build.make gtest/googlemock/CMakeFiles/gmock_main.dir/build
|
||||
.PHONY : gmock_main/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named gmock
|
||||
|
||||
# Build rule for target.
|
||||
gmock: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 gmock
|
||||
.PHONY : gmock
|
||||
|
||||
# fast build rule for target.
|
||||
gmock/fast:
|
||||
$(MAKE) -f gtest/googlemock/CMakeFiles/gmock.dir/build.make gtest/googlemock/CMakeFiles/gmock.dir/build
|
||||
.PHONY : gmock/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named gtest_main
|
||||
|
||||
# Build rule for target.
|
||||
gtest_main: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 gtest_main
|
||||
.PHONY : gtest_main
|
||||
|
||||
# fast build rule for target.
|
||||
gtest_main/fast:
|
||||
$(MAKE) -f gtest/googletest/CMakeFiles/gtest_main.dir/build.make gtest/googletest/CMakeFiles/gtest_main.dir/build
|
||||
.PHONY : gtest_main/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named gtest
|
||||
|
||||
# Build rule for target.
|
||||
gtest: cmake_check_build_system
|
||||
$(MAKE) -f CMakeFiles/Makefile2 gtest
|
||||
.PHONY : gtest
|
||||
|
||||
# fast build rule for target.
|
||||
gtest/fast:
|
||||
$(MAKE) -f gtest/googletest/CMakeFiles/gtest.dir/build.make gtest/googletest/CMakeFiles/gtest.dir/build
|
||||
.PHONY : gtest/fast
|
||||
|
||||
src/turtle_mover.o: src/turtle_mover.cpp.o
|
||||
|
||||
.PHONY : src/turtle_mover.o
|
||||
|
||||
# target to build an object file
|
||||
src/turtle_mover.cpp.o:
|
||||
$(MAKE) -f CMakeFiles/turtle_control_node.dir/build.make CMakeFiles/turtle_control_node.dir/src/turtle_mover.cpp.o
|
||||
.PHONY : src/turtle_mover.cpp.o
|
||||
|
||||
src/turtle_mover.i: src/turtle_mover.cpp.i
|
||||
|
||||
.PHONY : src/turtle_mover.i
|
||||
|
||||
# target to preprocess a source file
|
||||
src/turtle_mover.cpp.i:
|
||||
$(MAKE) -f CMakeFiles/turtle_control_node.dir/build.make CMakeFiles/turtle_control_node.dir/src/turtle_mover.cpp.i
|
||||
.PHONY : src/turtle_mover.cpp.i
|
||||
|
||||
src/turtle_mover.s: src/turtle_mover.cpp.s
|
||||
|
||||
.PHONY : src/turtle_mover.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
src/turtle_mover.cpp.s:
|
||||
$(MAKE) -f CMakeFiles/turtle_control_node.dir/build.make CMakeFiles/turtle_control_node.dir/src/turtle_mover.cpp.s
|
||||
.PHONY : src/turtle_mover.cpp.s
|
||||
|
||||
# Help Target
|
||||
help:
|
||||
@echo "The following are some of the valid targets for this Makefile:"
|
||||
@echo "... all (the default if no target is provided)"
|
||||
@echo "... clean"
|
||||
@echo "... depend"
|
||||
@echo "... install/local"
|
||||
@echo "... rebuild_cache"
|
||||
@echo "... edit_cache"
|
||||
@echo "... test"
|
||||
@echo "... turtle_control_node"
|
||||
@echo "... std_msgs_generate_messages_py"
|
||||
@echo "... std_msgs_generate_messages_nodejs"
|
||||
@echo "... install/strip"
|
||||
@echo "... std_msgs_generate_messages_cpp"
|
||||
@echo "... rosgraph_msgs_generate_messages_nodejs"
|
||||
@echo "... tests"
|
||||
@echo "... clean_test_results"
|
||||
@echo "... list_install_components"
|
||||
@echo "... std_msgs_generate_messages_lisp"
|
||||
@echo "... run_tests"
|
||||
@echo "... download_extra_data"
|
||||
@echo "... doxygen"
|
||||
@echo "... roscpp_generate_messages_py"
|
||||
@echo "... roscpp_generate_messages_cpp"
|
||||
@echo "... roscpp_generate_messages_eus"
|
||||
@echo "... rosgraph_msgs_generate_messages_py"
|
||||
@echo "... roscpp_generate_messages_lisp"
|
||||
@echo "... install"
|
||||
@echo "... std_msgs_generate_messages_eus"
|
||||
@echo "... roscpp_generate_messages_nodejs"
|
||||
@echo "... rosgraph_msgs_generate_messages_cpp"
|
||||
@echo "... rosgraph_msgs_generate_messages_eus"
|
||||
@echo "... rosgraph_msgs_generate_messages_lisp"
|
||||
@echo "... gmock_main"
|
||||
@echo "... gmock"
|
||||
@echo "... gtest_main"
|
||||
@echo "... gtest"
|
||||
@echo "... src/turtle_mover.o"
|
||||
@echo "... src/turtle_mover.i"
|
||||
@echo "... src/turtle_mover.s"
|
||||
.PHONY : help
|
||||
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
- setup-file:
|
||||
local-name: /home/dennis/catkin_ws/src/turtle_control/devel/setup.sh
|
||||
@@ -1,304 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2012, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""This file generates shell code for the setup.SHELL scripts to set environment variables."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import copy
|
||||
import errno
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
CATKIN_MARKER_FILE = '.catkin'
|
||||
|
||||
system = platform.system()
|
||||
IS_DARWIN = (system == 'Darwin')
|
||||
IS_WINDOWS = (system == 'Windows')
|
||||
|
||||
PATH_TO_ADD_SUFFIX = ['bin']
|
||||
if IS_WINDOWS:
|
||||
# while catkin recommends putting dll's into bin, 3rd party packages often put dll's into lib
|
||||
# since Windows finds dll's via the PATH variable, prepend it with path to lib
|
||||
PATH_TO_ADD_SUFFIX.extend([['lib', os.path.join('lib', 'x86_64-linux-gnu')]])
|
||||
|
||||
# subfolder of workspace prepended to CMAKE_PREFIX_PATH
|
||||
ENV_VAR_SUBFOLDERS = {
|
||||
'CMAKE_PREFIX_PATH': '',
|
||||
'LD_LIBRARY_PATH' if not IS_DARWIN else 'DYLD_LIBRARY_PATH': ['lib', os.path.join('lib', 'x86_64-linux-gnu')],
|
||||
'PATH': PATH_TO_ADD_SUFFIX,
|
||||
'PKG_CONFIG_PATH': [os.path.join('lib', 'pkgconfig'), os.path.join('lib', 'x86_64-linux-gnu', 'pkgconfig')],
|
||||
'PYTHONPATH': 'lib/python3/dist-packages',
|
||||
}
|
||||
|
||||
|
||||
def rollback_env_variables(environ, env_var_subfolders):
|
||||
"""
|
||||
Generate shell code to reset environment variables.
|
||||
|
||||
by unrolling modifications based on all workspaces in CMAKE_PREFIX_PATH.
|
||||
This does not cover modifications performed by environment hooks.
|
||||
"""
|
||||
lines = []
|
||||
unmodified_environ = copy.copy(environ)
|
||||
for key in sorted(env_var_subfolders.keys()):
|
||||
subfolders = env_var_subfolders[key]
|
||||
if not isinstance(subfolders, list):
|
||||
subfolders = [subfolders]
|
||||
value = _rollback_env_variable(unmodified_environ, key, subfolders)
|
||||
if value is not None:
|
||||
environ[key] = value
|
||||
lines.append(assignment(key, value))
|
||||
if lines:
|
||||
lines.insert(0, comment('reset environment variables by unrolling modifications based on all workspaces in CMAKE_PREFIX_PATH'))
|
||||
return lines
|
||||
|
||||
|
||||
def _rollback_env_variable(environ, name, subfolders):
|
||||
"""
|
||||
For each catkin workspace in CMAKE_PREFIX_PATH remove the first entry from env[NAME] matching workspace + subfolder.
|
||||
|
||||
:param subfolders: list of str '' or subfoldername that may start with '/'
|
||||
:returns: the updated value of the environment variable.
|
||||
"""
|
||||
value = environ[name] if name in environ else ''
|
||||
env_paths = [path for path in value.split(os.pathsep) if path]
|
||||
value_modified = False
|
||||
for subfolder in subfolders:
|
||||
if subfolder:
|
||||
if subfolder.startswith(os.path.sep) or (os.path.altsep and subfolder.startswith(os.path.altsep)):
|
||||
subfolder = subfolder[1:]
|
||||
if subfolder.endswith(os.path.sep) or (os.path.altsep and subfolder.endswith(os.path.altsep)):
|
||||
subfolder = subfolder[:-1]
|
||||
for ws_path in _get_workspaces(environ, include_fuerte=True, include_non_existing=True):
|
||||
path_to_find = os.path.join(ws_path, subfolder) if subfolder else ws_path
|
||||
path_to_remove = None
|
||||
for env_path in env_paths:
|
||||
env_path_clean = env_path[:-1] if env_path and env_path[-1] in [os.path.sep, os.path.altsep] else env_path
|
||||
if env_path_clean == path_to_find:
|
||||
path_to_remove = env_path
|
||||
break
|
||||
if path_to_remove:
|
||||
env_paths.remove(path_to_remove)
|
||||
value_modified = True
|
||||
new_value = os.pathsep.join(env_paths)
|
||||
return new_value if value_modified else None
|
||||
|
||||
|
||||
def _get_workspaces(environ, include_fuerte=False, include_non_existing=False):
|
||||
"""
|
||||
Based on CMAKE_PREFIX_PATH return all catkin workspaces.
|
||||
|
||||
:param include_fuerte: The flag if paths starting with '/opt/ros/fuerte' should be considered workspaces, ``bool``
|
||||
"""
|
||||
# get all cmake prefix paths
|
||||
env_name = 'CMAKE_PREFIX_PATH'
|
||||
value = environ[env_name] if env_name in environ else ''
|
||||
paths = [path for path in value.split(os.pathsep) if path]
|
||||
# remove non-workspace paths
|
||||
workspaces = [path for path in paths if os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE)) or (include_fuerte and path.startswith('/opt/ros/fuerte')) or (include_non_existing and not os.path.exists(path))]
|
||||
return workspaces
|
||||
|
||||
|
||||
def prepend_env_variables(environ, env_var_subfolders, workspaces):
|
||||
"""Generate shell code to prepend environment variables for the all workspaces."""
|
||||
lines = []
|
||||
lines.append(comment('prepend folders of workspaces to environment variables'))
|
||||
|
||||
paths = [path for path in workspaces.split(os.pathsep) if path]
|
||||
|
||||
prefix = _prefix_env_variable(environ, 'CMAKE_PREFIX_PATH', paths, '')
|
||||
lines.append(prepend(environ, 'CMAKE_PREFIX_PATH', prefix))
|
||||
|
||||
for key in sorted(key for key in env_var_subfolders.keys() if key != 'CMAKE_PREFIX_PATH'):
|
||||
subfolder = env_var_subfolders[key]
|
||||
prefix = _prefix_env_variable(environ, key, paths, subfolder)
|
||||
lines.append(prepend(environ, key, prefix))
|
||||
return lines
|
||||
|
||||
|
||||
def _prefix_env_variable(environ, name, paths, subfolders):
|
||||
"""
|
||||
Return the prefix to prepend to the environment variable NAME.
|
||||
|
||||
Adding any path in NEW_PATHS_STR without creating duplicate or empty items.
|
||||
"""
|
||||
value = environ[name] if name in environ else ''
|
||||
environ_paths = [path for path in value.split(os.pathsep) if path]
|
||||
checked_paths = []
|
||||
for path in paths:
|
||||
if not isinstance(subfolders, list):
|
||||
subfolders = [subfolders]
|
||||
for subfolder in subfolders:
|
||||
path_tmp = path
|
||||
if subfolder:
|
||||
path_tmp = os.path.join(path_tmp, subfolder)
|
||||
# skip nonexistent paths
|
||||
if not os.path.exists(path_tmp):
|
||||
continue
|
||||
# exclude any path already in env and any path we already added
|
||||
if path_tmp not in environ_paths and path_tmp not in checked_paths:
|
||||
checked_paths.append(path_tmp)
|
||||
prefix_str = os.pathsep.join(checked_paths)
|
||||
if prefix_str != '' and environ_paths:
|
||||
prefix_str += os.pathsep
|
||||
return prefix_str
|
||||
|
||||
|
||||
def assignment(key, value):
|
||||
if not IS_WINDOWS:
|
||||
return 'export %s="%s"' % (key, value)
|
||||
else:
|
||||
return 'set %s=%s' % (key, value)
|
||||
|
||||
|
||||
def comment(msg):
|
||||
if not IS_WINDOWS:
|
||||
return '# %s' % msg
|
||||
else:
|
||||
return 'REM %s' % msg
|
||||
|
||||
|
||||
def prepend(environ, key, prefix):
|
||||
if key not in environ or not environ[key]:
|
||||
return assignment(key, prefix)
|
||||
if not IS_WINDOWS:
|
||||
return 'export %s="%s$%s"' % (key, prefix, key)
|
||||
else:
|
||||
return 'set %s=%s%%%s%%' % (key, prefix, key)
|
||||
|
||||
|
||||
def find_env_hooks(environ, cmake_prefix_path):
|
||||
"""Generate shell code with found environment hooks for the all workspaces."""
|
||||
lines = []
|
||||
lines.append(comment('found environment hooks in workspaces'))
|
||||
|
||||
generic_env_hooks = []
|
||||
generic_env_hooks_workspace = []
|
||||
specific_env_hooks = []
|
||||
specific_env_hooks_workspace = []
|
||||
generic_env_hooks_by_filename = {}
|
||||
specific_env_hooks_by_filename = {}
|
||||
generic_env_hook_ext = 'bat' if IS_WINDOWS else 'sh'
|
||||
specific_env_hook_ext = environ['CATKIN_SHELL'] if not IS_WINDOWS and 'CATKIN_SHELL' in environ and environ['CATKIN_SHELL'] else None
|
||||
# remove non-workspace paths
|
||||
workspaces = [path for path in cmake_prefix_path.split(os.pathsep) if path and os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE))]
|
||||
for workspace in reversed(workspaces):
|
||||
env_hook_dir = os.path.join(workspace, 'etc', 'catkin', 'profile.d')
|
||||
if os.path.isdir(env_hook_dir):
|
||||
for filename in sorted(os.listdir(env_hook_dir)):
|
||||
if filename.endswith('.%s' % generic_env_hook_ext):
|
||||
# remove previous env hook with same name if present
|
||||
if filename in generic_env_hooks_by_filename:
|
||||
i = generic_env_hooks.index(generic_env_hooks_by_filename[filename])
|
||||
generic_env_hooks.pop(i)
|
||||
generic_env_hooks_workspace.pop(i)
|
||||
# append env hook
|
||||
generic_env_hooks.append(os.path.join(env_hook_dir, filename))
|
||||
generic_env_hooks_workspace.append(workspace)
|
||||
generic_env_hooks_by_filename[filename] = generic_env_hooks[-1]
|
||||
elif specific_env_hook_ext is not None and filename.endswith('.%s' % specific_env_hook_ext):
|
||||
# remove previous env hook with same name if present
|
||||
if filename in specific_env_hooks_by_filename:
|
||||
i = specific_env_hooks.index(specific_env_hooks_by_filename[filename])
|
||||
specific_env_hooks.pop(i)
|
||||
specific_env_hooks_workspace.pop(i)
|
||||
# append env hook
|
||||
specific_env_hooks.append(os.path.join(env_hook_dir, filename))
|
||||
specific_env_hooks_workspace.append(workspace)
|
||||
specific_env_hooks_by_filename[filename] = specific_env_hooks[-1]
|
||||
env_hooks = generic_env_hooks + specific_env_hooks
|
||||
env_hooks_workspace = generic_env_hooks_workspace + specific_env_hooks_workspace
|
||||
count = len(env_hooks)
|
||||
lines.append(assignment('_CATKIN_ENVIRONMENT_HOOKS_COUNT', count))
|
||||
for i in range(count):
|
||||
lines.append(assignment('_CATKIN_ENVIRONMENT_HOOKS_%d' % i, env_hooks[i]))
|
||||
lines.append(assignment('_CATKIN_ENVIRONMENT_HOOKS_%d_WORKSPACE' % i, env_hooks_workspace[i]))
|
||||
return lines
|
||||
|
||||
|
||||
def _parse_arguments(args=None):
|
||||
parser = argparse.ArgumentParser(description='Generates code blocks for the setup.SHELL script.')
|
||||
parser.add_argument('--extend', action='store_true', help='Skip unsetting previous environment variables to extend context')
|
||||
parser.add_argument('--local', action='store_true', help='Only consider this prefix path and ignore other prefix path in the environment')
|
||||
return parser.parse_known_args(args=args)[0]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
try:
|
||||
args = _parse_arguments()
|
||||
except Exception as e:
|
||||
print(e, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if not args.local:
|
||||
# environment at generation time
|
||||
CMAKE_PREFIX_PATH = r'/opt/ros/noetic'.split(';')
|
||||
else:
|
||||
# don't consider any other prefix path than this one
|
||||
CMAKE_PREFIX_PATH = []
|
||||
# prepend current workspace if not already part of CPP
|
||||
base_path = os.path.dirname(__file__)
|
||||
# CMAKE_PREFIX_PATH uses forward slash on all platforms, but __file__ is platform dependent
|
||||
# base_path on Windows contains backward slashes, need to be converted to forward slashes before comparison
|
||||
if os.path.sep != '/':
|
||||
base_path = base_path.replace(os.path.sep, '/')
|
||||
|
||||
if base_path not in CMAKE_PREFIX_PATH:
|
||||
CMAKE_PREFIX_PATH.insert(0, base_path)
|
||||
CMAKE_PREFIX_PATH = os.pathsep.join(CMAKE_PREFIX_PATH)
|
||||
|
||||
environ = dict(os.environ)
|
||||
lines = []
|
||||
if not args.extend:
|
||||
lines += rollback_env_variables(environ, ENV_VAR_SUBFOLDERS)
|
||||
lines += prepend_env_variables(environ, ENV_VAR_SUBFOLDERS, CMAKE_PREFIX_PATH)
|
||||
lines += find_env_hooks(environ, CMAKE_PREFIX_PATH)
|
||||
print('\n'.join(lines))
|
||||
|
||||
# need to explicitly flush the output
|
||||
sys.stdout.flush()
|
||||
except IOError as e:
|
||||
# and catch potential "broken pipe" if stdout is not writable
|
||||
# which can happen when piping the output to a file but the disk is full
|
||||
if e.errno == errno.EPIPE:
|
||||
print(e, file=sys.stderr)
|
||||
sys.exit(2)
|
||||
raise
|
||||
|
||||
sys.exit(0)
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# generated from catkin/cmake/templates/env.sh.in
|
||||
|
||||
if [ $# -eq 0 ] ; then
|
||||
/bin/echo "Usage: env.sh COMMANDS"
|
||||
/bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ensure to not use different shell type which was set before
|
||||
CATKIN_SHELL=sh
|
||||
|
||||
# source setup.sh from same directory as this file
|
||||
_CATKIN_SETUP_DIR=$(cd "`dirname "$0"`" > /dev/null && pwd)
|
||||
. "$_CATKIN_SETUP_DIR/setup.sh"
|
||||
exec "$@"
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# generated from catkin/cmake/templates/local_setup.bash.in
|
||||
|
||||
CATKIN_SHELL=bash
|
||||
|
||||
# source setup.sh from same directory as this file
|
||||
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
|
||||
. "$_CATKIN_SETUP_DIR/setup.sh" --extend --local
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# generated from catkin/cmake/template/local_setup.sh.in
|
||||
|
||||
# since this file is sourced either use the provided _CATKIN_SETUP_DIR
|
||||
# or fall back to the destination set at configure time
|
||||
: ${_CATKIN_SETUP_DIR:=/home/dennis/catkin_ws/src/turtle_control/devel}
|
||||
CATKIN_SETUP_UTIL_ARGS="--extend --local"
|
||||
. "$_CATKIN_SETUP_DIR/setup.sh"
|
||||
unset CATKIN_SETUP_UTIL_ARGS
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
# generated from catkin/cmake/templates/local_setup.zsh.in
|
||||
|
||||
CATKIN_SHELL=zsh
|
||||
|
||||
# source setup.sh from same directory as this file
|
||||
_CATKIN_SETUP_DIR=$(builtin cd -q "`dirname "$0"`" > /dev/null && pwd)
|
||||
emulate -R zsh -c 'source "$_CATKIN_SETUP_DIR/setup.sh" --extend --local'
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# generated from catkin/cmake/templates/setup.bash.in
|
||||
|
||||
CATKIN_SHELL=bash
|
||||
|
||||
# source setup.sh from same directory as this file
|
||||
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
|
||||
. "$_CATKIN_SETUP_DIR/setup.sh"
|
||||
@@ -1,96 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# generated from catkin/cmake/template/setup.sh.in
|
||||
|
||||
# Sets various environment variables and sources additional environment hooks.
|
||||
# It tries it's best to undo changes from a previously sourced setup file before.
|
||||
# Supported command line options:
|
||||
# --extend: skips the undoing of changes from a previously sourced setup file
|
||||
# --local: only considers this workspace but not the chained ones
|
||||
# In plain sh shell which doesn't support arguments for sourced scripts you can
|
||||
# set the environment variable `CATKIN_SETUP_UTIL_ARGS=--extend/--local` instead.
|
||||
|
||||
# since this file is sourced either use the provided _CATKIN_SETUP_DIR
|
||||
# or fall back to the destination set at configure time
|
||||
: ${_CATKIN_SETUP_DIR:=/home/dennis/catkin_ws/src/turtle_control/devel}
|
||||
_SETUP_UTIL="$_CATKIN_SETUP_DIR/_setup_util.py"
|
||||
unset _CATKIN_SETUP_DIR
|
||||
|
||||
if [ ! -f "$_SETUP_UTIL" ]; then
|
||||
echo "Missing Python script: $_SETUP_UTIL"
|
||||
return 22
|
||||
fi
|
||||
|
||||
# detect if running on Darwin platform
|
||||
_UNAME=`uname -s`
|
||||
_IS_DARWIN=0
|
||||
if [ "$_UNAME" = "Darwin" ]; then
|
||||
_IS_DARWIN=1
|
||||
fi
|
||||
unset _UNAME
|
||||
|
||||
# make sure to export all environment variables
|
||||
export CMAKE_PREFIX_PATH
|
||||
if [ $_IS_DARWIN -eq 0 ]; then
|
||||
export LD_LIBRARY_PATH
|
||||
else
|
||||
export DYLD_LIBRARY_PATH
|
||||
fi
|
||||
unset _IS_DARWIN
|
||||
export PATH
|
||||
export PKG_CONFIG_PATH
|
||||
export PYTHONPATH
|
||||
|
||||
# remember type of shell if not already set
|
||||
if [ -z "$CATKIN_SHELL" ]; then
|
||||
CATKIN_SHELL=sh
|
||||
fi
|
||||
|
||||
# invoke Python script to generate necessary exports of environment variables
|
||||
# use TMPDIR if it exists, otherwise fall back to /tmp
|
||||
if [ -d "${TMPDIR:-}" ]; then
|
||||
_TMPDIR="${TMPDIR}"
|
||||
else
|
||||
_TMPDIR=/tmp
|
||||
fi
|
||||
_SETUP_TMP=`mktemp "${_TMPDIR}/setup.sh.XXXXXXXXXX"`
|
||||
unset _TMPDIR
|
||||
if [ $? -ne 0 -o ! -f "$_SETUP_TMP" ]; then
|
||||
echo "Could not create temporary file: $_SETUP_TMP"
|
||||
return 1
|
||||
fi
|
||||
CATKIN_SHELL=$CATKIN_SHELL "$_SETUP_UTIL" $@ ${CATKIN_SETUP_UTIL_ARGS:-} >> "$_SETUP_TMP"
|
||||
_RC=$?
|
||||
if [ $_RC -ne 0 ]; then
|
||||
if [ $_RC -eq 2 ]; then
|
||||
echo "Could not write the output of '$_SETUP_UTIL' to temporary file '$_SETUP_TMP': may be the disk if full?"
|
||||
else
|
||||
echo "Failed to run '\"$_SETUP_UTIL\" $@': return code $_RC"
|
||||
fi
|
||||
unset _RC
|
||||
unset _SETUP_UTIL
|
||||
rm -f "$_SETUP_TMP"
|
||||
unset _SETUP_TMP
|
||||
return 1
|
||||
fi
|
||||
unset _RC
|
||||
unset _SETUP_UTIL
|
||||
. "$_SETUP_TMP"
|
||||
rm -f "$_SETUP_TMP"
|
||||
unset _SETUP_TMP
|
||||
|
||||
# source all environment hooks
|
||||
_i=0
|
||||
while [ $_i -lt $_CATKIN_ENVIRONMENT_HOOKS_COUNT ]; do
|
||||
eval _envfile=\$_CATKIN_ENVIRONMENT_HOOKS_$_i
|
||||
unset _CATKIN_ENVIRONMENT_HOOKS_$_i
|
||||
eval _envfile_workspace=\$_CATKIN_ENVIRONMENT_HOOKS_${_i}_WORKSPACE
|
||||
unset _CATKIN_ENVIRONMENT_HOOKS_${_i}_WORKSPACE
|
||||
# set workspace for environment hook
|
||||
CATKIN_ENV_HOOK_WORKSPACE=$_envfile_workspace
|
||||
. "$_envfile"
|
||||
unset CATKIN_ENV_HOOK_WORKSPACE
|
||||
_i=$((_i + 1))
|
||||
done
|
||||
unset _i
|
||||
|
||||
unset _CATKIN_ENVIRONMENT_HOOKS_COUNT
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
# generated from catkin/cmake/templates/setup.zsh.in
|
||||
|
||||
CATKIN_SHELL=zsh
|
||||
|
||||
# source setup.sh from same directory as this file
|
||||
_CATKIN_SETUP_DIR=$(builtin cd -q "`dirname "$0"`" > /dev/null && pwd)
|
||||
emulate -R zsh -c 'source "$_CATKIN_SETUP_DIR/setup.sh"'
|
||||
@@ -1,24 +0,0 @@
|
||||
set(_CATKIN_CURRENT_PACKAGE "catkin")
|
||||
set(catkin_VERSION "0.8.10")
|
||||
set(catkin_MAINTAINER "Michael Carroll <michael@openrobotics.org>, Tully Foote <tfoote@openrobotics.org>")
|
||||
set(catkin_PACKAGE_FORMAT "3")
|
||||
set(catkin_BUILD_DEPENDS "python-argparse" "python-catkin-pkg" "python3-catkin-pkg" "python-empy" "python3-empy")
|
||||
set(catkin_BUILD_DEPENDS_python-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_BUILD_DEPENDS_python3-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_BUILD_EXPORT_DEPENDS "google-mock" "gtest" "python-nose" "python3-nose" "python-argparse" "python-catkin-pkg" "python3-catkin-pkg" "python-empy" "python3-empy")
|
||||
set(catkin_BUILD_EXPORT_DEPENDS_python-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_BUILD_EXPORT_DEPENDS_python3-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_BUILDTOOL_DEPENDS "cmake" "python-setuptools" "python3-setuptools")
|
||||
set(catkin_BUILDTOOL_EXPORT_DEPENDS "cmake" "python3-setuptools")
|
||||
set(catkin_EXEC_DEPENDS "python-argparse" "python-catkin-pkg" "python3-catkin-pkg" "python-empy" "python3-empy")
|
||||
set(catkin_EXEC_DEPENDS_python-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_EXEC_DEPENDS_python3-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_RUN_DEPENDS "python-argparse" "python-catkin-pkg" "python3-catkin-pkg" "python-empy" "python3-empy" "google-mock" "gtest" "python-nose" "python3-nose")
|
||||
set(catkin_RUN_DEPENDS_python-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_RUN_DEPENDS_python3-catkin-pkg_VERSION_GT "0.4.3")
|
||||
set(catkin_TEST_DEPENDS "python-mock" "python3-mock" "python-nose" "python3-nose")
|
||||
set(catkin_DOC_DEPENDS )
|
||||
set(catkin_URL_WEBSITE "http://wiki.ros.org/catkin")
|
||||
set(catkin_URL_BUGTRACKER "https://github.com/ros/catkin/issues")
|
||||
set(catkin_URL_REPOSITORY "https://github.com/ros/catkin")
|
||||
set(catkin_DEPRECATED "")
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# generated from catkin/cmake/templates/env.sh.in
|
||||
|
||||
if [ $# -eq 0 ] ; then
|
||||
/bin/echo "Usage: env.sh COMMANDS"
|
||||
/bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ensure to not use different shell type which was set before
|
||||
CATKIN_SHELL=sh
|
||||
|
||||
# source setup_cached.sh from same directory as this file
|
||||
_CATKIN_SETUP_DIR=$(cd "`dirname "$0"`" > /dev/null && pwd)
|
||||
. "$_CATKIN_SETUP_DIR/setup_cached.sh"
|
||||
exec "$@"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user