66 Commits
Author SHA1 Message Date
tscherne 7185753455 Dateien nach " gripperMover" hochladen 2024-03-06 20:10:18 +01:00
tscherne e4797d435c turtle/marker_attacke_headleas.py aktualisiert 2024-03-06 20:07:44 +01:00
tscherne 2f6eee89c1 Dateien nach "turtle" hochladen 2024-03-06 20:07:16 +01:00
tscherne 9e280919f1 Dateien nach "gripperMover" hochladen 2024-03-06 16:09:53 +01:00
tscherne 74627e2456 Dateien nach "turtle" hochladen 2024-03-06 16:09:33 +01:00
tscherne ce862fd07b Dateien nach "/" hochladen 2024-03-05 15:30:18 +01:00
tscherne d181e9a14c Dateien nach "gripperMover" hochladen 2024-02-28 15:15:36 +01:00
tscherne 67d7a51331 gripperMover/gripperHelper.py gelöscht 2024-02-28 15:15:18 +01:00
tscherne 9cf2c5f479 gripperMover/marker_attack_3_real.py gelöscht 2024-02-28 15:15:08 +01:00
tscherne 401f154a5b gripperMover/arduino.cc hinzugefügt 2024-02-28 10:44:40 +01:00
tscherne f0f0d17523 Dateien nach "gripperMover" hochladen 2024-02-27 13:31:46 +01:00
tscherne 618d7f28df Dateien nach "pngs" hochladen 2024-02-27 12:14:09 +01:00
tscherne 7a7a0b7012 Dateien nach "pngs" hochladen 2024-02-27 08:47:33 +01:00
tscherne 5107626091 Dateien nach "/" hochladen 2024-02-25 20:34:53 +01:00
tscherne 198f6652c4 Dateien nach "/" hochladen 2024-02-21 13:00:52 +01:00
becker 2a63ce206c Dateien nach "/" hochladen 2024-02-21 11:12:26 +01:00
tscherne 54b5f0287d arduino2.ino aktualisiert 2024-01-27 11:10:09 +01:00
tscherne 5370810c66 Dateien nach "/" hochladen 2024-01-24 20:37:25 +01:00
tscherne f27dcce2f8 arduino2.ino aktualisiert 2024-01-24 20:34:10 +01:00
tscherne 5eef3105fe Dateien nach "/" hochladen 2024-01-24 18:12:14 +01:00
tscherne 993e4bdf78 Dateien nach "/" hochladen
testsssssssss
2024-01-23 18:46:21 +01:00
tscherne 3cc8f9ac4f Dateien nach "/" hochladen 2024-01-15 21:12:57 +01:00
tscherne de6370ee19 Dateien nach "/" hochladen
Final marker attack
2024-01-08 18:45:56 +01:00
tscherne 4079c4732b Merge branch 'simon' into main
:q
2023-12-20 12:58:12 +01:00
tscherne dc99d62d7b i:de€kb€kb€kbDel Win:wq :w :q .:WQ€kb€kbwq! :q! 2023-12-20 12:55:21 +01:00
tscherne 2d84d13e78 Dateien nach "turtle_control/scripts" hochladen 2023-12-20 12:54:07 +01:00
tscherne b2cc06152e Dateien nach "newTests" hochladen 2023-12-19 20:00:02 +01:00
tscherne 2a68782e33 Orginal Aruco 2023-12-19 13:08:39 +01:00
tscherne 33544298ea Ignore 2023-12-19 12:49:49 +01:00
tscherne 6978ff886c New tests 2023-12-18 22:50:38 +01:00
tscherne fd892f4e0a Original Aruco 2023-12-18 22:31:21 +01:00
tscherne bf41b75f6e Test depth 2023-12-17 21:01:00 +01:00
tscherne c6d98a1922 No more CMakeFiles 2023-12-17 20:18:45 +01:00
tscherne efbd664b44 Keep this dir 2023-12-17 20:12:16 +01:00
tscherne 967f10e56e More structure and less Docker 2023-12-17 20:10:26 +01:00
tscherne dcd984c53c Dateien nach "den" hochladen 2023-12-14 13:22:26 +01:00
tscherne 5aacbd541e machCatkin_ws.bash aktualisiert 2023-12-13 15:17:24 +01:00
tscherne 63acba847c Dateien nach "Win" hochladen 2023-12-12 20:58:50 +01:00
tscherne a29d174d1a Depth please 2023-12-10 18:42:24 +01:00
tscherne 08ee288f49 Better keyboard for all! 2023-11-29 19:52:56 +01:00
tscherne 09ee42cfb9 Formatting 2023-11-29 16:47:29 +01:00
tscherne 6148059f20 vvv 2023-11-29 16:44:01 +01:00
tscherne a27c348879 Dateien nach "Docker/turtle_control/scripts" hochladen 2023-11-29 13:14:59 +01:00
tscherne 3d84a191a2 commands.txt aktualisiert 2023-11-28 12:20:38 +01:00
tscherne ac697e3e03 commands.txt aktualisiert 2023-11-28 12:19:09 +01:00
tscherne 47a07e000f Movemnet helper 2023-11-27 14:56:33 +01:00
tscherne 0dbb7ded6f Commands 2023-11-25 16:27:41 +01:00
tscherne 23b65cc7b2 Moved to docker. 2023-11-25 15:52:32 +01:00
tscherne e40f5253f7 Now use sudo everywhere 2023-11-25 15:23:36 +01:00
tscherne e9933be5fa Bridge docker to ros package 2023-11-24 22:23:25 +01:00
tscherne 1fe811e28a Goodbye VM. Hello Docker 2023-11-24 21:45:15 +01:00
tscherne bd3ea5a906 Dateien nach "rosNodeCvTests/src/turtle_control/scripts" hochladen 2023-11-23 13:39:41 +01:00
tscherne a9bf5fc6ea rosNodeCvTests/src/turtle_control/scripts/marker_test2.py gelöscht 2023-11-23 13:39:05 +01:00
tscherne a4e658d0e2 Dateien nach "pdf" hochladen 2023-11-23 12:17:01 +01:00
tscherne 0529be0c7c Dateien nach "pdf" hochladen 2023-11-23 12:16:50 +01:00
tscherne cd79ac4aba Dateien nach "pdf" hochladen 2023-11-23 12:16:40 +01:00
tscherne 3d77bfa6a0 Dateien nach "pdf" hochladen 2023-11-23 12:16:26 +01:00
tscherne 18985aee5e Dateien nach "pdf" hochladen 2023-11-23 12:16:08 +01:00
Zimzn 1cbbb0f653 New py scripts 2023-11-22 22:19:01 +01:00
Zimzn 480d940051 Test module 2023-11-22 22:16:07 +01:00
Zimzn 2bf7df2466 Not needed anymore 2023-11-22 22:09:24 +01:00
Zimzn 43bdbbe5dd gitignore 2023-11-22 22:08:25 +01:00
tscherne 7994cc800f Dateien nach "t1" hochladen
Nichts außer gucken und bewegen
2023-11-22 11:40:38 +01:00
tscherne 95f2797828 commands.txt hinzugefügt 2023-11-15 12:09:27 +01:00
tscherne dfb7b0c3a0 :q 2023-11-15 11:58:05 +01:00
tscherne a677e7247c €kd€ku:q 2023-11-15 11:02:50 +01:00
153 changed files with 43753 additions and 0 deletions
+194
View File
@@ -0,0 +1,194 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import random
import numpy as np
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import Twist
import gripperHelper
import bDepth
class gripper_mover():
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)
turtle_is_here = 0
def wait_for_here_callback(self,data):
rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
if data.data == "IMHERE":
self.turtle_is_here = 1
def wait_for_here(self):
sub = rospy.Subscriber("chatterabc", String, self.wait_for_here_callback)
while self.turtle_is_here == 0:
print("Turtle is not here")
self.rate.sleep()
sub.unregister()
print("Turtle IS here")
def say_im_finish(self):
for x in range(0, 50):
hello_str = "GRIPFINISH"
print("IM FINISHED")
self.pub2.publish(hello_str)
self.rate.sleep()
def __init__(self, astra_camera_rgb_topic : str, astra_camera_depth_topic : str , start_id : int = 1):
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.gHelper = gripperHelper.gripperArdunio()
# self.gHelper.testMove(10)
self.gHelper.grabK()
self.bDepth = bDepth.betterDepth()
### For turtle controll
# self.wait_for_subscribers()
self.wait_for_publisher(astra_camera_rgb_topic,astra_camera_depth_topic)
self.bridge = CvBridge()
self.pub2 = rospy.Publisher('grippertalker', String, queue_size=10)
rospy.init_node("turtle_control", anonymous=True)
self.rate = rospy.Rate(30) # update rate can be increased
self.wait_for_here()
self.depth_point = (-1,-1) #This is the point from where we get the depth
self.last_depth = -1 #This is the last depth from the depth_point
self.last_depth2 = -1
self.depth_counter = 0 #Make sure we are really there by counting how many time we got this result
self.rState = 0
self.lastMove = 0
self.image_sub = rospy.Subscriber(
astra_camera_rgb_topic, Image, self.callback_rgb
)
self.depth_bridge = CvBridge()
self.lastTime = time.time()
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):
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)
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 corners: #marker corners
#Now seleted the corners of the tag with the right id => the tag that indicates the distance to the gripper
i = np.where(ids == self.target_id) # wahrscheinlich 1 und 0
if len(i[0]) > 0:
fitting_corners = corners[i[0][0]]
self.markDetected(cv_image, fitting_corners)
tM = np.where(ids == 0) #Now try to get the marker that indicates the turtlebot
else:
self.depth_point = (-1,-1)
cv2.rectangle(cv_image,(0,0),(700,120),(10, 10, 10),-1)
#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, (200, 200, 200), 2, cv2.LINE_8)
depthString = "DepthPoint:" + str(self.depth_point[0]) +"x" +str(self.depth_point[1]) + "Distance:" + str(self.last_depth)
cv2.putText(cv_image, depthString, (10,60), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
depthString2 = "LastMove:" + str(self.lastMove)
cv2.putText(cv_image, depthString2, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
self.rate.sleep()
cv2.imshow("Window", cv_image)
cv2.waitKey(1)
def callback_depth(self, data):
#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")
if self.depth_point != (-1,-1):
self.currentTime = time.time()
# Here x and y are swapped. I dont know why.
#notNull = cv_depth_image[self.depth_point[1]][self.depth_point[0]]
last_depth_2 = self.bDepth.wDepthImage(cv_depth_image,self.depth_point[1],self.depth_point[0])
if last_depth_2 == 0 or last_depth_2 > 2000:
return
self.last_depth = last_depth_2
if (self.currentTime - self.lastTime) > 4:
rr = self.last_depth*-0.2478+253.15
st=0
#self.gHelper.testRotate(int(rr))
self.lastTime = time.time()
if self.last_depth < 1000:
self.lastMove = self.last_depth
rr = self.last_depth*-0.2478+253.15
st = 0
while rr > st :
self.gHelper.testRotate(int(st))
st = st + 20
print("st:" + str(st))
print("rr:" + str(rr))
print("==here")
self.gHelper.testPlace(int(rr))
self.depth_point = (-1,-1)
self.say_im_finish()
rospy.signal_shutdown(1)
sys.exit(1)
def main():
if len(sys.argv) != 3:
print("Please give the following arguments <camera-img-topic> and <camera-depth-topic>")
print("Like: marker_attack.py /camera/rgb/image_raw /camera/depth/image_raw")
return 1
print("OK")
ic = gripper_mover(str(sys.argv[1]),str(sys.argv[2]))
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
+3
View File
@@ -0,0 +1,3 @@
.vscode/
turtle_control/CMakeFiles/*
Docker/turtle_control/*
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
sudo docker exec -it ros-core bash
+34
View File
@@ -0,0 +1,34 @@
#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: {}
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
sudo docker rm -f $(sudo docker ps -a -q)
+62
View File
@@ -0,0 +1,62 @@
#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
+9
View File
@@ -0,0 +1,9 @@
#!/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
+21
View File
@@ -0,0 +1,21 @@
#!/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
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
#Stops all docker container
sudo docker stop $(sudo docker ps -a -q)
sudo docker ps
View File
+83
View File
@@ -0,0 +1,83 @@
#include <string.h>
#include <Servo.h>
#define LED 13
#define PIN_OFFSET 2 //At which pin is the first connection, must be in row
#define SERVO_NUM 7
int servoPos[SERVO_NUM] = {0};
Servo ser[SERVO_NUM];
void setup() {
//start serial connection
Serial.begin(9600);
pinMode(LED, OUTPUT);
for(int i = 0;i<SERVO_NUM;i++)
{
ser[i].attach(i + PIN_OFFSET);
}
Serial.println("START");
}
void setAllZero()
{
for(int i = 0;i<SERVO_NUM;i++)
{
servoPos[i] = 0;
delay(200);
}
}
void moveServoSlowly(int servo,int pos)
{
for(int i = 0;i< pos;i++)
{
ser[servo].write(i);
delay(10);
}
}
void moveServo()
{
for(int i = 0;i<SERVO_NUM;i++)
{
//ser[i].write(servoPos[i]);
moveServoSlowly(i,servoPos[i]);
delay(200);
}
}
void printAll()
{
for(int i = 0;i<SERVO_NUM;i++)
{
Serial.println(servoPos[i]);
}
}
void loop() {
String str = Serial.readString();
// String str = "1456,677,123,456,789,999,111";
str.trim();
if(str[0] == '1')
{
digitalWrite(LED, HIGH);
Serial.println("OK1");
str.remove(0,1);
sscanf(str.c_str(),"%d,%d,%d,%d,%d,%d,%d",&servoPos[0],&servoPos[1],&servoPos[2],&servoPos[3],&servoPos[4],&servoPos[5],&servoPos[6]);
printAll();
moveServo();
digitalWrite(LED, LOW);
}
else if (str[0] == '0')
{
Serial.println("OK0");
setAllZero();
moveServo();
}
delay(10);
}
+68
View File
@@ -0,0 +1,68 @@
#include <Servo.h>
#include <string.h>
int cX = 0;
int cY = 0;
#define LED 13
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);
}
//Lets assume 640 × 480p
void moveRightLeft()
{
if(cX > 320)
{
s.write(180);
}
else
{
s.write(0);
}
delay(300);
}
void moveUpDown()
{
if(cY > 200)
{
s3.write(180);
}
else
{
s3.write(0);
}
delay(300);
}
void loop() {
if (Serial.available() > 0) {
digitalWrite(LED, HIGH);
String str = Serial.readString();
str.trim();
Serial.println(str);
if(str.charAt(0) == '1')
{
str.remove(0,1);
sscanf(str.c_str(),"%d,%d",&cX,&cY);
Serial.println(cX);
Serial.println(cY);
Serial.println("======");
moveRightLeft();
moveUpDown();
}
digitalWrite(LED, LOW);
}
}
+30
View File
@@ -0,0 +1,30 @@
class betterDepth():
lastResult = 0.0
maxDistance = 0
def __init__(self,maxDistante : int = 1000):
self.maxDistante = maxDistante
def getProperDepth(self,vListe : list) -> float:
def checkList(ele):
if ele > 400 and ele < self.maxDistante:
return True
return False
self.lastResult = 0.0
vNewListe = list(filter(checkList, vListe)) #Filter the list before we use it
for i,val in enumerate(vNewListe):
self.lastResult += val
self.lastResult = self.lastResult / len(vNewListe)
return self.lastResult
#Pass the depthimage that has already been converted and the depth point x, y
#The idea here is that one depth point is not enough so we use the 9 most adjacent points
def wDepthImage(self, cv_depth_image : list, dX : int, dY : int) -> float:
vDepthPoints = []
for z in range(0, 8):
vDepthPoints.append(cv_depth_image[dX - 4 + z][dY - 4 + z])
self.getProperDepth(vDepthPoints)
return self.lastResult
vListe = [1,500,600,500,600,450,650,1999]
bD = betterDepth()
mmDepth = bD.getProperDepth(vListe)
print(mmDepth)
+16
View File
@@ -0,0 +1,16 @@
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
+52
View File
@@ -0,0 +1,52 @@
import serial
#pip3 install pyserial
MAX_SERV = 7
currentState = [1, 2, 3, 4, 5, 6, 7]
globalSerial = 0
def openSerial():
port = "/dev/ttyACM0"
baud = 9600
ser = serial.Serial(port, baud, timeout=1)
return ser
# Make sure data is in the format like: "%d,%d,%d,%d,%d,%d,%d"
def sendData(ser, data: str):
dataSend = "1" + data
ser.write(dataSend.encode("utf-8"))
print("=Data written=")
def buildAndSendData():
sendThis = ""
for x in range(0, MAX_SERV):
sendThis += str(currentState[x]) + ","
sendThis = sendThis[:-1]
print(sendThis)
sendData(globalSerial,sendThis)
def printState():
for x in range(0, MAX_SERV):
print("Servo {} is set to {}".format(x,currentState[x]))
def testLoop():
while True:
printState()
print("=========")
id = input("Type in an ID\n")
degree = input("Type in an Degree\n")
if id and degree:
currentState[int(id)] = int(degree)
buildAndSendData()
print(chr(27) + "[2J") #Clear terminal maybe
pass
if __name__ == "__main__":
globalSerial = openSerial()
buildAndSendData()
testLoop()
+52
View File
@@ -0,0 +1,52 @@
#!/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
View File
File diff suppressed because it is too large Load Diff
+193
View File
@@ -0,0 +1,193 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import argparse
import numpy as np
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.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_ARUCO_ORIGINAL",
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, 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)
for markerCorner in corners:
corners = markerCorner.reshape((4,2))
(top_left, top_right, bottom_right, bottom_left) = corners
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.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
(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("##############################################")
self.t.linear.x = 0.1
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
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
self.pub.publish(self.t)
self.rate.sleep()
#print(corners[0][0])
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()
return img
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:
cv_image = self.markDetected(ids, cv_image, corners)
#else:
#self.t.angular.z = 0.8
#self.t.linear.x = 0.2
#self.pub.publish(self.t)
#self.rate.sleep()
#self.t.angular.z = -0.8
#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)
+200
View File
@@ -0,0 +1,200 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import argparse
import numpy as np
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.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_ARUCO_ORIGINAL",
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()
self.storedMarkerPoints = []
### 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)
for markerCorner in corners:
corners = markerCorner.reshape((4,2))
(top_left, top_right, bottom_right, bottom_left) = corners
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.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
(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("##############################################")
self.t.linear.x = 0.1
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
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
self.pub.publish(self.t)
self.rate.sleep()
#print(corners[0][0])
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()
return img
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:
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)
#else:
#self.t.angular.z = 0.8
#self.t.linear.x = 0.2
#self.pub.publish(self.t)
#self.rate.sleep()
#self.t.angular.z = -0.8
#self.pub.publish(self.t)
#self.rate.sleep()
#####
cv2.imshow("Image window", cv_image)
cv2.waitKey(3)
def main(args):
ic = image_converter()
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main(sys.argv)
+148
View File
@@ -0,0 +1,148 @@
#!/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
+127
View File
@@ -0,0 +1,127 @@
#!/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)
+84
View File
@@ -0,0 +1,84 @@
import serial
import time
class gripperArdunio():
globalSerial = 0
MAX_SERV = 7
def __init__(self):
port = "/dev/ttyACM0"
baud = 9600
self.globalSerial = serial.Serial(port, baud, timeout=1)
def sendData(self,ser, data: str):
dataSend = "1" + data
ser.write(dataSend.encode("utf-8"))
print("==DATA SEND==")
def buildAndSendData(self,data):
sendThis = ""
for x in range(0, self.MAX_SERV):
sendThis += str(data[x]) + ","
sendThis = sendThis[:-1]
print(sendThis)
self.sendData(self.globalSerial,sendThis)
time.sleep(2)
def normalMove(self):
time.sleep(1)
data = [10, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def testMove(self,degrees):
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 1, 100, 150, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def testPlace(self,degrees):
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 20, 100, 150, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def testRotate(self,degrees):
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def grabK(self):
data = [0, 0, 90, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 0, 60, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 18, 60, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 18, 70, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 26, 70, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 26, 75, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 29, 75, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 29, 78, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 33, 78, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 33, 82, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 37, 88, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 38, 88, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 38, 88, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 38, 88, 63, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 20, 90, 63, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 0, 90, 63, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 0, 90, 90, 0, 0, 0]
self.buildAndSendData(data)
+82
View File
@@ -0,0 +1,82 @@
#include <string.h>
#include <Servo.h>
#define LED 13
#define PIN_OFFSET 2 //At which pin is the first connection, must be in row
#define SERVO_NUM 7
int servoPos[SERVO_NUM] = {0};
Servo ser[SERVO_NUM];
//VarSpeedServo myServo;
void setup() {
//start serial connection
Serial.begin(9600);
pinMode(LED, OUTPUT);
for(int i = 0;i<SERVO_NUM;i++)
{
ser[i].attach(i + PIN_OFFSET);
}
Serial.println("START");
}
void setAllZero()
{
for(int i = 0;i<SERVO_NUM;i++)
{
servoPos[i] = 0;
delay(200);
}
}
void moveServoSlowly(int servo,int pos)
{
for(int i = 0;i< pos;i++)
{
ser[servo].write(i);
delay(10);
}
}
void moveServo()
{
for(int i = 0;i<SERVO_NUM;i++)
{
ser[i].write(servoPos[i]);
// moveServoSlowly(i,servoPos[i]);
delay(200);
}
}
void printAll()
{
for(int i = 0;i<SERVO_NUM;i++)
{
Serial.println(servoPos[i]);
}
}
void loop() {
String str = Serial.readString();
// String str = "1456,677,123,456,789,999,111";
str.trim();
if(str[0] == '1')
{
digitalWrite(LED, HIGH);
Serial.println("OK1");
str.remove(0,1);
sscanf(str.c_str(),"%d,%d,%d,%d,%d,%d,%d",&servoPos[0],&servoPos[1],&servoPos[2],&servoPos[3],&servoPos[4],&servoPos[5],&servoPos[6]);
printAll();
moveServo();
digitalWrite(LED, LOW);
}
delay(10);
}
+33
View File
@@ -0,0 +1,33 @@
class betterDepth():
lastResult = 0.0
maxDistance = 0
def __init__(self,maxDistante : int = 2000):
self.maxDistante = maxDistante
def getProperDepth(self,vListe : list) -> float:
def checkList(ele):
if ele > 400 and ele < self.maxDistante:
return True
return False
self.lastResult = 0.0
vNewListe = list(filter(checkList, vListe)) #Filter the list before we use it
if len(vNewListe) == 0:
return self.lastResult
for i,val in enumerate(vNewListe):
self.lastResult += val
self.lastResult = self.lastResult / len(vNewListe)
return self.lastResult
#Pass the depthimage that has already been converted and the depth point x, y
#The idea here is that one depth point is not enough so we use the 9 most adjacent points
def wDepthImage(self, cv_depth_image : list, dX : int, dY : int) -> float:
vDepthPoints = []
for z in range(0, 8):
vDepthPoints.append(cv_depth_image[dX - 4 + z][dY - 4 + z])
self.getProperDepth(vDepthPoints)
return self.lastResult
if __name__ == "__main__":
vListe = [1,500,600,500,600,450,650,1999]
bD = betterDepth()
mmDepth = bD.getProperDepth(vListe)
print(mmDepth)
+84
View File
@@ -0,0 +1,84 @@
import serial
import time
class gripperArdunio():
globalSerial = 0
MAX_SERV = 7
def __init__(self):
port = "/dev/ttyACM1"
baud = 9600
self.globalSerial = serial.Serial(port, baud, timeout=1)
def sendData(self,ser, data: str):
dataSend = "1" + data
ser.write(dataSend.encode("utf-8"))
print("==DATA SEND==")
def buildAndSendData(self,data):
sendThis = ""
for x in range(0, self.MAX_SERV):
sendThis += str(data[x]) + ","
sendThis = sendThis[:-1]
print(sendThis)
self.sendData(self.globalSerial,sendThis)
time.sleep(2)
def normalMove(self):
time.sleep(1)
data = [10, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def testMove(self,degrees):
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 1, 100, 150, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def testPlace(self,degrees):
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 20, 100, 150, 0, 0, 0]
self.buildAndSendData(data)
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def testRotate(self,degrees):
data = [degrees, 1, 100, 80, 0, 0, 0]
self.buildAndSendData(data)
def grabK(self):
data = [0, 0, 90, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 0, 60, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 18, 60, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 18, 70, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 26, 70, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 26, 75, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 29, 75, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 29, 78, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 33, 78, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 33, 82, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 37, 88, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 38, 88, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 38, 88, 90, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 38, 88, 63, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 20, 90, 63, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 0, 90, 63, 0, 0, 0]
self.buildAndSendData(data)
data = [0, 0, 90, 90, 0, 0, 0]
self.buildAndSendData(data)
+194
View File
@@ -0,0 +1,194 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import random
import numpy as np
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import Twist
import gripperHelper
import bDepth
class gripper_mover():
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)
turtle_is_here = 0
def wait_for_here_callback(self,data):
rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
if data.data == "IMHERE":
self.turtle_is_here = 1
def wait_for_here(self):
sub = rospy.Subscriber("chatterabc", String, self.wait_for_here_callback)
while self.turtle_is_here == 0:
print("Turtle is not here")
self.rate.sleep()
sub.unregister()
print("Turtle IS here")
def say_im_finish(self):
pub = rospy.Publisher('grippertalker', String, queue_size=10)
for x in range(0, 50):
hello_str = "GRIPFINISH"
print("IM FINISHED")
pub.publish(hello_str)
self.rate.sleep()
def __init__(self, astra_camera_rgb_topic : str, astra_camera_depth_topic : str , start_id : int = 1):
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.gHelper = gripperHelper.gripperArdunio()
# self.gHelper.testMove(10)
self.gHelper.grabK()
self.bDepth = bDepth.betterDepth()
### For turtle controll
# self.wait_for_subscribers()
self.wait_for_publisher(astra_camera_rgb_topic,astra_camera_depth_topic)
self.bridge = CvBridge()
rospy.init_node("turtle_control", anonymous=True)
self.rate = rospy.Rate(30) # update rate can be increased
self.wait_for_here()
self.depth_point = (-1,-1) #This is the point from where we get the depth
self.last_depth = -1 #This is the last depth from the depth_point
self.last_depth2 = -1
self.depth_counter = 0 #Make sure we are really there by counting how many time we got this result
self.rState = 0
self.lastMove = 0
self.image_sub = rospy.Subscriber(
astra_camera_rgb_topic, Image, self.callback_rgb
)
self.depth_bridge = CvBridge()
self.lastTime = time.time()
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):
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)
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 corners: #marker corners
#Now seleted the corners of the tag with the right id => the tag that indicates the distance to the gripper
i = np.where(ids == self.target_id) # wahrscheinlich 1 und 0
if len(i[0]) > 0:
fitting_corners = corners[i[0][0]]
self.markDetected(cv_image, fitting_corners)
tM = np.where(ids == 0) #Now try to get the marker that indicates the turtlebot
else:
self.depth_point = (-1,-1)
cv2.rectangle(cv_image,(0,0),(700,120),(10, 10, 10),-1)
#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, (200, 200, 200), 2, cv2.LINE_8)
depthString = "DepthPoint:" + str(self.depth_point[0]) +"x" +str(self.depth_point[1]) + "Distance:" + str(self.last_depth)
cv2.putText(cv_image, depthString, (10,60), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
depthString2 = "LastMove:" + str(self.lastMove)
cv2.putText(cv_image, depthString2, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
self.rate.sleep()
cv2.imshow("Window", cv_image)
cv2.waitKey(1)
def callback_depth(self, data):
#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")
if self.depth_point != (-1,-1):
self.currentTime = time.time()
# Here x and y are swapped. I dont know why.
#notNull = cv_depth_image[self.depth_point[1]][self.depth_point[0]]
last_depth_2 = self.bDepth.wDepthImage(cv_depth_image,self.depth_point[1],self.depth_point[0])
if last_depth_2 == 0 or last_depth_2 > 2000:
return
self.last_depth = last_depth_2
if (self.currentTime - self.lastTime) > 4:
rr = self.last_depth*-0.2478+253.15
st=0
#self.gHelper.testRotate(int(rr))
self.lastTime = time.time()
if self.last_depth < 1000:
self.lastMove = self.last_depth
rr = self.last_depth*-0.2478+253.15
st = 0
while rr > st :
self.gHelper.testRotate(int(st))
st = st + 20
print("st:" + str(st))
print("rr:" + str(rr))
print("==here")
self.gHelper.testPlace(int(rr))
self.depth_point = (-1,-1)
self.say_im_finish()
rospy.signal_shutdown(1)
sys.exit(1)
def main():
if len(sys.argv) != 3:
print("Please give the following arguments <camera-img-topic> and <camera-depth-topic>")
print("Like: marker_attack.py /camera/rgb/image_raw /camera/depth/image_raw")
return 1
print("OK")
ic = gripper_mover(str(sys.argv[1]),str(sys.argv[2]))
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
+76
View File
@@ -0,0 +1,76 @@
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import numpy as np
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import Twist
import serial
def openSerial():
port = '/dev/ttyACM0'
baud = 9600
ser = serial.Serial(port, baud, timeout=1)
return ser
def sendData(ser,data):
dataSend = "1" + str(data[0]) + "," + str(data[1])
print(dataSend)
ser.write(dataSend.encode('utf-8'))
print("=Data written=")
class camera_marker_finder():
def __init__(self, astra_rgb_topic : str):
self.bridge = CvBridge()
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
self.arucoParams = cv2.aruco.DetectorParameters_create()
rospy.init_node("gripper_master", anonymous=True)
self.rate = rospy.Rate(10)
self.image_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
self.serial = openSerial()
def markDetected(self, img, corners):
for markerCorner in corners:
(top_left, top_right, bottom_right, bottom_left) = markerCorner.reshape((4,2))
return (int((top_left[0] + bottom_right[0]) / 2), int((top_left[1] + bottom_right[1]) / 2))
def callback_rgb(self, data):
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
(self.h, self.w) = cv_image.shape[:2]
(corners, ids, rejected) = cv2.aruco.detectMarkers(cv_image, self.arucoDict, parameters=self.arucoParams)
if corners:
results = self.markDetected(cv_image, corners)
print("Yes I see a marker at X:" + str(results[0]) + " Y:" + str(results[1]))
sendData(self.serial,results)
else:
print("No marker in image")
self.rate.sleep()
cv2.waitKey(1)
def main():
if len(sys.argv) != 2:
print("Please give the following arguments <camera-img-topic>")
print("Like: {} /camera/rgb/image_raw".format(str(sys.argv[0])))
return 1
ic = camera_marker_finder(str(sys.argv[1]))
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
+143
View File
@@ -0,0 +1,143 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import numpy as np
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import Twist
import bDepth
class gripper_mover():
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, astra_camera_rgb_topic : str, astra_camera_depth_topic : str, start_id : int = 1):
self.target_id = start_id #We target one tag at a time
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
self.arucoParams_test = cv2.aruco.DetectorParameters_create()
self.arucoParams = self.arucoParams_test
self.maxMinDepth = 0.5
self.bDepth = bDepth.betterDepth()
### For turtle controll
# self.wait_for_subscribers()
self.wait_for_publisher(astra_camera_rgb_topic,astra_camera_depth_topic)
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.depth_point2 = (-1,-1)
self.last_depth = -1 #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):
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)
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 corners: #marker corners
#Now seleted the corners of the tag with the right id => the tag that indicates the distance to the gripper
i = np.where(ids == self.target_id) # wahrscheinlich 1 und 0
if len(i[0]) > 0:
fitting_corners = corners[i[0][0]]
self.markDetected(cv_image, fitting_corners)
tM = np.where(ids == 0) #Now try to get the marker that indicates the turtlebot
else:
self.depth_point = (-1,-1)
cv2.rectangle(cv_image,(0,0),(700,120),(10, 10, 10),-1)
#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, (200, 200, 200), 2, cv2.LINE_8)
depthString = "DepthPoint:" + str(self.depth_point[0]) +"x" +str(self.depth_point[1])
cv2.putText(cv_image, depthString, (10,60), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
depthString2 = "Distance to marker:" + str(self.last_depth)
cv2.putText(cv_image, depthString2, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
self.rate.sleep()
cv2.imshow("Window", cv_image)
cv2.waitKey(1)
def callback_depth(self, data):
#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")
if self.depth_point != (-1,-1):
# Here x and y are swapped. I dont know why.
#notNull = cv_depth_image[self.depth_point[1]][self.depth_point[0]]
testDepth = self.bDepth.wDepthImage(cv_depth_image,self.depth_point[1],self.depth_point[0])
if testDepth < 500:
return
self.last_depth = self.bDepth.wDepthImage(cv_depth_image,self.depth_point[1],self.depth_point[0])
def main():
if len(sys.argv) != 3:
print("Please give the following arguments <camera-img-topic> and <camera-depth-topic>")
print("Like: marker_attack.py /camera/rgb/image_raw /camera/depth/image_raw")
return 1
print("OK")
ic = gripper_mover(str(sys.argv[1]),str(sys.argv[2]))
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
+50
View File
@@ -0,0 +1,50 @@
#!/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!"
+196
View File
@@ -0,0 +1,196 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import numpy as np
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 = 0.5
### 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(8) # 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:
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.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 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()
+203
View File
@@ -0,0 +1,203 @@
#!/usr/bin/env python
#pip3 install opencv-python3==4.9.0.80
#pip3 install rospy
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import numpy as np
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 = 0.5
### 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(10) # 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)
depthString2 = "Res:" + str(self.w) + "x" + str(self.h) + " RState:" + str(self.rState) + " MMDepth:" + str(self.maxMinDepth)
# cv2.putText(cv_image, depthString2, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (255, 0, 0), 2, cv2.LINE_8)
self.rate.sleep()
print(idString)
print(depthString)
print(depthString2)
print("=======")
# 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:
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.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 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()
+182
View File
@@ -0,0 +1,182 @@
#!/usr/bin/env python
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import random
import numpy as np
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import Twist
import gripperHelper
import bDepth
class gripper_mover():
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)
turtle_is_here = 0
def wait_for_here_callback(self,data):
rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
if data.data == "IMHERE":
self.turtle_is_here = 1
def wait_for_here(self):
sub = rospy.Subscriber("chatter", String, self.wait_for_here_callback)
while self.turtle_is_here == 0:
print("Turtle is not here")
self.rate.sleep()
sub.unregister()
print("Turtle IS here")
def __init__(self, astra_camera_rgb_topic : str, astra_camera_depth_topic : str , start_id : int = 1):
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.gHelper = gripperHelper.gripperArdunio()
#self.gHelper.testMove(10)
self.gHelper.grabK()
self.bDepth = bDepth.betterDepth()
### For turtle controll
# self.wait_for_subscribers()
self.wait_for_publisher(astra_camera_rgb_topic,astra_camera_depth_topic)
self.bridge = CvBridge()
rospy.init_node("turtle_control", anonymous=True)
self.rate = rospy.Rate(30) # update rate can be increased
self.wait_for_here()
self.depth_point = (-1,-1) #This is the point from where we get the depth
self.last_depth = -1 #This is the last depth from the depth_point
self.last_depth2 = -1
self.depth_counter = 0 #Make sure we are really there by counting how many time we got this result
self.rState = 0
self.lastMove = 0
self.image_sub = rospy.Subscriber(
astra_camera_rgb_topic, Image, self.callback_rgb
)
self.depth_bridge = CvBridge()
self.lastTime = time.time()
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):
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)
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 corners: #marker corners
#Now seleted the corners of the tag with the right id => the tag that indicates the distance to the gripper
i = np.where(ids == self.target_id) # wahrscheinlich 1 und 0
if len(i[0]) > 0:
fitting_corners = corners[i[0][0]]
self.markDetected(cv_image, fitting_corners)
tM = np.where(ids == 0) #Now try to get the marker that indicates the turtlebot
else:
self.depth_point = (-1,-1)
cv2.rectangle(cv_image,(0,0),(700,120),(10, 10, 10),-1)
#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, (200, 200, 200), 2, cv2.LINE_8)
depthString = "DepthPoint:" + str(self.depth_point[0]) +"x" +str(self.depth_point[1]) + "Distance:" + str(self.last_depth)
cv2.putText(cv_image, depthString, (10,60), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
depthString2 = "LastMove:" + str(self.lastMove)
cv2.putText(cv_image, depthString2, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (200, 200, 200), 2, cv2.LINE_8)
self.rate.sleep()
cv2.imshow("Window", cv_image)
cv2.waitKey(1)
def callback_depth(self, data):
#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")
if self.depth_point != (-1,-1):
self.currentTime = time.time()
# Here x and y are swapped. I dont know why.
#notNull = cv_depth_image[self.depth_point[1]][self.depth_point[0]]
last_depth_2 = self.bDepth.wDepthImage(cv_depth_image,self.depth_point[1],self.depth_point[0])
if last_depth_2 == 0 or last_depth_2 > 2000:
return
self.last_depth = last_depth_2
if (self.currentTime - self.lastTime) > 4:
rr = self.last_depth*-0.2478+253.15
st=0
#self.gHelper.testRotate(int(rr))
self.lastTime = time.time()
if self.last_depth < 1000:
self.lastMove = self.last_depth
rr = self.last_depth*-0.2478+253.15
st=0
while rr>st :
self.gHelper.testRotate(int(st))
st=st+20
self.gHelper.testPlace(int(rr))
self.depth_point = (-1,-1)
rospy.signal_shutdown(1)
def main():
if len(sys.argv) != 3:
print("Please give the following arguments <camera-img-topic> and <camera-depth-topic>")
print("Like: marker_attack.py /camera/rgb/image_raw /camera/depth/image_raw")
return 1
print("OK")
ic = gripper_mover(str(sys.argv[1]),str(sys.argv[2]))
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
+76
View File
@@ -0,0 +1,76 @@
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import numpy as np
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import Twist
import serial
def openSerial():
port = '/dev/ttyACM0'
baud = 9600
ser = serial.Serial(port, baud, timeout=1)
return ser
def sendData(ser,data):
dataSend = "1" + str(data[0]) + "," + str(data[1])
print(dataSend)
ser.write(dataSend.encode('utf-8'))
print("=Data written=")
class camera_marker_finder():
def __init__(self, astra_rgb_topic : str):
self.bridge = CvBridge()
self.arucoDict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
self.arucoParams = cv2.aruco.DetectorParameters_create()
rospy.init_node("gripper_master", anonymous=True)
self.rate = rospy.Rate(10)
self.image_sub = rospy.Subscriber(astra_rgb_topic, Image, self.callback_rgb)
self.serial = openSerial()
def markDetected(self, img, corners):
for markerCorner in corners:
(top_left, top_right, bottom_right, bottom_left) = markerCorner.reshape((4,2))
return (int((top_left[0] + bottom_right[0]) / 2), int((top_left[1] + bottom_right[1]) / 2))
def callback_rgb(self, data):
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
(self.h, self.w) = cv_image.shape[:2]
(corners, ids, rejected) = cv2.aruco.detectMarkers(cv_image, self.arucoDict, parameters=self.arucoParams)
if corners:
results = self.markDetected(cv_image, corners)
print("Yes I see a marker at X:" + str(results[0]) + " Y:" + str(results[1]))
sendData(self.serial,results)
else:
print("No marker in image")
self.rate.sleep()
cv2.waitKey(1)
def main():
if len(sys.argv) != 2:
print("Please give the following arguments <camera-img-topic>")
print("Like: {} /camera/rgb/image_raw".format(str(sys.argv[0])))
return 1
ic = camera_marker_finder(str(sys.argv[1]))
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
+95
View File
@@ -0,0 +1,95 @@
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()
+165
View File
@@ -0,0 +1,165 @@
#!/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
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 802 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+236
View File
@@ -0,0 +1,236 @@
#!/usr/bin/env python
#pip3 install pencv-python3==4.9.0.80
#pip3 install rospy
from __future__ import print_function
import roslib
import sys
import rospy
import cv2
import time
import numpy as np
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 say_im_here(self):
for x in range(0, 40):
hello_str = "IMHERE"
rospy.loginfo(hello_str)
self.pub2.publish(hello_str)
self.rate.sleep()
gripper_finish = 0
stopAll = 0
def wait_for_gripper_callback(selfi,data):
spy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
if data.data == "GRIPFINISH":
self.gripper_finish = 1
def wait_for_gripper(self):
sub = rospy.Subscriber("grippertalker", String, self.wait_for_gripper_callback)
while self.gripper_finish == 0:
print("Gripper has not finished")
self.rate.sleep()
print("Gripper finished")
sub.unregister()
self.stopAll = 0
def __init__(self, turlte_bot_topic : str, astra_camera_rgb_topic : str, astra_camera_depth_topic : str ,speed_emul : float = 1, start_id : int = 5):
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 = 0.5
### For turtle controll
self.pub = rospy.Publisher(turlte_bot_topic, Twist, queue_size=1)
self.pub2 = rospy.Publisher('chatterabc', String, queue_size=10)
# 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(30) # 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.stopAll == 1:
return 0
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.15 * 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.15 * 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)
depthString2 = "Res:" + str(self.w) + "x" + str(self.h) + " RState:" + str(self.rState) + " MMDepth:" + str(self.maxMinDepth)
# cv2.putText(cv_image, depthString2, (10,90), cv2.FONT_HERSHEY_TRIPLEX , 0.8, (255, 0, 0), 2, cv2.LINE_8)
self.rate.sleep()
print(idString)
print(depthString)
print(depthString2)
print("=======")
# 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 > 500:
self.depth_counter += 1 #Sometimes the data is inacurate make sure we get the data at least 5times
if self.last_depth < 800:
if self.depth_counter > 0:
print("We are really there")
# self.target_id += 1
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
self.stopAll = 1
self.say_im_here()
self.wait_for_gripper()
else:
self.depth_counter = 0
#We dont need to sleep twice
#self.rate.sleep()
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()
+721
View File
@@ -0,0 +1,721 @@
# 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
+205
View File
@@ -0,0 +1,205 @@
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)
+105
View File
@@ -0,0 +1,105 @@
# 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:
+2
View File
@@ -0,0 +1,2 @@
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 0)
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 0)
+7
View File
@@ -0,0 +1,7 @@
# 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")
+576
View File
@@ -0,0 +1,576 @@
# 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
+2
View File
@@ -0,0 +1,2 @@
- setup-file:
local-name: /home/dennis/catkin_ws/src/turtle_control/devel/setup.sh
+304
View File
@@ -0,0 +1,304 @@
#!/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)
+16
View File
@@ -0,0 +1,16 @@
#!/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 "$@"
+8
View File
@@ -0,0 +1,8 @@
#!/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
+9
View File
@@ -0,0 +1,9 @@
#!/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
+8
View File
@@ -0,0 +1,8 @@
#!/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'
+8
View File
@@ -0,0 +1,8 @@
#!/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"
+96
View File
@@ -0,0 +1,96 @@
#!/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
+8
View File
@@ -0,0 +1,8 @@
#!/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"'
@@ -0,0 +1,24 @@
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 "")
+16
View File
@@ -0,0 +1,16 @@
#!/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 "$@"
+30
View File
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import stat
import sys
# find the import for catkin's python package - either from source space or from an installed underlay
if os.path.exists(os.path.join('/opt/ros/noetic/share/catkin/cmake', 'catkinConfig.cmake.in')):
sys.path.insert(0, os.path.join('/opt/ros/noetic/share/catkin/cmake', '..', 'python'))
try:
from catkin.environment_cache import generate_environment_script
except ImportError:
# search for catkin package in all workspaces and prepend to path
for workspace in '/opt/ros/noetic'.split(';'):
python_path = os.path.join(workspace, 'lib/python3/dist-packages')
if os.path.isdir(os.path.join(python_path, 'catkin')):
sys.path.insert(0, python_path)
break
from catkin.environment_cache import generate_environment_script
code = generate_environment_script('/home/dennis/catkin_ws/src/turtle_control/devel/env.sh')
output_filename = '/home/dennis/catkin_ws/src/turtle_control/catkin_generated/setup_cached.sh'
with open(output_filename, 'w') as f:
# print('Generate script for cached setup "%s"' % output_filename)
f.write('\n'.join(code))
mode = os.stat(output_filename).st_mode
os.chmod(output_filename, mode | stat.S_IXUSR)
+2
View File
@@ -0,0 +1,2 @@
- setup-file:
local-name: /usr/local/setup.sh
+304
View File
@@ -0,0 +1,304 @@
#!/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)
+16
View File
@@ -0,0 +1,16 @@
#!/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 "$@"
@@ -0,0 +1,8 @@
#!/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
@@ -0,0 +1,9 @@
#!/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:=/usr/local}
CATKIN_SETUP_UTIL_ARGS="--extend --local"
. "$_CATKIN_SETUP_DIR/setup.sh"
unset CATKIN_SETUP_UTIL_ARGS
@@ -0,0 +1,8 @@
#!/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'
+8
View File
@@ -0,0 +1,8 @@
#!/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"
+96
View File
@@ -0,0 +1,96 @@
#!/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:=/usr/local}
_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
+8
View File
@@ -0,0 +1,8 @@
#!/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"'
@@ -0,0 +1,8 @@
prefix=/usr/local
Name: turtle_control
Description: Description of turtle_control
Version: 0.0.0
Cflags:
Libs: -L${prefix}/lib
Requires:
@@ -0,0 +1,14 @@
# generated from catkin/cmake/template/pkgConfig-version.cmake.in
set(PACKAGE_VERSION "0.0.0")
set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)
if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT True)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
if("${PACKAGE_FIND_VERSION}" VERSION_LESS "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
@@ -0,0 +1,223 @@
# generated from catkin/cmake/template/pkgConfig.cmake.in
# append elements to a list and remove existing duplicates from the list
# copied from catkin/cmake/list_append_deduplicate.cmake to keep pkgConfig
# self contained
macro(_list_append_deduplicate listname)
if(NOT "${ARGN}" STREQUAL "")
if(${listname})
list(REMOVE_ITEM ${listname} ${ARGN})
endif()
list(APPEND ${listname} ${ARGN})
endif()
endmacro()
# append elements to a list if they are not already in the list
# copied from catkin/cmake/list_append_unique.cmake to keep pkgConfig
# self contained
macro(_list_append_unique listname)
foreach(_item ${ARGN})
list(FIND ${listname} ${_item} _index)
if(_index EQUAL -1)
list(APPEND ${listname} ${_item})
endif()
endforeach()
endmacro()
# pack a list of libraries with optional build configuration keywords
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
# self contained
macro(_pack_libraries_with_build_configuration VAR)
set(${VAR} "")
set(_argn ${ARGN})
list(LENGTH _argn _count)
set(_index 0)
while(${_index} LESS ${_count})
list(GET _argn ${_index} lib)
if("${lib}" MATCHES "^(debug|optimized|general)$")
math(EXPR _index "${_index} + 1")
if(${_index} EQUAL ${_count})
message(FATAL_ERROR "_pack_libraries_with_build_configuration() the list of libraries '${ARGN}' ends with '${lib}' which is a build configuration keyword and must be followed by a library")
endif()
list(GET _argn ${_index} library)
list(APPEND ${VAR} "${lib}${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}")
else()
list(APPEND ${VAR} "${lib}")
endif()
math(EXPR _index "${_index} + 1")
endwhile()
endmacro()
# unpack a list of libraries with optional build configuration keyword prefixes
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
# self contained
macro(_unpack_libraries_with_build_configuration VAR)
set(${VAR} "")
foreach(lib ${ARGN})
string(REGEX REPLACE "^(debug|optimized|general)${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}(.+)$" "\\1;\\2" lib "${lib}")
list(APPEND ${VAR} "${lib}")
endforeach()
endmacro()
if(turtle_control_CONFIG_INCLUDED)
return()
endif()
set(turtle_control_CONFIG_INCLUDED TRUE)
# set variables for source/devel/install prefixes
if("FALSE" STREQUAL "TRUE")
set(turtle_control_SOURCE_PREFIX /home/dennis/catkin_ws/src/turtle_control)
set(turtle_control_DEVEL_PREFIX /home/dennis/catkin_ws/src/turtle_control/devel)
set(turtle_control_INSTALL_PREFIX "")
set(turtle_control_PREFIX ${turtle_control_DEVEL_PREFIX})
else()
set(turtle_control_SOURCE_PREFIX "")
set(turtle_control_DEVEL_PREFIX "")
set(turtle_control_INSTALL_PREFIX /usr/local)
set(turtle_control_PREFIX ${turtle_control_INSTALL_PREFIX})
endif()
# warn when using a deprecated package
if(NOT "" STREQUAL "")
set(_msg "WARNING: package 'turtle_control' is deprecated")
# append custom deprecation text if available
if(NOT "" STREQUAL "TRUE")
set(_msg "${_msg} ()")
endif()
message("${_msg}")
endif()
# flag project as catkin-based to distinguish if a find_package()-ed project is a catkin project
set(turtle_control_FOUND_CATKIN_PROJECT TRUE)
if(NOT " " STREQUAL " ")
set(turtle_control_INCLUDE_DIRS "")
set(_include_dirs "")
if(NOT " " STREQUAL " ")
set(_report "Check the issue tracker '' and consider creating a ticket if the problem has not been reported yet.")
elseif(NOT " " STREQUAL " ")
set(_report "Check the website '' for information and consider reporting the problem.")
else()
set(_report "Report the problem to the maintainer 'dennis <dennis@todo.todo>' and request to fix the problem.")
endif()
foreach(idir ${_include_dirs})
if(IS_ABSOLUTE ${idir} AND IS_DIRECTORY ${idir})
set(include ${idir})
elseif("${idir} " STREQUAL "include ")
get_filename_component(include "${turtle_control_DIR}/../../../include" ABSOLUTE)
if(NOT IS_DIRECTORY ${include})
message(FATAL_ERROR "Project 'turtle_control' specifies '${idir}' as an include dir, which is not found. It does not exist in '${include}'. ${_report}")
endif()
else()
message(FATAL_ERROR "Project 'turtle_control' specifies '${idir}' as an include dir, which is not found. It does neither exist as an absolute directory nor in '\${prefix}/${idir}'. ${_report}")
endif()
_list_append_unique(turtle_control_INCLUDE_DIRS ${include})
endforeach()
endif()
set(libraries "")
foreach(library ${libraries})
# keep build configuration keywords, target names and absolute libraries as-is
if("${library}" MATCHES "^(debug|optimized|general)$")
list(APPEND turtle_control_LIBRARIES ${library})
elseif(${library} MATCHES "^-l")
list(APPEND turtle_control_LIBRARIES ${library})
elseif(${library} MATCHES "^-")
# This is a linker flag/option (like -pthread)
# There's no standard variable for these, so create an interface library to hold it
if(NOT turtle_control_NUM_DUMMY_TARGETS)
set(turtle_control_NUM_DUMMY_TARGETS 0)
endif()
# Make sure the target name is unique
set(interface_target_name "catkin::turtle_control::wrapped-linker-option${turtle_control_NUM_DUMMY_TARGETS}")
while(TARGET "${interface_target_name}")
math(EXPR turtle_control_NUM_DUMMY_TARGETS "${turtle_control_NUM_DUMMY_TARGETS}+1")
set(interface_target_name "catkin::turtle_control::wrapped-linker-option${turtle_control_NUM_DUMMY_TARGETS}")
endwhile()
add_library("${interface_target_name}" INTERFACE IMPORTED)
if("${CMAKE_VERSION}" VERSION_LESS "3.13.0")
set_property(
TARGET
"${interface_target_name}"
APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "${library}")
else()
target_link_options("${interface_target_name}" INTERFACE "${library}")
endif()
list(APPEND turtle_control_LIBRARIES "${interface_target_name}")
elseif(TARGET ${library})
list(APPEND turtle_control_LIBRARIES ${library})
elseif(IS_ABSOLUTE ${library})
list(APPEND turtle_control_LIBRARIES ${library})
else()
set(lib_path "")
set(lib "${library}-NOTFOUND")
# since the path where the library is found is returned we have to iterate over the paths manually
foreach(path /usr/local/lib;/opt/ros/noetic/lib)
find_library(lib ${library}
PATHS ${path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
if(lib)
set(lib_path ${path})
break()
endif()
endforeach()
if(lib)
_list_append_unique(turtle_control_LIBRARY_DIRS ${lib_path})
list(APPEND turtle_control_LIBRARIES ${lib})
else()
# as a fall back for non-catkin libraries try to search globally
find_library(lib ${library})
if(NOT lib)
message(FATAL_ERROR "Project '${PROJECT_NAME}' tried to find library '${library}'. The library is neither a target nor built/installed properly. Did you compile project 'turtle_control'? Did you find_package() it before the subdirectory containing its code is included?")
endif()
list(APPEND turtle_control_LIBRARIES ${lib})
endif()
endif()
endforeach()
set(turtle_control_EXPORTED_TARGETS "")
# create dummy targets for exported code generation targets to make life of users easier
foreach(t ${turtle_control_EXPORTED_TARGETS})
if(NOT TARGET ${t})
add_custom_target(${t})
endif()
endforeach()
set(depends "")
foreach(depend ${depends})
string(REPLACE " " ";" depend_list ${depend})
# the package name of the dependency must be kept in a unique variable so that it is not overwritten in recursive calls
list(GET depend_list 0 turtle_control_dep)
list(LENGTH depend_list count)
if(${count} EQUAL 1)
# simple dependencies must only be find_package()-ed once
if(NOT ${turtle_control_dep}_FOUND)
find_package(${turtle_control_dep} REQUIRED NO_MODULE)
endif()
else()
# dependencies with components must be find_package()-ed again
list(REMOVE_AT depend_list 0)
find_package(${turtle_control_dep} REQUIRED NO_MODULE ${depend_list})
endif()
_list_append_unique(turtle_control_INCLUDE_DIRS ${${turtle_control_dep}_INCLUDE_DIRS})
# merge build configuration keywords with library names to correctly deduplicate
_pack_libraries_with_build_configuration(turtle_control_LIBRARIES ${turtle_control_LIBRARIES})
_pack_libraries_with_build_configuration(_libraries ${${turtle_control_dep}_LIBRARIES})
_list_append_deduplicate(turtle_control_LIBRARIES ${_libraries})
# undo build configuration keyword merging after deduplication
_unpack_libraries_with_build_configuration(turtle_control_LIBRARIES ${turtle_control_LIBRARIES})
_list_append_unique(turtle_control_LIBRARY_DIRS ${${turtle_control_dep}_LIBRARY_DIRS})
_list_append_deduplicate(turtle_control_EXPORTED_TARGETS ${${turtle_control_dep}_EXPORTED_TARGETS})
endforeach()
set(pkg_cfg_extras "")
foreach(extra ${pkg_cfg_extras})
if(NOT IS_ABSOLUTE ${extra})
set(extra ${turtle_control_DIR}/${extra})
endif()
include(${extra})
endforeach()
+1
View File
@@ -0,0 +1 @@
set(ORDERED_PATHS "/opt/ros/noetic/lib")
+16
View File
@@ -0,0 +1,16 @@
set(_CATKIN_CURRENT_PACKAGE "turtle_control")
set(turtle_control_VERSION "0.0.0")
set(turtle_control_MAINTAINER "dennis <dennis@todo.todo>")
set(turtle_control_PACKAGE_FORMAT "2")
set(turtle_control_BUILD_DEPENDS "roscpp" "rospy")
set(turtle_control_BUILD_EXPORT_DEPENDS "roscpp" "rospy")
set(turtle_control_BUILDTOOL_DEPENDS "catkin")
set(turtle_control_BUILDTOOL_EXPORT_DEPENDS )
set(turtle_control_EXEC_DEPENDS "roscpp" "rospy")
set(turtle_control_RUN_DEPENDS "roscpp" "rospy")
set(turtle_control_TEST_DEPENDS )
set(turtle_control_DOC_DEPENDS )
set(turtle_control_URL_WEBSITE "")
set(turtle_control_URL_BUGTRACKER "")
set(turtle_control_URL_REPOSITORY "")
set(turtle_control_DEPRECATED "")
@@ -0,0 +1,8 @@
# generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "".split(';') if "" != "" else []
PROJECT_CATKIN_DEPENDS = "".replace(';', ' ')
PKG_CONFIG_LIBRARIES_WITH_PREFIX = "".split(';') if "" != "" else []
PROJECT_NAME = "turtle_control"
PROJECT_SPACE_DIR = "/home/dennis/catkin_ws/src/turtle_control/devel"
PROJECT_VERSION = "0.0.0"
@@ -0,0 +1,8 @@
# generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "".split(';') if "" != "" else []
PROJECT_CATKIN_DEPENDS = "".replace(';', ' ')
PKG_CONFIG_LIBRARIES_WITH_PREFIX = "".split(';') if "" != "" else []
PROJECT_NAME = "turtle_control"
PROJECT_SPACE_DIR = "/usr/local"
PROJECT_VERSION = "0.0.0"
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env sh
# generated from catkin/python/catkin/environment_cache.py
# based on a snapshot of the environment before and after calling the setup script
# it emulates the modifications of the setup script without recurring computations
# new environment variables
# modified environment variables
export CMAKE_PREFIX_PATH="/home/dennis/catkin_ws/src/turtle_control/devel:$CMAKE_PREFIX_PATH"
export ROSLISP_PACKAGE_DIRECTORIES='/home/dennis/catkin_ws/src/turtle_control/devel/share/common-lisp'
export ROS_PACKAGE_PATH="/home/dennis/catkin_ws/src/turtle_control:$ROS_PACKAGE_PATH"
@@ -0,0 +1,304 @@
#!/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)
@@ -0,0 +1,255 @@
# 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.
from __future__ import print_function
import os
import runpy
import sys
from argparse import ArgumentParser
setup_modules = []
try:
import distutils.core
setup_modules.append(distutils.core)
except ImportError:
pass
try:
import setuptools
setup_modules.append(setuptools)
except ImportError:
pass
assert setup_modules, 'Must have distutils or setuptools installed'
def _get_locations(pkgs, package_dir):
"""
Based on setuptools logic and the package_dir dict, builds a dict of location roots for each pkg in pkgs.
See http://docs.python.org/distutils/setupscript.html
:returns: a dict {pkgname: root} for each pkgname in pkgs (and each of their parents)
"""
# package_dir contains a dict {package_name: relativepath}
# Example {'': 'src', 'foo': 'lib', 'bar': 'lib2'}
#
# '' means where to look for any package unless a parent package
# is listed so package bar.pot is expected at lib2/bar/pot,
# whereas package sup.dee is expected at src/sup/dee
#
# if package_dir does not state anything about a package,
# setuptool expects the package folder to be in the root of the
# project
locations = {}
allprefix = package_dir.get('', '')
for pkg in pkgs:
parent_location = None
splits = pkg.split('.')
# we iterate over compound name from parent to child
# so once we found parent, children just append to their parent
for key_len in range(len(splits)):
key = '.'.join(splits[:key_len + 1])
if key not in locations:
if key in package_dir:
locations[key] = package_dir[key]
elif parent_location is not None:
locations[key] = os.path.join(parent_location, splits[key_len])
else:
locations[key] = os.path.join(allprefix, key)
parent_location = locations[key]
return locations
def generate_cmake_file(package_name, version, scripts, package_dir, pkgs, modules, setup_module=None):
"""
Generate lines to add to a cmake file which will set variables.
:param version: str, format 'int.int.int'
:param scripts: [list of str]: relative paths to scripts
:param package_dir: {modulename: path}
:param pkgs: [list of str] python_packages declared in catkin package
:param modules: [list of str] python modules
:param setup_module: str, setuptools or distutils
"""
prefix = '%s_SETUP_PY' % package_name
result = []
if setup_module:
result.append(r'set(%s_SETUP_MODULE "%s")' % (prefix, setup_module))
result.append(r'set(%s_VERSION "%s")' % (prefix, version))
result.append(r'set(%s_SCRIPTS "%s")' % (prefix, ';'.join(scripts)))
# Remove packages with '.' separators.
#
# setuptools allows specifying submodules in other folders than
# their parent
#
# The symlink approach of catkin does not work with such submodules.
# In the common case, this does not matter as the submodule is
# within the containing module. We verify this assumption, and if
# it passes, we remove submodule packages.
locations = _get_locations(pkgs, package_dir)
for pkgname, location in locations.items():
if '.' not in pkgname:
continue
splits = pkgname.split('.')
# hack: ignore write-combining setup.py files for msg and srv files
if splits[1] in ['msg', 'srv']:
continue
# check every child has the same root folder as its parent
root_name = splits[0]
root_location = location
for _ in range(len(splits) - 1):
root_location = os.path.dirname(root_location)
if root_location != locations[root_name]:
raise RuntimeError(
'catkin_export_python does not support setup.py files that combine across multiple directories: %s in %s, %s in %s' % (pkgname, location, root_name, locations[root_name]))
# If checks pass, remove all submodules
pkgs = [p for p in pkgs if '.' not in p]
resolved_pkgs = []
for pkg in pkgs:
resolved_pkgs += [locations[pkg]]
result.append(r'set(%s_PACKAGES "%s")' % (prefix, ';'.join(pkgs)))
result.append(r'set(%s_PACKAGE_DIRS "%s")' % (prefix, ';'.join(resolved_pkgs).replace('\\', '/')))
# skip modules which collide with package names
filtered_modules = []
for modname in modules:
splits = modname.split('.')
# check all parents too
equals_package = [('.'.join(splits[:-i]) in locations) for i in range(len(splits))]
if any(equals_package):
continue
filtered_modules.append(modname)
module_locations = _get_locations(filtered_modules, package_dir)
result.append(r'set(%s_MODULES "%s")' % (prefix, ';'.join(['%s.py' % m.replace('.', '/') for m in filtered_modules])))
result.append(r'set(%s_MODULE_DIRS "%s")' % (prefix, ';'.join([module_locations[m] for m in filtered_modules]).replace('\\', '/')))
return result
def _create_mock_setup_function(setup_module, package_name, outfile):
"""
Create a function to call instead of distutils.core.setup or setuptools.setup.
It just captures some args and writes them into a file that can be used from cmake.
:param package_name: name of the package
:param outfile: filename that cmake will use afterwards
:returns: a function to replace disutils.core.setup and setuptools.setup
"""
def setup(*args, **kwargs):
"""Check kwargs and write a scriptfile."""
if 'version' not in kwargs:
sys.stderr.write("\n*** Unable to find 'version' in setup.py of %s\n" % package_name)
raise RuntimeError('version not found in setup.py')
version = kwargs['version']
package_dir = kwargs.get('package_dir', {})
pkgs = kwargs.get('packages', [])
scripts = kwargs.get('scripts', [])
modules = kwargs.get('py_modules', [])
unsupported_args = [
'entry_points',
'exclude_package_data',
'ext_modules ',
'ext_package',
'include_package_data',
'namespace_packages',
'setup_requires',
'use_2to3',
'zip_safe']
used_unsupported_args = [arg for arg in unsupported_args if arg in kwargs]
if used_unsupported_args:
sys.stderr.write('*** Arguments %s to setup() not supported in catkin devel space in setup.py of %s\n' % (used_unsupported_args, package_name))
result = generate_cmake_file(package_name=package_name,
version=version,
scripts=scripts,
package_dir=package_dir,
pkgs=pkgs,
modules=modules,
setup_module=setup_module)
with open(outfile, 'w') as out:
out.write('\n'.join(result))
return setup
def main():
"""Script main, parses arguments and invokes Dummy.setup indirectly."""
parser = ArgumentParser(description='Utility to read setup.py values from cmake macros. Creates a file with CMake set commands setting variables.')
parser.add_argument('package_name', help='Name of catkin package')
parser.add_argument('setupfile_path', help='Full path to setup.py')
parser.add_argument('outfile', help='Where to write result to')
args = parser.parse_args()
# print("%s" % sys.argv)
# PACKAGE_NAME = sys.argv[1]
# OUTFILE = sys.argv[3]
# print("Interrogating setup.py for package %s into %s " % (PACKAGE_NAME, OUTFILE),
# file=sys.stderr)
# print("executing %s" % args.setupfile_path)
# be sure you're in the directory containing
# setup.py so the sys.path manipulation works,
# so the import of __version__ works
os.chdir(os.path.dirname(os.path.abspath(args.setupfile_path)))
# patch setup() function of distutils and setuptools for the
# context of evaluating setup.py
backup_modules = {}
try:
for module in setup_modules:
backup_modules[id(module)] = module.setup
module.setup = _create_mock_setup_function(
setup_module=module.__name__, package_name=args.package_name, outfile=args.outfile)
runpy.run_path(args.setupfile_path)
finally:
for module in setup_modules:
module.setup = backup_modules[id(module)]
if __name__ == '__main__':
main()
@@ -0,0 +1,65 @@
<?xml version="1.0"?>
<package format="2">
<name>turtle_control</name>
<version>0.0.0</version>
<description>The turtle_control package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="dennis@todo.todo">dennis</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/turtle_control</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
@@ -0,0 +1,8 @@
prefix=@PROJECT_SPACE_DIR
Name: @(CATKIN_PACKAGE_PREFIX + PROJECT_NAME)
Description: Description of @PROJECT_NAME
Version: @PROJECT_VERSION
Cflags: @(' '.join(['-I%s' % include for include in PROJECT_PKG_CONFIG_INCLUDE_DIRS]))
Libs: -L${prefix}/lib @(' '.join(PKG_CONFIG_LIBRARIES_WITH_PREFIX))
Requires: @(PROJECT_CATKIN_DEPENDS)
+161
View File
@@ -0,0 +1,161 @@
# Install script for directory: /home/dennis/catkin_ws/src/turtle_control
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Install shared libraries without execute permission?
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
set(CMAKE_INSTALL_SO_NO_EXE "1")
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
if (NOT EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}")
file(MAKE_DIRECTORY "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}")
endif()
if (NOT EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/.catkin")
file(WRITE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/.catkin" "")
endif()
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/_setup_util.py")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE PROGRAM FILES "/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/_setup_util.py")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/env.sh")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE PROGRAM FILES "/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/env.sh")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/setup.bash;/usr/local/local_setup.bash")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE FILE FILES
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/setup.bash"
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/local_setup.bash"
)
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/setup.sh;/usr/local/local_setup.sh")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE FILE FILES
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/setup.sh"
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/local_setup.sh"
)
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/setup.zsh;/usr/local/local_setup.zsh")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE FILE FILES
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/setup.zsh"
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/local_setup.zsh"
)
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/.rosinstall")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE FILE FILES "/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/.rosinstall")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" TYPE FILE FILES "/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/turtle_control.pc")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/share/turtle_control/cmake" TYPE FILE FILES
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/turtle_controlConfig.cmake"
"/home/dennis/catkin_ws/src/turtle_control/catkin_generated/installspace/turtle_controlConfig-version.cmake"
)
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/share/turtle_control" TYPE FILE FILES "/home/dennis/catkin_ws/src/turtle_control/package.xml")
endif()
if(NOT CMAKE_INSTALL_LOCAL_ONLY)
# Include the install script for each subdirectory.
include("/home/dennis/catkin_ws/src/turtle_control/gtest/cmake_install.cmake")
endif()
if(CMAKE_INSTALL_COMPONENT)
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
else()
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
endif()
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
"${CMAKE_INSTALL_MANIFEST_FILES}")
file(WRITE "/home/dennis/catkin_ws/src/turtle_control/${CMAKE_INSTALL_MANIFEST}"
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
+1
View File
@@ -0,0 +1 @@
/home/dennis/catkin_ws/src/turtle_control
+2
View File
@@ -0,0 +1,2 @@
- setup-file:
local-name: /home/dennis/catkin_ws/src/turtle_control/devel/setup.sh
+304
View File
@@ -0,0 +1,304 @@
#!/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)
View File
+16
View File
@@ -0,0 +1,16 @@
#!/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 "$@"
+8
View File
@@ -0,0 +1,8 @@
prefix=/home/dennis/catkin_ws/src/turtle_control/devel
Name: turtle_control
Description: Description of turtle_control
Version: 0.0.0
Cflags:
Libs: -L${prefix}/lib
Requires:
+8
View File
@@ -0,0 +1,8 @@
#!/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
+9
View File
@@ -0,0 +1,9 @@
#!/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
+8
View File
@@ -0,0 +1,8 @@
#!/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'
+8
View File
@@ -0,0 +1,8 @@
#!/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"
+96
View File
@@ -0,0 +1,96 @@
#!/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
+8
View File
@@ -0,0 +1,8 @@
#!/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"'
@@ -0,0 +1,14 @@
# generated from catkin/cmake/template/pkgConfig-version.cmake.in
set(PACKAGE_VERSION "0.0.0")
set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)
if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT True)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
if("${PACKAGE_FIND_VERSION}" VERSION_LESS "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
@@ -0,0 +1,223 @@
# generated from catkin/cmake/template/pkgConfig.cmake.in
# append elements to a list and remove existing duplicates from the list
# copied from catkin/cmake/list_append_deduplicate.cmake to keep pkgConfig
# self contained
macro(_list_append_deduplicate listname)
if(NOT "${ARGN}" STREQUAL "")
if(${listname})
list(REMOVE_ITEM ${listname} ${ARGN})
endif()
list(APPEND ${listname} ${ARGN})
endif()
endmacro()
# append elements to a list if they are not already in the list
# copied from catkin/cmake/list_append_unique.cmake to keep pkgConfig
# self contained
macro(_list_append_unique listname)
foreach(_item ${ARGN})
list(FIND ${listname} ${_item} _index)
if(_index EQUAL -1)
list(APPEND ${listname} ${_item})
endif()
endforeach()
endmacro()
# pack a list of libraries with optional build configuration keywords
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
# self contained
macro(_pack_libraries_with_build_configuration VAR)
set(${VAR} "")
set(_argn ${ARGN})
list(LENGTH _argn _count)
set(_index 0)
while(${_index} LESS ${_count})
list(GET _argn ${_index} lib)
if("${lib}" MATCHES "^(debug|optimized|general)$")
math(EXPR _index "${_index} + 1")
if(${_index} EQUAL ${_count})
message(FATAL_ERROR "_pack_libraries_with_build_configuration() the list of libraries '${ARGN}' ends with '${lib}' which is a build configuration keyword and must be followed by a library")
endif()
list(GET _argn ${_index} library)
list(APPEND ${VAR} "${lib}${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}")
else()
list(APPEND ${VAR} "${lib}")
endif()
math(EXPR _index "${_index} + 1")
endwhile()
endmacro()
# unpack a list of libraries with optional build configuration keyword prefixes
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
# self contained
macro(_unpack_libraries_with_build_configuration VAR)
set(${VAR} "")
foreach(lib ${ARGN})
string(REGEX REPLACE "^(debug|optimized|general)${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}(.+)$" "\\1;\\2" lib "${lib}")
list(APPEND ${VAR} "${lib}")
endforeach()
endmacro()
if(turtle_control_CONFIG_INCLUDED)
return()
endif()
set(turtle_control_CONFIG_INCLUDED TRUE)
# set variables for source/devel/install prefixes
if("TRUE" STREQUAL "TRUE")
set(turtle_control_SOURCE_PREFIX /home/dennis/catkin_ws/src/turtle_control)
set(turtle_control_DEVEL_PREFIX /home/dennis/catkin_ws/src/turtle_control/devel)
set(turtle_control_INSTALL_PREFIX "")
set(turtle_control_PREFIX ${turtle_control_DEVEL_PREFIX})
else()
set(turtle_control_SOURCE_PREFIX "")
set(turtle_control_DEVEL_PREFIX "")
set(turtle_control_INSTALL_PREFIX /usr/local)
set(turtle_control_PREFIX ${turtle_control_INSTALL_PREFIX})
endif()
# warn when using a deprecated package
if(NOT "" STREQUAL "")
set(_msg "WARNING: package 'turtle_control' is deprecated")
# append custom deprecation text if available
if(NOT "" STREQUAL "TRUE")
set(_msg "${_msg} ()")
endif()
message("${_msg}")
endif()
# flag project as catkin-based to distinguish if a find_package()-ed project is a catkin project
set(turtle_control_FOUND_CATKIN_PROJECT TRUE)
if(NOT " " STREQUAL " ")
set(turtle_control_INCLUDE_DIRS "")
set(_include_dirs "")
if(NOT " " STREQUAL " ")
set(_report "Check the issue tracker '' and consider creating a ticket if the problem has not been reported yet.")
elseif(NOT " " STREQUAL " ")
set(_report "Check the website '' for information and consider reporting the problem.")
else()
set(_report "Report the problem to the maintainer 'dennis <dennis@todo.todo>' and request to fix the problem.")
endif()
foreach(idir ${_include_dirs})
if(IS_ABSOLUTE ${idir} AND IS_DIRECTORY ${idir})
set(include ${idir})
elseif("${idir} " STREQUAL "include ")
get_filename_component(include "${turtle_control_DIR}/../../../include" ABSOLUTE)
if(NOT IS_DIRECTORY ${include})
message(FATAL_ERROR "Project 'turtle_control' specifies '${idir}' as an include dir, which is not found. It does not exist in '${include}'. ${_report}")
endif()
else()
message(FATAL_ERROR "Project 'turtle_control' specifies '${idir}' as an include dir, which is not found. It does neither exist as an absolute directory nor in '/home/dennis/catkin_ws/src/turtle_control/${idir}'. ${_report}")
endif()
_list_append_unique(turtle_control_INCLUDE_DIRS ${include})
endforeach()
endif()
set(libraries "")
foreach(library ${libraries})
# keep build configuration keywords, target names and absolute libraries as-is
if("${library}" MATCHES "^(debug|optimized|general)$")
list(APPEND turtle_control_LIBRARIES ${library})
elseif(${library} MATCHES "^-l")
list(APPEND turtle_control_LIBRARIES ${library})
elseif(${library} MATCHES "^-")
# This is a linker flag/option (like -pthread)
# There's no standard variable for these, so create an interface library to hold it
if(NOT turtle_control_NUM_DUMMY_TARGETS)
set(turtle_control_NUM_DUMMY_TARGETS 0)
endif()
# Make sure the target name is unique
set(interface_target_name "catkin::turtle_control::wrapped-linker-option${turtle_control_NUM_DUMMY_TARGETS}")
while(TARGET "${interface_target_name}")
math(EXPR turtle_control_NUM_DUMMY_TARGETS "${turtle_control_NUM_DUMMY_TARGETS}+1")
set(interface_target_name "catkin::turtle_control::wrapped-linker-option${turtle_control_NUM_DUMMY_TARGETS}")
endwhile()
add_library("${interface_target_name}" INTERFACE IMPORTED)
if("${CMAKE_VERSION}" VERSION_LESS "3.13.0")
set_property(
TARGET
"${interface_target_name}"
APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "${library}")
else()
target_link_options("${interface_target_name}" INTERFACE "${library}")
endif()
list(APPEND turtle_control_LIBRARIES "${interface_target_name}")
elseif(TARGET ${library})
list(APPEND turtle_control_LIBRARIES ${library})
elseif(IS_ABSOLUTE ${library})
list(APPEND turtle_control_LIBRARIES ${library})
else()
set(lib_path "")
set(lib "${library}-NOTFOUND")
# since the path where the library is found is returned we have to iterate over the paths manually
foreach(path /home/dennis/catkin_ws/src/turtle_control/devel/lib;/opt/ros/noetic/lib)
find_library(lib ${library}
PATHS ${path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
if(lib)
set(lib_path ${path})
break()
endif()
endforeach()
if(lib)
_list_append_unique(turtle_control_LIBRARY_DIRS ${lib_path})
list(APPEND turtle_control_LIBRARIES ${lib})
else()
# as a fall back for non-catkin libraries try to search globally
find_library(lib ${library})
if(NOT lib)
message(FATAL_ERROR "Project '${PROJECT_NAME}' tried to find library '${library}'. The library is neither a target nor built/installed properly. Did you compile project 'turtle_control'? Did you find_package() it before the subdirectory containing its code is included?")
endif()
list(APPEND turtle_control_LIBRARIES ${lib})
endif()
endif()
endforeach()
set(turtle_control_EXPORTED_TARGETS "")
# create dummy targets for exported code generation targets to make life of users easier
foreach(t ${turtle_control_EXPORTED_TARGETS})
if(NOT TARGET ${t})
add_custom_target(${t})
endif()
endforeach()
set(depends "")
foreach(depend ${depends})
string(REPLACE " " ";" depend_list ${depend})
# the package name of the dependency must be kept in a unique variable so that it is not overwritten in recursive calls
list(GET depend_list 0 turtle_control_dep)
list(LENGTH depend_list count)
if(${count} EQUAL 1)
# simple dependencies must only be find_package()-ed once
if(NOT ${turtle_control_dep}_FOUND)
find_package(${turtle_control_dep} REQUIRED NO_MODULE)
endif()
else()
# dependencies with components must be find_package()-ed again
list(REMOVE_AT depend_list 0)
find_package(${turtle_control_dep} REQUIRED NO_MODULE ${depend_list})
endif()
_list_append_unique(turtle_control_INCLUDE_DIRS ${${turtle_control_dep}_INCLUDE_DIRS})
# merge build configuration keywords with library names to correctly deduplicate
_pack_libraries_with_build_configuration(turtle_control_LIBRARIES ${turtle_control_LIBRARIES})
_pack_libraries_with_build_configuration(_libraries ${${turtle_control_dep}_LIBRARIES})
_list_append_deduplicate(turtle_control_LIBRARIES ${_libraries})
# undo build configuration keyword merging after deduplication
_unpack_libraries_with_build_configuration(turtle_control_LIBRARIES ${turtle_control_LIBRARIES})
_list_append_unique(turtle_control_LIBRARY_DIRS ${${turtle_control_dep}_LIBRARY_DIRS})
_list_append_deduplicate(turtle_control_EXPORTED_TARGETS ${${turtle_control_dep}_EXPORTED_TARGETS})
endforeach()
set(pkg_cfg_extras "")
foreach(extra ${pkg_cfg_extras})
if(NOT IS_ABSOLUTE ${extra})
set(extra ${turtle_control_DIR}/${extra})
endif()
include(${extra})
endforeach()

Some files were not shown because too many files have changed in this diff Show More