├── CMakeLists.txt ├── README.md ├── object_tracker ├── src │ ├── listener.cpp │ ├── test_image.cpp │ ├── talker.cpp │ ├── pcl_tutorial.cpp │ └── Tracker_object.cpp ├── scripts │ ├── talker.py │ ├── listener.py │ └── ros_cv_wrapper.py ├── package.xml~ ├── package.xml ├── CMakeLists.txt └── CMakeLists.txt~ └── project_1 ├── scripts ├── talker.py ├── listener.py └── ros_cv_wrapper.py ├── package.xml~ ├── package.xml ├── src ├── Tracker_object.cpp ├── test_image.cpp └── Tracker_object2.cpp ├── CMakeLists.txt~ └── CMakeLists.txt /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | /opt/ros/indigo/share/catkin/cmake/toplevel.cmake -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pcl_object_tracking 2 | Color based segmentation and point cloud extraction.(Current configurations are for tracking orange coloured objects, the colour can be varied by changing the hsv constraints) 3 | 4 | The built source files are located in Project_1 folder. Go through the following steps in order to run the executables. 5 | 6 | i. Copy the folder Project_1 to the catkin workspace/src folder. 7 | 8 | ii. Build the project by using catkin_make command. 9 | 10 | iii. Run either FreeNect_Launch or OpenNI_Launch, in order to access the point cloud and rectified rgb image topics from Microsoft Kinect. 11 | 12 | iv. Launch either of the above in a terminal. 13 | 14 | v. Run the "test_image" program and note the specific HSV values required to detect the object, and close after visualizing effective results. 15 | 16 | vi. Change the HSV values in the Project_1/src/Tracker_object2.cpp file. 17 | 18 | v. Run "Tracker_object2". The point cloud of the object can be visualized in rviz by choosing the topic "pointcloud/object". 19 | -------------------------------------------------------------------------------- /object_tracker/src/listener.cpp: -------------------------------------------------------------------------------- 1 | #include "ros/ros.h" 2 | #include "std_msgs/String.h" 3 | 4 | /** 5 | * This tutorial demonstrates simple receipt of messages over the ROS system. 6 | */ 7 | void chatterCallback(const std_msgs::String::ConstPtr& msg) 8 | { 9 | ROS_INFO("I heard: [%s]", msg->data.c_str()); 10 | } 11 | 12 | int main(int argc, char **argv) 13 | { 14 | 15 | ros::init(argc, argv, "listener"); 16 | 17 | /** 18 | * NodeHandle is the main access point to communications with the ROS system. 19 | * The first NodeHandle constructed will fully initialize this node, and the last 20 | * NodeHandle destructed will close down the node. 21 | */ 22 | ros::NodeHandle n; 23 | 24 | ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback); 25 | 26 | /** 27 | * ros::spin() will enter a loop, pumping callbacks. With this version, all 28 | * callbacks will be called from within this thread (the main one). ros::spin() 29 | * will exit when Ctrl-C is pressed, or the node is shutdown by the master. 30 | */ 31 | ros::spin(); 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /object_tracker/src/test_image.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // PCL specific includes 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //openCV includes 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | void image_callback(const sensor_msgs::ImageConstPtr& img_ptr) 19 | { 20 | cv::Mat cv_image; 21 | cv_bridge::CvImagePtr cv_ptr; 22 | cv_ptr = cv_bridge::toCvCopy(img_ptr); 23 | cv_image=cv_ptr->image; 24 | 25 | cv::imshow("WINDOW",cv_image); 26 | cv::waitKey(5); 27 | 28 | } 29 | 30 | int main(int argc, char** argv) 31 | { 32 | ros::init(argc, argv, "test"); 33 | ros::NodeHandle nh; 34 | ros::Subscriber sub_2; 35 | cv::namedWindow("WINDOW", CV_WINDOW_AUTOSIZE); 36 | sub_2=nh.subscribe("image_mask", 1,image_callback); 37 | 38 | ros::spin(); 39 | } -------------------------------------------------------------------------------- /object_tracker/src/talker.cpp: -------------------------------------------------------------------------------- 1 | #include "ros/ros.h" 2 | #include "std_msgs/String.h" 3 | 4 | #include 5 | 6 | 7 | int main(int argc, char **argv) 8 | { 9 | 10 | ros::init(argc, argv, "talker"); 11 | 12 | /** 13 | * NodeHandle is the main access point to communications with the ROS system. 14 | * The first NodeHandle constructed will fully initialize this node, and the last 15 | * NodeHandle destructed will close down the node. 16 | */ 17 | ros::NodeHandle n; 18 | 19 | ros::Publisher chatter_pub = n.advertise("chatter", 1000); 20 | 21 | ros::Rate loop_rate(10); 22 | 23 | /** 24 | * A count of how many messages we have sent. This is used to create 25 | * a unique string for each message. 26 | */ 27 | int count = 0; 28 | while (ros::ok()) 29 | { 30 | /** 31 | * This is a message object. You stuff it with data, and then publish it. 32 | */ 33 | std_msgs::String msg; 34 | 35 | std::stringstream ss; 36 | ss << "hello world " << count; 37 | msg.data = ss.str(); 38 | 39 | ROS_INFO("%s", msg.data.c_str()); 40 | 41 | /** 42 | * The publish() function is how you send messages. The parameter 43 | * is the message object. The type of this object must agree with the type 44 | * given as a template parameter to the advertise<>() call, as was done 45 | * in the constructor above. 46 | */ 47 | chatter_pub.publish(msg); 48 | 49 | ros::spinOnce(); 50 | 51 | loop_rate.sleep(); 52 | ++count; 53 | } 54 | 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /object_tracker/src/pcl_tutorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // PCL specific includes 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //openCV includes 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | 18 | ros::Publisher pub; 19 | 20 | void cloud_cb(const pcl::PCLPointCloud2ConstPtr& input) 21 | { 22 | 23 | pcl::PointCloud cloud_xyz; // Convert PCL to XYZ data type 24 | pcl::fromPCLPointCloud2(*input, cloud_xyz); 25 | int size=cloud_xyz.points.size(); 26 | ROS_INFO("Size of Cloud: %d",size); 27 | 28 | pcl::PointCloud mask_xyz; 29 | mask_xyz.height=480; 30 | mask_xyz.width=640; 31 | 32 | 33 | 34 | pcl::PCLPointCloud2 cloud_filtered; // Using Voxelgrid filtering to sample down point cloud // point cloud 35 | pcl::VoxelGrid sor; 36 | sor.setInputCloud (input); 37 | sor.setLeafSize (0.05, 0.05, 0.05); 38 | sor.filter (cloud_filtered); 39 | // Publish the dataSize 40 | pub.publish (cloud_filtered); 41 | } 42 | 43 | 44 | 45 | 46 | int main (int argc, char** argv) 47 | { 48 | // Initialize ROS 49 | ros::init (argc, argv, "my_pcl_tutorial"); 50 | ros::NodeHandle nh; 51 | // Create ROS publisher for publishing the point cloud 52 | // Create a ROS subscriber for the input point cloud 53 | ros::Subscriber sub = nh.subscribe ("camera/depth/points", 1, cloud_cb); 54 | // Create a ROS publisher for the output point cloud 55 | pub = nh.advertise ("output", 1); 56 | // Spin 57 | ros::spin (); 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /project_1/scripts/talker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Software License Agreement (BSD License) 3 | # 4 | # Copyright (c) 2008, Willow Garage, Inc. 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following 15 | # disclaimer in the documentation and/or other materials provided 16 | # with the distribution. 17 | # * Neither the name of Willow Garage, Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived 19 | # from this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | # POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | # Revision $Id$ 35 | 36 | ## Simple talker demo that published std_msgs/Strings messages 37 | ## to the 'chatter' topic 38 | 39 | import rospy 40 | from std_msgs.msg import String 41 | 42 | def talker(): 43 | pub = rospy.Publisher('chatter', String, queue_size=10) 44 | rospy.init_node('talker', anonymous=True) 45 | rate = rospy.Rate(10) # 10hz 46 | while not rospy.is_shutdown(): 47 | hello_str = "hello world %s" % rospy.get_time() 48 | rospy.loginfo(hello_str) 49 | pub.publish(hello_str) 50 | rate.sleep() 51 | 52 | if __name__ == '__main__': 53 | try: 54 | talker() 55 | except rospy.ROSInterruptException: 56 | pass 57 | -------------------------------------------------------------------------------- /object_tracker/scripts/talker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Software License Agreement (BSD License) 3 | # 4 | # Copyright (c) 2008, Willow Garage, Inc. 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following 15 | # disclaimer in the documentation and/or other materials provided 16 | # with the distribution. 17 | # * Neither the name of Willow Garage, Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived 19 | # from this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | # POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | # Revision $Id$ 35 | 36 | ## Simple talker demo that published std_msgs/Strings messages 37 | ## to the 'chatter' topic 38 | 39 | import rospy 40 | from std_msgs.msg import String 41 | 42 | def talker(): 43 | pub = rospy.Publisher('chatter', String, queue_size=10) 44 | rospy.init_node('talker', anonymous=True) 45 | rate = rospy.Rate(10) # 10hz 46 | while not rospy.is_shutdown(): 47 | hello_str = "hello world %s" % rospy.get_time() 48 | rospy.loginfo(hello_str) 49 | pub.publish(hello_str) 50 | rate.sleep() 51 | 52 | if __name__ == '__main__': 53 | try: 54 | talker() 55 | except rospy.ROSInterruptException: 56 | pass 57 | -------------------------------------------------------------------------------- /project_1/scripts/listener.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Software License Agreement (BSD License) 3 | # 4 | # Copyright (c) 2008, Willow Garage, Inc. 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following 15 | # disclaimer in the documentation and/or other materials provided 16 | # with the distribution. 17 | # * Neither the name of Willow Garage, Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived 19 | # from this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | # POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | # Revision $Id$ 35 | 36 | ## Simple talker demo that listens to std_msgs/Strings published 37 | ## to the 'chatter' topic 38 | 39 | import rospy 40 | from std_msgs.msg import String 41 | 42 | def callback(data): 43 | rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data) 44 | 45 | def listener(): 46 | 47 | # In ROS, nodes are uniquely named. If two nodes with the same 48 | # node are launched, the previous one is kicked off. The 49 | # anonymous=True flag means that rospy will choose a unique 50 | # name for our 'talker' node so that multiple talkers can 51 | # run simultaneously. 52 | rospy.init_node('listener', anonymous=True) 53 | 54 | rospy.Subscriber("chatter", String, callback) 55 | 56 | # spin() simply keeps python from exiting until this node is stopped 57 | rospy.spin() 58 | 59 | if __name__ == '__main__': 60 | listener() 61 | -------------------------------------------------------------------------------- /object_tracker/scripts/listener.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Software License Agreement (BSD License) 3 | # 4 | # Copyright (c) 2008, Willow Garage, Inc. 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following 15 | # disclaimer in the documentation and/or other materials provided 16 | # with the distribution. 17 | # * Neither the name of Willow Garage, Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived 19 | # from this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | # POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | # Revision $Id$ 35 | 36 | ## Simple talker demo that listens to std_msgs/Strings published 37 | ## to the 'chatter' topic 38 | 39 | import rospy 40 | from std_msgs.msg import String 41 | 42 | def callback(data): 43 | rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data) 44 | 45 | def listener(): 46 | 47 | # In ROS, nodes are uniquely named. If two nodes with the same 48 | # node are launched, the previous one is kicked off. The 49 | # anonymous=True flag means that rospy will choose a unique 50 | # name for our 'talker' node so that multiple talkers can 51 | # run simultaneously. 52 | rospy.init_node('listener', anonymous=True) 53 | 54 | rospy.Subscriber("chatter", String, callback) 55 | 56 | # spin() simply keeps python from exiting until this node is stopped 57 | rospy.spin() 58 | 59 | if __name__ == '__main__': 60 | listener() 61 | -------------------------------------------------------------------------------- /project_1/scripts/ros_cv_wrapper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import rospy 3 | import sys 4 | import cv2 5 | import cv2.cv as cv 6 | from sensor_msgs.msg import Image, CameraInfo 7 | from cv_bridge import CvBridge, CvBridgeError 8 | import numpy as np 9 | 10 | class cvBridgeDemo(): 11 | 12 | def __init__(self): 13 | self.node_name = "cv_bridge_demo" 14 | #Initialize the ros node 15 | rospy.init_node(self.node_name) 16 | # What we do during shutdown 17 | # Create the OpenCV display window for the RGB image 18 | self.cv_window_name = self.node_name 19 | cv.NamedWindow(self.cv_window_name, cv.CV_WINDOW_NORMAL) 20 | cv.MoveWindow(self.cv_window_name, 25, 75) 21 | # Create the cv_bridge object 22 | self.bridge = CvBridge() 23 | # Subscribe to the camera image and depth topics and set 24 | # the appropriate callbacks 25 | self.image_sub = rospy.Subscriber("/camera/rgb/image_rect_color", Image, self.image_callback) 26 | self.image_pub = rospy.Publisher("image_mask", Image) 27 | rospy.loginfo("Waiting for image topics...") 28 | 29 | 30 | def image_callback(self, ros_image): 31 | 32 | try: 33 | frame = self.bridge.imgmsg_to_cv2(ros_image, "bgr8") 34 | except CvBridgeError, e: 35 | print e 36 | # require Numpy arrays. 37 | frame = np.array(frame, dtype=np.uint8) 38 | display_image = self.process_image(frame) 39 | # Display the image. 40 | cv2.imshow(self.node_name, display_image) 41 | # Process any keyboard commands 42 | self.keystroke = cv.WaitKey(5) 43 | if 32 <= self.keystroke and self.keystroke < 128: 44 | cc = chr(self.keystroke).lower() 45 | if cc == 'q': 46 | # The user has press the q key, so exit 47 | rospy.signal_shutdown("User hit q key to quit.") 48 | 49 | def process_image(self, frame): 50 | 51 | # hsv color segmentation 52 | imghsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 53 | lower_blue=np.array([112,122,89]) 54 | higher_blue=np.array([132,255,255]) 55 | mask=cv2.inRange(imghsv,lower_blue,higher_blue) 56 | 57 | # morphological filtering noise removal 58 | kernel = np.ones((5,5),np.uint8) 59 | opening = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel) 60 | try: 61 | opening_1 = self.bridge.cv2_to_imgmsg(opening, "8UC1") 62 | except CvBridgeError, e: 63 | print e 64 | self.image_pub.publish(opening_1) 65 | return opening 66 | 67 | 68 | def main(args): 69 | try: 70 | cvBridgeDemo() 71 | rospy.spin() 72 | except KeyboardInterrupt: 73 | print "Shutting down vision node." 74 | cv.DestroyAllWindows() 75 | 76 | 77 | if __name__ == '__main__': 78 | main(sys.argv) -------------------------------------------------------------------------------- /object_tracker/scripts/ros_cv_wrapper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import rospy 3 | import sys 4 | import cv2 5 | import cv2.cv as cv 6 | from sensor_msgs.msg import Image, CameraInfo 7 | from cv_bridge import CvBridge, CvBridgeError 8 | import numpy as np 9 | 10 | class cvBridgeDemo(): 11 | 12 | def __init__(self): 13 | self.node_name = "cv_bridge_demo" 14 | #Initialize the ros node 15 | rospy.init_node(self.node_name) 16 | # What we do during shutdown 17 | # Create the OpenCV display window for the RGB image 18 | self.cv_window_name = self.node_name 19 | cv.NamedWindow(self.cv_window_name, cv.CV_WINDOW_NORMAL) 20 | cv.MoveWindow(self.cv_window_name, 25, 75) 21 | # Create the cv_bridge object 22 | self.bridge = CvBridge() 23 | # Subscribe to the camera image and depth topics and set 24 | # the appropriate callbacks 25 | self.image_sub = rospy.Subscriber("/camera/rgb/image_rect_color", Image, self.image_callback) 26 | self.image_pub = rospy.Publisher("image_mask", Image) 27 | rospy.loginfo("Waiting for image topics...") 28 | 29 | 30 | def image_callback(self, ros_image): 31 | 32 | try: 33 | frame = self.bridge.imgmsg_to_cv2(ros_image, "bgr8") 34 | except CvBridgeError, e: 35 | print e 36 | # require Numpy arrays. 37 | frame = np.array(frame, dtype=np.uint8) 38 | display_image = self.process_image(frame) 39 | # Display the image. 40 | cv2.imshow(self.node_name, display_image) 41 | # Process any keyboard commands 42 | self.keystroke = cv.WaitKey(5) 43 | if 32 <= self.keystroke and self.keystroke < 128: 44 | cc = chr(self.keystroke).lower() 45 | if cc == 'q': 46 | # The user has press the q key, so exit 47 | rospy.signal_shutdown("User hit q key to quit.") 48 | 49 | def process_image(self, frame): 50 | 51 | # hsv color segmentation 52 | imghsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 53 | lower_blue=np.array([112,122,89]) 54 | higher_blue=np.array([132,255,255]) 55 | mask=cv2.inRange(imghsv,lower_blue,higher_blue) 56 | 57 | # morphological filtering noise removal 58 | kernel = np.ones((5,5),np.uint8) 59 | opening = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel) 60 | try: 61 | opening_1 = self.bridge.cv2_to_imgmsg(opening, "8UC1") 62 | except CvBridgeError, e: 63 | print e 64 | self.image_pub.publish(opening_1) 65 | return opening 66 | 67 | 68 | def main(args): 69 | try: 70 | cvBridgeDemo() 71 | rospy.spin() 72 | except KeyboardInterrupt: 73 | print "Shutting down vision node." 74 | cv.DestroyAllWindows() 75 | 76 | 77 | if __name__ == '__main__': 78 | main(sys.argv) -------------------------------------------------------------------------------- /project_1/package.xml~: -------------------------------------------------------------------------------- 1 | 2 | 3 | project_1 4 | 0.0.0 5 | The project_1 package 6 | 7 | 8 | 9 | 10 | ros-amar 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | catkin 43 | 44 | 45 | 46 | 47 | roscpp 48 | rospy 49 | sensor_msgs 50 | std_msgs 51 | 52 | pcl_ros 53 | pcl_conversions 54 | libpcl-all-dev 55 | 56 | 57 | roscpp 58 | rospy 59 | sensor_msgs 60 | std_msgs 61 | 62 | pcl_ros 63 | pcl_conversions 64 | libpcl-all-dev 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /object_tracker/package.xml~: -------------------------------------------------------------------------------- 1 | 2 | 3 | project_1 4 | 0.0.0 5 | The project_1 package 6 | 7 | 8 | 9 | 10 | ros-amar 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | catkin 43 | 44 | 45 | 46 | 47 | roscpp 48 | rospy 49 | sensor_msgs 50 | std_msgs 51 | 52 | pcl_ros 53 | pcl_conversions 54 | libpcl-all-dev 55 | 56 | 57 | roscpp 58 | rospy 59 | sensor_msgs 60 | std_msgs 61 | 62 | pcl_ros 63 | pcl_conversions 64 | libpcl-all-dev 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /project_1/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | project_1 4 | 0.0.0 5 | The project_1 package 6 | 7 | 8 | 9 | 10 | ros-amar 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | catkin 43 | 44 | 45 | 46 | 47 | roscpp 48 | rospy 49 | sensor_msgs 50 | std_msgs 51 | 52 | pcl_ros 53 | pcl_conversions 54 | libpcl-all-dev 55 | opencv2 56 | 57 | 58 | roscpp 59 | rospy 60 | sensor_msgs 61 | std_msgs 62 | 63 | pcl_ros 64 | pcl_conversions 65 | libpcl-all-dev 66 | opencv2 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /object_tracker/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | project_1 4 | 0.0.0 5 | The project_1 package 6 | 7 | 8 | 9 | 10 | ros-amar 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | catkin 43 | 44 | 45 | 46 | 47 | roscpp 48 | rospy 49 | sensor_msgs 50 | std_msgs 51 | 52 | pcl_ros 53 | pcl_conversions 54 | libpcl-all-dev 55 | opencv2 56 | 57 | 58 | roscpp 59 | rospy 60 | sensor_msgs 61 | std_msgs 62 | 63 | pcl_ros 64 | pcl_conversions 65 | libpcl-all-dev 66 | opencv2 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /project_1/src/Tracker_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // PCL specific includes 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //openCV includes 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | class Object_track 20 | { 21 | cv::Mat cv_image; 22 | pcl::PCLPointCloud2 pcl_pointcloud; 23 | ros::NodeHandle nh; 24 | ros::Publisher pub_1; 25 | ros::Subscriber sub_1; 26 | ros::Subscriber sub_2; 27 | 28 | 29 | public: 30 | 31 | Object_track(); 32 | 33 | private: 34 | 35 | void pointcloud_callback(const pcl::PCLPointCloud2ConstPtr& pcl_ptr); 36 | void image_callback(const sensor_msgs::ImageConstPtr& img_ptr); 37 | 38 | }; 39 | 40 | Object_track::Object_track() 41 | { 42 | pub_1=nh.advertise("pointcloud/object", 1); 43 | sub_1=nh.subscribe("camera/depth/points", 1, &Object_track::pointcloud_callback,this); 44 | sub_2=nh.subscribe("image_mask", 1, &Object_track::image_callback,this); 45 | 46 | } 47 | 48 | void Object_track::image_callback(const sensor_msgs::ImageConstPtr& img_ptr) 49 | { 50 | cv_bridge::CvImagePtr cv_ptr; 51 | cv_ptr = cv_bridge::toCvCopy(img_ptr); 52 | cv_image=cv_ptr->image; 53 | 54 | } 55 | 56 | void Object_track::pointcloud_callback(const pcl::PCLPointCloud2ConstPtr& pcl_ptr) 57 | { 58 | 59 | pcl::PointCloud cloud_xyz; // Convert PCL to XYZ data type 60 | pcl::fromPCLPointCloud2(*pcl_ptr, cloud_xyz); 61 | pcl::PointCloud cloud_new; 62 | cloud_new.width=cloud_xyz.width; 63 | cloud_new.height=cloud_xyz.height; 64 | cloud_new.points.resize(cloud_new.width*cloud_new.height); 65 | int count=0; 66 | for(int j=0;j(j,i)==255 ) 72 | { 73 | cloud_new.points[count].x=cloud_xyz.points[count].x; 74 | cloud_new.points[count].y=cloud_xyz.points[count].y; 75 | cloud_new.points[count].z=cloud_xyz.points[count].z; 76 | ROS_INFO("Data assigned: %G", cloud_new.points[count].z ); 77 | 78 | } 79 | count++; 80 | } 81 | } 82 | pcl::toPCLPointCloud2(cloud_new, pcl_pointcloud); 83 | pcl_pointcloud.header.frame_id=pcl_ptr->header.frame_id; 84 | pcl_pointcloud.header.stamp=pcl_ptr->header.stamp; 85 | 86 | pub_1.publish(pcl_pointcloud); 87 | 88 | } 89 | 90 | int main(int argc, char** argv) 91 | { 92 | ros::init(argc, argv, "Object_track"); 93 | 94 | Object_track tracker; 95 | 96 | ros::spin(); 97 | } -------------------------------------------------------------------------------- /object_tracker/src/Tracker_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // PCL specific includes 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //openCV includes 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | class Object_track 20 | { 21 | cv::Mat cv_image; 22 | pcl::PCLPointCloud2 pcl_pointcloud; 23 | ros::NodeHandle nh; 24 | ros::Publisher pub_1; 25 | ros::Subscriber sub_1; 26 | ros::Subscriber sub_2; 27 | 28 | 29 | public: 30 | 31 | Object_track(); 32 | 33 | private: 34 | 35 | void pointcloud_callback(const pcl::PCLPointCloud2ConstPtr& pcl_ptr); 36 | void image_callback(const sensor_msgs::ImageConstPtr& img_ptr); 37 | 38 | }; 39 | 40 | Object_track::Object_track() 41 | { 42 | pub_1=nh.advertise("pointcloud/object", 1); 43 | sub_1=nh.subscribe("camera/depth/points", 1, &Object_track::pointcloud_callback,this); 44 | sub_2=nh.subscribe("image_mask", 1, &Object_track::image_callback,this); 45 | 46 | } 47 | 48 | void Object_track::image_callback(const sensor_msgs::ImageConstPtr& img_ptr) 49 | { 50 | cv_bridge::CvImagePtr cv_ptr; 51 | cv_ptr = cv_bridge::toCvCopy(img_ptr); 52 | cv_image=cv_ptr->image; 53 | 54 | } 55 | 56 | void Object_track::pointcloud_callback(const pcl::PCLPointCloud2ConstPtr& pcl_ptr) 57 | { 58 | 59 | pcl::PointCloud cloud_xyz; // Convert PCL to XYZ data type 60 | pcl::fromPCLPointCloud2(*pcl_ptr, cloud_xyz); 61 | pcl::PointCloud cloud_new; 62 | cloud_new.width=cloud_xyz.width; 63 | cloud_new.height=cloud_xyz.height; 64 | cloud_new.points.resize(cloud_new.width*cloud_new.height); 65 | int count=0; 66 | for(int j=0;j(j,i)==255 ) 72 | { 73 | cloud_new.points[count].x=cloud_xyz.points[count].x; 74 | cloud_new.points[count].y=cloud_xyz.points[count].y; 75 | cloud_new.points[count].z=cloud_xyz.points[count].z; 76 | ROS_INFO("Data assigned: %G", cloud_new.points[count].z ); 77 | 78 | } 79 | count++; 80 | } 81 | } 82 | pcl::toPCLPointCloud2(cloud_new, pcl_pointcloud); 83 | pcl_pointcloud.header.frame_id=pcl_ptr->header.frame_id; 84 | pcl_pointcloud.header.stamp=pcl_ptr->header.stamp; 85 | 86 | pub_1.publish(pcl_pointcloud); 87 | 88 | } 89 | 90 | int main(int argc, char** argv) 91 | { 92 | ros::init(argc, argv, "Object_track"); 93 | 94 | Object_track tracker; 95 | 96 | ros::spin(); 97 | } -------------------------------------------------------------------------------- /project_1/src/test_image.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // PCL specific includes 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //openCV includes 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | class HSV_tracker 19 | { 20 | public: 21 | int* HSV; 22 | ros::NodeHandle nh; 23 | ros::Subscriber sub_2; 24 | 25 | public: 26 | HSV_tracker(int* x) 27 | { 28 | HSV=x; 29 | sub_2=nh.subscribe("/camera/rgb/image_rect_color", 1, &HSV_tracker::image_callback,this); 30 | } 31 | private: 32 | void image_callback(const sensor_msgs::ImageConstPtr& img_ptr); 33 | 34 | }; 35 | 36 | void HSV_tracker::image_callback(const sensor_msgs::ImageConstPtr& img_ptr) 37 | { 38 | cv::Mat cv_image; 39 | cv_bridge::CvImagePtr cv_ptr; 40 | cv_ptr = cv_bridge::toCvCopy(img_ptr); 41 | cv_image=cv_ptr->image; 42 | cv::Mat imgHSV; 43 | 44 | cv::cvtColor(cv_image, imgHSV, cv::COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV 45 | 46 | cv::Mat imgThresholded; 47 | 48 | int iLowH=cvGetTrackbarPos("LowH","Control"); 49 | int iHighH=cvGetTrackbarPos("HighH","Control"); 50 | int iLowS=cvGetTrackbarPos("LowS","Control"); 51 | int iHighS=cvGetTrackbarPos("HighS","Control"); 52 | int iLowV=cvGetTrackbarPos("LowV","Control"); 53 | int iHighV=cvGetTrackbarPos("HighV","Control"); 54 | 55 | 56 | cv::inRange(imgHSV, cv::Scalar(iLowH, iLowS, iLowV), cv::Scalar(iHighH, iHighS, iHighV), imgThresholded); //Threshold the image 57 | 58 | //morphological opening (remove small objects from the foreground) 59 | cv::erode(imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3)) ); 60 | cv::dilate( imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3)) ); 61 | 62 | //morphological closing (fill small holes in the foreground) 63 | cv::dilate( imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(20, 20)) ); 64 | cv::erode(imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(20, 20)) ); 65 | 66 | 67 | cv::imshow("WINDOW",imgThresholded); 68 | cv::waitKey(5); 69 | 70 | } 71 | 72 | 73 | int main(int argc, char** argv) 74 | { 75 | ros::init(argc, argv, "test"); 76 | 77 | cv::namedWindow("WINDOW", CV_WINDOW_AUTOSIZE); 78 | cv::namedWindow("Control", CV_WINDOW_AUTOSIZE); 79 | int iLowH =0; 80 | int iHighH=20; 81 | 82 | int iLowS =0; 83 | int iHighS=255; 84 | 85 | int iLowV =0; 86 | int iHighV=255; 87 | 88 | //Create trackbars in "Control" window 89 | cvCreateTrackbar("LowH", "Control", &iLowH, 179); //Hue (0 - 179) 90 | cvCreateTrackbar("HighH", "Control", &iHighH, 179); 91 | 92 | cvCreateTrackbar("LowS", "Control", &iLowS, 255); //Saturation (0 - 255) 93 | cvCreateTrackbar("HighS", "Control", &iHighS, 255); 94 | 95 | cvCreateTrackbar("LowV", "Control", &iLowV, 255); //Value (0 - 255) 96 | cvCreateTrackbar("HighV", "Control", &iHighV, 255); 97 | 98 | int HSV[6]; 99 | HSV[0]=iLowH; 100 | HSV[1]=iHighH; 101 | HSV[2]=iLowS; 102 | HSV[3]=iHighS; 103 | HSV[4]=iLowV; 104 | HSV[5]=iHighV; 105 | 106 | HSV_tracker tracker(HSV); 107 | 108 | 109 | 110 | ros::spin(); 111 | } -------------------------------------------------------------------------------- /project_1/src/Tracker_object2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // PCL specific includes 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //openCV includes 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | class Object_track 20 | { 21 | cv::Mat cv_image; 22 | pcl::PCLPointCloud2 pcl_pointcloud; 23 | ros::NodeHandle nh; 24 | ros::Publisher pub_1; 25 | ros::Subscriber sub_1; 26 | ros::Subscriber sub_2; 27 | 28 | 29 | public: 30 | 31 | Object_track(); 32 | 33 | private: 34 | 35 | void pointcloud_callback(const pcl::PCLPointCloud2ConstPtr& pcl_ptr); 36 | void image_callback(const sensor_msgs::ImageConstPtr& img_ptr); 37 | 38 | }; 39 | 40 | Object_track::Object_track() 41 | { 42 | pub_1=nh.advertise("pointcloud/object", 1); 43 | sub_1=nh.subscribe("camera/depth/points", 1, &Object_track::pointcloud_callback,this); 44 | sub_2=nh.subscribe("/camera/rgb/image_rect_color", 1, &Object_track::image_callback,this); 45 | 46 | } 47 | 48 | void Object_track::image_callback(const sensor_msgs::ImageConstPtr& img_ptr) 49 | { 50 | cv::Mat imgRGB; 51 | cv_bridge::CvImagePtr cv_ptr; 52 | cv_ptr = cv_bridge::toCvCopy(img_ptr); 53 | imgRGB=cv_ptr->image; 54 | cv::Mat imgHSV; 55 | 56 | cv::cvtColor(imgRGB, imgHSV, cv::COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV 57 | 58 | cv::Mat imgThresholded; 59 | 60 | // HSV Values set for orange colored object 61 | int iLowH=0 ; 62 | int iHighH=20; 63 | int iLowS=154; 64 | int iHighS=255; 65 | int iLowV=145; 66 | int iHighV=255; 67 | 68 | 69 | cv::inRange(imgHSV, cv::Scalar(iLowH, iLowS, iLowV), cv::Scalar(iHighH, iHighS, iHighV), imgThresholded); //Threshold the image 70 | 71 | //morphological opening (remove small objects from the foreground) 72 | cv::erode(imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3)) ); 73 | cv::dilate( imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3)) ); 74 | 75 | //morphological closing (fill small holes in the foreground) 76 | cv::dilate( imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(20, 20)) ); 77 | cv::erode(imgThresholded, imgThresholded, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(20, 20)) ); 78 | 79 | cv_image=imgThresholded; 80 | 81 | } 82 | 83 | void Object_track::pointcloud_callback(const pcl::PCLPointCloud2ConstPtr& pcl_ptr) 84 | { 85 | 86 | pcl::PointCloud cloud_xyz; // Convert PCL to XYZ data type 87 | pcl::fromPCLPointCloud2(*pcl_ptr, cloud_xyz); 88 | pcl::PointCloud cloud_new; 89 | cloud_new.width=cloud_xyz.width; 90 | cloud_new.height=cloud_xyz.height; 91 | cloud_new.points.resize(cloud_new.width*cloud_new.height); 92 | int count=0; 93 | for(int j=0;j(j,i)==255 ) 99 | { 100 | cloud_new.points[count].x=cloud_xyz.points[count].x; 101 | cloud_new.points[count].y=cloud_xyz.points[count].y; 102 | cloud_new.points[count].z=cloud_xyz.points[count].z; 103 | ROS_INFO("Data assigned: %G", cloud_new.points[count].z ); 104 | 105 | } 106 | count++; 107 | } 108 | } 109 | pcl::toPCLPointCloud2(cloud_new, pcl_pointcloud); 110 | pcl_pointcloud.header.frame_id=pcl_ptr->header.frame_id; 111 | pcl_pointcloud.header.stamp=pcl_ptr->header.stamp; 112 | 113 | pub_1.publish(pcl_pointcloud); 114 | 115 | } 116 | 117 | int main(int argc, char** argv) 118 | { 119 | ros::init(argc, argv, "Object_track"); 120 | 121 | Object_track tracker; 122 | 123 | ros::spin(); 124 | } -------------------------------------------------------------------------------- /object_tracker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(project_1) 3 | 4 | ## Find catkin macros and libraries 5 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) 6 | ## is used, also find other catkin packages 7 | find_package(catkin REQUIRED COMPONENTS 8 | rospy 9 | roscpp 10 | sensor_msgs 11 | std_msgs 12 | pcl_ros 13 | pcl_conversions 14 | cv_bridge 15 | 16 | ) 17 | 18 | find_package(PCL REQUIRED) 19 | include_directories( 20 | ${PCL_INCLUDE_DIRS} 21 | ) 22 | link_directories( 23 | ${PCL_LIBRARY_DIRS} 24 | ) 25 | 26 | 27 | find_package(OpenCV) 28 | include_directories(${OpenCV_INCLUDE_DIRS}) 29 | ## System dependencies are found with CMake's conventions 30 | # find_package(Boost REQUIRED COMPONENTS system) 31 | 32 | 33 | ## Uncomment this if the package has a setup.py. This macro ensures 34 | ## modules and global scripts declared therein get installed 35 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html 36 | # catkin_python_setup() 37 | 38 | ################################################ 39 | ## Declare ROS messages, services and actions ## 40 | ################################################ 41 | 42 | ## To declare and build messages, services or actions from within this 43 | ## package, follow these steps: 44 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in 45 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). 46 | ## * In the file package.xml: 47 | ## * add a build_depend tag for "message_generation" 48 | ## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET 49 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in 50 | ## but can be declared for certainty nonetheless: 51 | ## * add a run_depend tag for "message_runtime" 52 | ## * In this file (CMakeLists.txt): 53 | ## * add "message_generation" and every package in MSG_DEP_SET to 54 | ## find_package(catkin REQUIRED COMPONENTS ...) 55 | ## * add "message_runtime" and every package in MSG_DEP_SET to 56 | ## catkin_package(CATKIN_DEPENDS ...) 57 | ## * uncomment the add_*_files sections below as needed 58 | ## and list every .msg/.srv/.action file to be processed 59 | ## * uncomment the generate_messages entry below 60 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) 61 | 62 | ## Generate messages in the 'msg' folder 63 | # add_message_files( 64 | # FILES 65 | # Message1.msg 66 | # Message2.msg 67 | # ) 68 | 69 | ## Generate services in the 'srv' folder 70 | # add_service_files( 71 | # FILES 72 | # Service1.srv 73 | # Service2.srv 74 | # ) 75 | 76 | ## Generate actions in the 'action' folder 77 | # add_action_files( 78 | # FILES 79 | # Action1.action 80 | # Action2.action 81 | # ) 82 | 83 | ## Generate added messages and services with any dependencies listed here 84 | # generate_messages( 85 | # DEPENDENCIES 86 | # std_msgs 87 | # ) 88 | 89 | ################################################ 90 | ## Declare ROS dynamic reconfigure parameters ## 91 | ################################################ 92 | 93 | ## To declare and build dynamic reconfigure parameters within this 94 | ## package, follow these steps: 95 | ## * In the file package.xml: 96 | ## * add a build_depend and a run_depend tag for "dynamic_reconfigure" 97 | ## * In this file (CMakeLists.txt): 98 | ## * add "dynamic_reconfigure" to 99 | ## find_package(catkin REQUIRED COMPONENTS ...) 100 | ## * uncomment the "generate_dynamic_reconfigure_options" section below 101 | ## and list every .cfg file to be processed 102 | 103 | ## Generate dynamic reconfigure parameters in the 'cfg' folder 104 | # generate_dynamic_reconfigure_options( 105 | # cfg/DynReconf1.cfg 106 | # cfg/DynReconf2.cfg 107 | # ) 108 | 109 | ################################### 110 | ## catkin specific configuration ## 111 | ################################### 112 | ## The catkin_package macro generates cmake config files for your package 113 | ## Declare things to be passed to dependent projects 114 | ## INCLUDE_DIRS: uncomment this if you package contains header files 115 | ## LIBRARIES: libraries you create in this project that dependent projects also need 116 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need 117 | ## DEPENDS: system dependencies of this project that dependent projects also need 118 | catkin_package( 119 | # INCLUDE_DIRS include 120 | # LIBRARIES project_1 121 | # CATKIN_DEPENDS rospy std_msgs 122 | # DEPENDS system_lib 123 | ) 124 | 125 | ########### 126 | ## Build ## 127 | ########### 128 | 129 | ## Specify additional locations of header files 130 | ## Your package locations should be listed before other locations 131 | # include_directories(include) 132 | include_directories( 133 | ${catkin_INCLUDE_DIRS} 134 | ) 135 | 136 | ## Declare a C++ library 137 | # add_library(project_1 138 | # src/${PROJECT_NAME}/project_1.cpp 139 | # ) 140 | 141 | ## Add cmake target dependencies of the library 142 | ## as an example, code may need to be generated before libraries 143 | ## either from message generation or dynamic reconfigure 144 | # add_dependencies(project_1 ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 145 | 146 | ## Declare a C++ executable 147 | # add_executable(project_1_node src/project_1_node.cpp) 148 | 149 | ## Add cmake target dependencies of the executable 150 | ## same as for the library above 151 | # add_dependencies(project_1_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 152 | 153 | ## Specify libraries to link a library or executable target against 154 | # target_link_libraries(project_1_node 155 | # ${catkin_LIBRARIES} 156 | # ) 157 | 158 | ############# 159 | ## Install ## 160 | ############# 161 | 162 | # all install targets should use catkin DESTINATION variables 163 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html 164 | 165 | ## Mark executable scripts (Python etc.) for installation 166 | ## in contrast to setup.py, you can choose the destination 167 | # install(PROGRAMS 168 | # scripts/my_python_script 169 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 170 | # ) 171 | 172 | ## Mark executables and/or libraries for installation 173 | # install(TARGETS project_1 project_1_node 174 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 175 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 176 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 177 | # ) 178 | 179 | ## Mark cpp header files for installation 180 | # install(DIRECTORY include/${PROJECT_NAME}/ 181 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 182 | # FILES_MATCHING PATTERN "*.h" 183 | # PATTERN ".svn" EXCLUDE 184 | # ) 185 | 186 | ## Mark other files for installation (e.g. launch and bag files, etc.) 187 | # install(FILES 188 | # # myfile1 189 | # # myfile2 190 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 191 | # ) 192 | 193 | ############# 194 | ## Testing ## 195 | ############# 196 | 197 | ## Add gtest based cpp test target and link libraries 198 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_project_1.cpp) 199 | # if(TARGET ${PROJECT_NAME}-test) 200 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) 201 | # endif() 202 | 203 | ## Add folders to be run by python nosetests 204 | # catkin_add_nosetests(test) 205 | 206 | add_executable(talker src/talker.cpp) 207 | target_link_libraries(talker ${catkin_LIBRARIES}) 208 | add_dependencies(talker project_1_generate_messages_cpp) 209 | 210 | add_executable(listener src/listener.cpp) 211 | target_link_libraries(listener ${catkin_LIBRARIES}) 212 | add_dependencies(listener project_1_generate_messages_cpp) 213 | 214 | 215 | add_executable(pcl_tutorial src/pcl_tutorial.cpp) 216 | target_link_libraries(pcl_tutorial ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS}) 217 | 218 | add_executable(Tracker_object src/Tracker_object.cpp) 219 | target_link_libraries(Tracker_object ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 220 | 221 | add_executable(test_image src/test_image.cpp) 222 | target_link_libraries(test_image ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 223 | -------------------------------------------------------------------------------- /object_tracker/CMakeLists.txt~: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(project_1) 3 | 4 | ## Find catkin macros and libraries 5 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) 6 | ## is used, also find other catkin packages 7 | find_package(catkin REQUIRED COMPONENTS 8 | rospy 9 | roscpp 10 | sensor_msgs 11 | std_msgs 12 | pcl_ros 13 | pcl_conversions 14 | cv_bridge 15 | 16 | ) 17 | 18 | find_package(PCL REQUIRED) 19 | include_directories( 20 | ${PCL_INCLUDE_DIRS} 21 | ) 22 | link_directories( 23 | ${PCL_LIBRARY_DIRS} 24 | ) 25 | 26 | 27 | find_package(OpenCV) 28 | include_directories(${OpenCV_INCLUDE_DIRS}) 29 | ## System dependencies are found with CMake's conventions 30 | # find_package(Boost REQUIRED COMPONENTS system) 31 | 32 | 33 | ## Uncomment this if the package has a setup.py. This macro ensures 34 | ## modules and global scripts declared therein get installed 35 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html 36 | # catkin_python_setup() 37 | 38 | ################################################ 39 | ## Declare ROS messages, services and actions ## 40 | ################################################ 41 | 42 | ## To declare and build messages, services or actions from within this 43 | ## package, follow these steps: 44 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in 45 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). 46 | ## * In the file package.xml: 47 | ## * add a build_depend tag for "message_generation" 48 | ## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET 49 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in 50 | ## but can be declared for certainty nonetheless: 51 | ## * add a run_depend tag for "message_runtime" 52 | ## * In this file (CMakeLists.txt): 53 | ## * add "message_generation" and every package in MSG_DEP_SET to 54 | ## find_package(catkin REQUIRED COMPONENTS ...) 55 | ## * add "message_runtime" and every package in MSG_DEP_SET to 56 | ## catkin_package(CATKIN_DEPENDS ...) 57 | ## * uncomment the add_*_files sections below as needed 58 | ## and list every .msg/.srv/.action file to be processed 59 | ## * uncomment the generate_messages entry below 60 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) 61 | 62 | ## Generate messages in the 'msg' folder 63 | # add_message_files( 64 | # FILES 65 | # Message1.msg 66 | # Message2.msg 67 | # ) 68 | 69 | ## Generate services in the 'srv' folder 70 | # add_service_files( 71 | # FILES 72 | # Service1.srv 73 | # Service2.srv 74 | # ) 75 | 76 | ## Generate actions in the 'action' folder 77 | # add_action_files( 78 | # FILES 79 | # Action1.action 80 | # Action2.action 81 | # ) 82 | 83 | ## Generate added messages and services with any dependencies listed here 84 | # generate_messages( 85 | # DEPENDENCIES 86 | # std_msgs 87 | # ) 88 | 89 | ################################################ 90 | ## Declare ROS dynamic reconfigure parameters ## 91 | ################################################ 92 | 93 | ## To declare and build dynamic reconfigure parameters within this 94 | ## package, follow these steps: 95 | ## * In the file package.xml: 96 | ## * add a build_depend and a run_depend tag for "dynamic_reconfigure" 97 | ## * In this file (CMakeLists.txt): 98 | ## * add "dynamic_reconfigure" to 99 | ## find_package(catkin REQUIRED COMPONENTS ...) 100 | ## * uncomment the "generate_dynamic_reconfigure_options" section below 101 | ## and list every .cfg file to be processed 102 | 103 | ## Generate dynamic reconfigure parameters in the 'cfg' folder 104 | # generate_dynamic_reconfigure_options( 105 | # cfg/DynReconf1.cfg 106 | # cfg/DynReconf2.cfg 107 | # ) 108 | 109 | ################################### 110 | ## catkin specific configuration ## 111 | ################################### 112 | ## The catkin_package macro generates cmake config files for your package 113 | ## Declare things to be passed to dependent projects 114 | ## INCLUDE_DIRS: uncomment this if you package contains header files 115 | ## LIBRARIES: libraries you create in this project that dependent projects also need 116 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need 117 | ## DEPENDS: system dependencies of this project that dependent projects also need 118 | catkin_package( 119 | # INCLUDE_DIRS include 120 | # LIBRARIES project_1 121 | # CATKIN_DEPENDS rospy std_msgs 122 | # DEPENDS system_lib 123 | ) 124 | 125 | ########### 126 | ## Build ## 127 | ########### 128 | 129 | ## Specify additional locations of header files 130 | ## Your package locations should be listed before other locations 131 | # include_directories(include) 132 | include_directories( 133 | ${catkin_INCLUDE_DIRS} 134 | ) 135 | 136 | ## Declare a C++ library 137 | # add_library(project_1 138 | # src/${PROJECT_NAME}/project_1.cpp 139 | # ) 140 | 141 | ## Add cmake target dependencies of the library 142 | ## as an example, code may need to be generated before libraries 143 | ## either from message generation or dynamic reconfigure 144 | # add_dependencies(project_1 ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 145 | 146 | ## Declare a C++ executable 147 | # add_executable(project_1_node src/project_1_node.cpp) 148 | 149 | ## Add cmake target dependencies of the executable 150 | ## same as for the library above 151 | # add_dependencies(project_1_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 152 | 153 | ## Specify libraries to link a library or executable target against 154 | # target_link_libraries(project_1_node 155 | # ${catkin_LIBRARIES} 156 | # ) 157 | 158 | ############# 159 | ## Install ## 160 | ############# 161 | 162 | # all install targets should use catkin DESTINATION variables 163 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html 164 | 165 | ## Mark executable scripts (Python etc.) for installation 166 | ## in contrast to setup.py, you can choose the destination 167 | # install(PROGRAMS 168 | # scripts/my_python_script 169 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 170 | # ) 171 | 172 | ## Mark executables and/or libraries for installation 173 | # install(TARGETS project_1 project_1_node 174 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 175 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 176 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 177 | # ) 178 | 179 | ## Mark cpp header files for installation 180 | # install(DIRECTORY include/${PROJECT_NAME}/ 181 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 182 | # FILES_MATCHING PATTERN "*.h" 183 | # PATTERN ".svn" EXCLUDE 184 | # ) 185 | 186 | ## Mark other files for installation (e.g. launch and bag files, etc.) 187 | # install(FILES 188 | # # myfile1 189 | # # myfile2 190 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 191 | # ) 192 | 193 | ############# 194 | ## Testing ## 195 | ############# 196 | 197 | ## Add gtest based cpp test target and link libraries 198 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_project_1.cpp) 199 | # if(TARGET ${PROJECT_NAME}-test) 200 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) 201 | # endif() 202 | 203 | ## Add folders to be run by python nosetests 204 | # catkin_add_nosetests(test) 205 | 206 | add_executable(talker src/talker.cpp) 207 | target_link_libraries(talker ${catkin_LIBRARIES}) 208 | add_dependencies(talker project_1_generate_messages_cpp) 209 | 210 | #add_executable(listener src/listener.cpp) 211 | #target_link_libraries(listener ${catkin_LIBRARIES}) 212 | #add_dependencies(listener project_1_generate_messages_cpp) 213 | 214 | 215 | add_executable(pcl_tutorial src/pcl_tutorial.cpp) 216 | target_link_libraries(pcl_tutorial ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS}) 217 | 218 | add_executable(Tracker_object src/Tracker_object.cpp) 219 | target_link_libraries(Tracker_object ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 220 | 221 | add_executable(test_image src/test_image.cpp) 222 | target_link_libraries(test_image ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 223 | -------------------------------------------------------------------------------- /project_1/CMakeLists.txt~: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(project_1) 3 | 4 | ## Find catkin macros and libraries 5 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) 6 | ## is used, also find other catkin packages 7 | find_package(catkin REQUIRED COMPONENTS 8 | rospy 9 | roscpp 10 | sensor_msgs 11 | std_msgs 12 | pcl_ros 13 | pcl_conversions 14 | cv_bridge 15 | 16 | ) 17 | 18 | find_package(PCL REQUIRED) 19 | include_directories( 20 | ${PCL_INCLUDE_DIRS} 21 | ) 22 | link_directories( 23 | ${PCL_LIBRARY_DIRS} 24 | ) 25 | 26 | 27 | find_package(OpenCV) 28 | include_directories(${OpenCV_INCLUDE_DIRS}) 29 | ## System dependencies are found with CMake's conventions 30 | # find_package(Boost REQUIRED COMPONENTS system) 31 | 32 | 33 | ## Uncomment this if the package has a setup.py. This macro ensures 34 | ## modules and global scripts declared therein get installed 35 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html 36 | # catkin_python_setup() 37 | 38 | ################################################ 39 | ## Declare ROS messages, services and actions ## 40 | ################################################ 41 | 42 | ## To declare and build messages, services or actions from within this 43 | ## package, follow these steps: 44 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in 45 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). 46 | ## * In the file package.xml: 47 | ## * add a build_depend tag for "message_generation" 48 | ## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET 49 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in 50 | ## but can be declared for certainty nonetheless: 51 | ## * add a run_depend tag for "message_runtime" 52 | ## * In this file (CMakeLists.txt): 53 | ## * add "message_generation" and every package in MSG_DEP_SET to 54 | ## find_package(catkin REQUIRED COMPONENTS ...) 55 | ## * add "message_runtime" and every package in MSG_DEP_SET to 56 | ## catkin_package(CATKIN_DEPENDS ...) 57 | ## * uncomment the add_*_files sections below as needed 58 | ## and list every .msg/.srv/.action file to be processed 59 | ## * uncomment the generate_messages entry below 60 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) 61 | 62 | ## Generate messages in the 'msg' folder 63 | # add_message_files( 64 | # FILES 65 | # Message1.msg 66 | # Message2.msg 67 | # ) 68 | 69 | ## Generate services in the 'srv' folder 70 | # add_service_files( 71 | # FILES 72 | # Service1.srv 73 | # Service2.srv 74 | # ) 75 | 76 | ## Generate actions in the 'action' folder 77 | # add_action_files( 78 | # FILES 79 | # Action1.action 80 | # Action2.action 81 | # ) 82 | 83 | ## Generate added messages and services with any dependencies listed here 84 | # generate_messages( 85 | # DEPENDENCIES 86 | # std_msgs 87 | # ) 88 | 89 | ################################################ 90 | ## Declare ROS dynamic reconfigure parameters ## 91 | ################################################ 92 | 93 | ## To declare and build dynamic reconfigure parameters within this 94 | ## package, follow these steps: 95 | ## * In the file package.xml: 96 | ## * add a build_depend and a run_depend tag for "dynamic_reconfigure" 97 | ## * In this file (CMakeLists.txt): 98 | ## * add "dynamic_reconfigure" to 99 | ## find_package(catkin REQUIRED COMPONENTS ...) 100 | ## * uncomment the "generate_dynamic_reconfigure_options" section below 101 | ## and list every .cfg file to be processed 102 | 103 | ## Generate dynamic reconfigure parameters in the 'cfg' folder 104 | # generate_dynamic_reconfigure_options( 105 | # cfg/DynReconf1.cfg 106 | # cfg/DynReconf2.cfg 107 | # ) 108 | 109 | ################################### 110 | ## catkin specific configuration ## 111 | ################################### 112 | ## The catkin_package macro generates cmake config files for your package 113 | ## Declare things to be passed to dependent projects 114 | ## INCLUDE_DIRS: uncomment this if you package contains header files 115 | ## LIBRARIES: libraries you create in this project that dependent projects also need 116 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need 117 | ## DEPENDS: system dependencies of this project that dependent projects also need 118 | catkin_package( 119 | # INCLUDE_DIRS include 120 | # LIBRARIES project_1 121 | # CATKIN_DEPENDS rospy std_msgs 122 | # DEPENDS system_lib 123 | ) 124 | 125 | ########### 126 | ## Build ## 127 | ########### 128 | 129 | ## Specify additional locations of header files 130 | ## Your package locations should be listed before other locations 131 | # include_directories(include) 132 | include_directories( 133 | ${catkin_INCLUDE_DIRS} 134 | ) 135 | 136 | ## Declare a C++ library 137 | # add_library(project_1 138 | # src/${PROJECT_NAME}/project_1.cpp 139 | # ) 140 | 141 | ## Add cmake target dependencies of the library 142 | ## as an example, code may need to be generated before libraries 143 | ## either from message generation or dynamic reconfigure 144 | # add_dependencies(project_1 ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 145 | 146 | ## Declare a C++ executable 147 | # add_executable(project_1_node src/project_1_node.cpp) 148 | 149 | ## Add cmake target dependencies of the executable 150 | ## same as for the library above 151 | # add_dependencies(project_1_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 152 | 153 | ## Specify libraries to link a library or executable target against 154 | # target_link_libraries(project_1_node 155 | # ${catkin_LIBRARIES} 156 | # ) 157 | 158 | ############# 159 | ## Install ## 160 | ############# 161 | 162 | # all install targets should use catkin DESTINATION variables 163 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html 164 | 165 | ## Mark executable scripts (Python etc.) for installation 166 | ## in contrast to setup.py, you can choose the destination 167 | # install(PROGRAMS 168 | # scripts/my_python_script 169 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 170 | # ) 171 | 172 | ## Mark executables and/or libraries for installation 173 | # install(TARGETS project_1 project_1_node 174 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 175 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 176 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 177 | # ) 178 | 179 | ## Mark cpp header files for installation 180 | # install(DIRECTORY include/${PROJECT_NAME}/ 181 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 182 | # FILES_MATCHING PATTERN "*.h" 183 | # PATTERN ".svn" EXCLUDE 184 | # ) 185 | 186 | ## Mark other files for installation (e.g. launch and bag files, etc.) 187 | # install(FILES 188 | # # myfile1 189 | # # myfile2 190 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 191 | # ) 192 | 193 | ############# 194 | ## Testing ## 195 | ############# 196 | 197 | ## Add gtest based cpp test target and link libraries 198 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_project_1.cpp) 199 | # if(TARGET ${PROJECT_NAME}-test) 200 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) 201 | # endif() 202 | 203 | ## Add folders to be run by python nosetests 204 | # catkin_add_nosetests(test) 205 | 206 | #add_executable(talker src/talker.cpp) 207 | #target_link_libraries(talker ${catkin_LIBRARIES}) 208 | #add_dependencies(talker project_1_generate_messages_cpp) 209 | 210 | #add_executable(listener src/listener.cpp) 211 | #target_link_libraries(listener ${catkin_LIBRARIES}) 212 | #add_dependencies(listener project_1_generate_messages_cpp) 213 | 214 | 215 | #add_executable(pcl_tutorial src/pcl_tutorial.cpp) 216 | #target_link_libraries(pcl_tutorial ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS}) 217 | 218 | add_executable(Tracker_object src/Tracker_object.cpp) 219 | target_link_libraries(Tracker_object ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 220 | 221 | add_executable(test_image src/test_image.cpp) 222 | target_link_libraries(test_image ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 223 | -------------------------------------------------------------------------------- /project_1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(project_1) 3 | 4 | ## Find catkin macros and libraries 5 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) 6 | ## is used, also find other catkin packages 7 | find_package(catkin REQUIRED COMPONENTS 8 | rospy 9 | roscpp 10 | sensor_msgs 11 | std_msgs 12 | pcl_ros 13 | pcl_conversions 14 | cv_bridge 15 | 16 | ) 17 | 18 | find_package(PCL REQUIRED) 19 | include_directories( 20 | ${PCL_INCLUDE_DIRS} 21 | ) 22 | link_directories( 23 | ${PCL_LIBRARY_DIRS} 24 | ) 25 | 26 | 27 | find_package(OpenCV) 28 | include_directories(${OpenCV_INCLUDE_DIRS}) 29 | ## System dependencies are found with CMake's conventions 30 | # find_package(Boost REQUIRED COMPONENTS system) 31 | 32 | 33 | ## Uncomment this if the package has a setup.py. This macro ensures 34 | ## modules and global scripts declared therein get installed 35 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html 36 | # catkin_python_setup() 37 | 38 | ################################################ 39 | ## Declare ROS messages, services and actions ## 40 | ################################################ 41 | 42 | ## To declare and build messages, services or actions from within this 43 | ## package, follow these steps: 44 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in 45 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). 46 | ## * In the file package.xml: 47 | ## * add a build_depend tag for "message_generation" 48 | ## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET 49 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in 50 | ## but can be declared for certainty nonetheless: 51 | ## * add a run_depend tag for "message_runtime" 52 | ## * In this file (CMakeLists.txt): 53 | ## * add "message_generation" and every package in MSG_DEP_SET to 54 | ## find_package(catkin REQUIRED COMPONENTS ...) 55 | ## * add "message_runtime" and every package in MSG_DEP_SET to 56 | ## catkin_package(CATKIN_DEPENDS ...) 57 | ## * uncomment the add_*_files sections below as needed 58 | ## and list every .msg/.srv/.action file to be processed 59 | ## * uncomment the generate_messages entry below 60 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) 61 | 62 | ## Generate messages in the 'msg' folder 63 | # add_message_files( 64 | # FILES 65 | # Message1.msg 66 | # Message2.msg 67 | # ) 68 | 69 | ## Generate services in the 'srv' folder 70 | # add_service_files( 71 | # FILES 72 | # Service1.srv 73 | # Service2.srv 74 | # ) 75 | 76 | ## Generate actions in the 'action' folder 77 | # add_action_files( 78 | # FILES 79 | # Action1.action 80 | # Action2.action 81 | # ) 82 | 83 | ## Generate added messages and services with any dependencies listed here 84 | # generate_messages( 85 | # DEPENDENCIES 86 | # std_msgs 87 | # ) 88 | 89 | ################################################ 90 | ## Declare ROS dynamic reconfigure parameters ## 91 | ################################################ 92 | 93 | ## To declare and build dynamic reconfigure parameters within this 94 | ## package, follow these steps: 95 | ## * In the file package.xml: 96 | ## * add a build_depend and a run_depend tag for "dynamic_reconfigure" 97 | ## * In this file (CMakeLists.txt): 98 | ## * add "dynamic_reconfigure" to 99 | ## find_package(catkin REQUIRED COMPONENTS ...) 100 | ## * uncomment the "generate_dynamic_reconfigure_options" section below 101 | ## and list every .cfg file to be processed 102 | 103 | ## Generate dynamic reconfigure parameters in the 'cfg' folder 104 | # generate_dynamic_reconfigure_options( 105 | # cfg/DynReconf1.cfg 106 | # cfg/DynReconf2.cfg 107 | # ) 108 | 109 | ################################### 110 | ## catkin specific configuration ## 111 | ################################### 112 | ## The catkin_package macro generates cmake config files for your package 113 | ## Declare things to be passed to dependent projects 114 | ## INCLUDE_DIRS: uncomment this if you package contains header files 115 | ## LIBRARIES: libraries you create in this project that dependent projects also need 116 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need 117 | ## DEPENDS: system dependencies of this project that dependent projects also need 118 | catkin_package( 119 | # INCLUDE_DIRS include 120 | # LIBRARIES project_1 121 | # CATKIN_DEPENDS rospy std_msgs 122 | # DEPENDS system_lib 123 | ) 124 | 125 | ########### 126 | ## Build ## 127 | ########### 128 | 129 | ## Specify additional locations of header files 130 | ## Your package locations should be listed before other locations 131 | # include_directories(include) 132 | include_directories( 133 | ${catkin_INCLUDE_DIRS} 134 | ) 135 | 136 | ## Declare a C++ library 137 | # add_library(project_1 138 | # src/${PROJECT_NAME}/project_1.cpp 139 | # ) 140 | 141 | ## Add cmake target dependencies of the library 142 | ## as an example, code may need to be generated before libraries 143 | ## either from message generation or dynamic reconfigure 144 | # add_dependencies(project_1 ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 145 | 146 | ## Declare a C++ executable 147 | # add_executable(project_1_node src/project_1_node.cpp) 148 | 149 | ## Add cmake target dependencies of the executable 150 | ## same as for the library above 151 | # add_dependencies(project_1_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 152 | 153 | ## Specify libraries to link a library or executable target against 154 | # target_link_libraries(project_1_node 155 | # ${catkin_LIBRARIES} 156 | # ) 157 | 158 | ############# 159 | ## Install ## 160 | ############# 161 | 162 | # all install targets should use catkin DESTINATION variables 163 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html 164 | 165 | ## Mark executable scripts (Python etc.) for installation 166 | ## in contrast to setup.py, you can choose the destination 167 | # install(PROGRAMS 168 | # scripts/my_python_script 169 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 170 | # ) 171 | 172 | ## Mark executables and/or libraries for installation 173 | # install(TARGETS project_1 project_1_node 174 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 175 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 176 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 177 | # ) 178 | 179 | ## Mark cpp header files for installation 180 | # install(DIRECTORY include/${PROJECT_NAME}/ 181 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 182 | # FILES_MATCHING PATTERN "*.h" 183 | # PATTERN ".svn" EXCLUDE 184 | # ) 185 | 186 | ## Mark other files for installation (e.g. launch and bag files, etc.) 187 | # install(FILES 188 | # # myfile1 189 | # # myfile2 190 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 191 | # ) 192 | 193 | ############# 194 | ## Testing ## 195 | ############# 196 | 197 | ## Add gtest based cpp test target and link libraries 198 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_project_1.cpp) 199 | # if(TARGET ${PROJECT_NAME}-test) 200 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) 201 | # endif() 202 | 203 | ## Add folders to be run by python nosetests 204 | # catkin_add_nosetests(test) 205 | 206 | #add_executable(talker src/talker.cpp) 207 | #target_link_libraries(talker ${catkin_LIBRARIES}) 208 | #add_dependencies(talker project_1_generate_messages_cpp) 209 | 210 | #add_executable(listener src/listener.cpp) 211 | #target_link_libraries(listener ${catkin_LIBRARIES}) 212 | #add_dependencies(listener project_1_generate_messages_cpp) 213 | 214 | 215 | #add_executable(pcl_tutorial src/pcl_tutorial.cpp) 216 | #target_link_libraries(pcl_tutorial ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS}) 217 | 218 | add_executable(Tracker_object2 src/Tracker_object2.cpp) 219 | target_link_libraries(Tracker_object2 ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 220 | 221 | add_executable(Tracker_object src/Tracker_object.cpp) 222 | target_link_libraries(Tracker_object ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 223 | 224 | add_executable(test_image src/test_image.cpp) 225 | target_link_libraries(test_image ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES}) 226 | --------------------------------------------------------------------------------