body_tracker_nodelet.cpp
Go to the documentation of this file.
00001 /*
00002  *****************************************************************
00003  * Copyright (c) 2015 \n
00004  * Fraunhofer Institute for Manufacturing Engineering
00005  * and Automation (IPA) \n\n
00006  *
00007  *****************************************************************
00008  *
00009  * \note
00010  * Project name: Care-O-bot
00011  * \note
00012  * ROS stack name: cob_people_perception
00013  * \note
00014  * ROS package name: cob_openni2_tracker
00015  *
00016  * \author
00017  * Author: Olha Meyer
00018  * \author
00019  * Supervised by: Richard Bormann
00020  *
00021  * \date Date of creation: Jan 15, 2015
00022  *
00023  * \brief
00024  * functions for detecting people using camera data
00025  * current approach: start a nodelet to launch the BodyTracker node and
00026  * camera driver simultaneously.
00027  *
00028  *****************************************************************
00029  *
00030  * Redistribution and use in source and binary forms, with or without
00031  * modification, are permitted provided that the following conditions are met:
00032  *
00033  * - Redistributions of source code must retain the above copyright
00034  * notice, this list of conditions and the following disclaimer. \n
00035  * - Redistributions in binary form must reproduce the above copyright
00036  * notice, this list of conditions and the following disclaimer in the
00037  * documentation and/or other materials provided with the distribution. \n
00038  * - Neither the name of the Fraunhofer Institute for Manufacturing
00039  * Engineering and Automation (IPA) nor the names of its
00040  * contributors may be used to endorse or promote products derived from
00041  * this software without specific prior written permission. \n
00042  *
00043  * This program is free software: you can redistribute it and/or modify
00044  * it under the terms of the GNU Lesser General Public License LGPL as
00045  * published by the Free Software Foundation, either version 3 of the
00046  * License, or (at your option) any later version.
00047  *
00048  * This program is distributed in the hope that it will be useful,
00049  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00050  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00051  * GNU Lesser General Public License LGPL for more details.
00052  *
00053  * You should have received a copy of the GNU Lesser General Public
00054  * License LGPL along with this program.
00055  * If not, see <http://www.gnu.org/licenses/>.
00056  *
00057  ****************************************************************/
00058 
00059 #include <cob_openni2_tracker/body_tracker_nodelet.h>
00060 #include "nodelet/loader.h"
00061 #include "nodelet/NodeletList.h"
00062 #include "nodelet/NodeletLoad.h"
00063 #include "nodelet/NodeletUnload.h"
00064 #include <boost/thread.hpp>
00065 
00066 PLUGINLIB_EXPORT_CLASS(BodyTrackerNodelet, nodelet::Nodelet);
00067 
00068 BodyTrackerNodelet::BodyTrackerNodelet(): Nodelet(), bt_listener(NULL)
00069 {
00070 }
00071 
00072 BodyTrackerNodelet::~BodyTrackerNodelet()
00073 {
00074         if (bt_listener != NULL)
00075         {
00076                 bt_listener->shutdown_ = true;
00077                 tracker_thread_->join();
00078                 delete bt_listener;
00079         }
00080 }
00081 
00082 void BodyTrackerNodelet::onInit()
00083 {
00084         NODELET_INFO("Init BodyTrackerNodelet.");
00085 
00086         getPrivateNodeHandle().param<std::string>("nodelet_manager", nodelet_manager_, "");
00087         std::cout << "nodelet_manager = " << nodelet_manager_ << "\n";
00088 
00089         if(bt_listener == 0)
00090                 bt_listener = new BodyTracker(getPrivateNodeHandle());
00091 
00092         if (bt_listener->shutdown_ == true)
00093         {
00094                 delete bt_listener;
00095                 bt_listener = 0;
00096 //              nodelet::NodeletUnload req;
00097 //              req.request.name = this->getPrivateNodeHandle().getNamespace();
00098 //              NODELET_INFO("name: %s", this->getPrivateNodeHandle().getNamespace().c_str());
00099 //              ros::ServiceClient unload = this->getNodeHandle().serviceClient<nodelet::NodeletUnload>(nodelet_manager_ + "/unload_nodelet");
00100 //              unload.call(req);
00101         }
00102         else
00103         {
00104                 tracker_thread_ = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&BodyTrackerNodelet::run, this)));
00105         }
00106 }
00107 
00108 void BodyTrackerNodelet::run()
00109 {
00110         bt_listener->runTracker(); // tracking loop is stopped by setting bt_listener->shutdown_ = true;
00111 }


cob_openni2_tracker
Author(s): Marcus Liebhardt , Olha Meyer
autogenerated on Mon May 6 2019 02:32:19