Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "camera.hpp"
00022
00023
00024
00025
00026 #include "../tools/alvisiondefinitions.h"
00027
00028 namespace naoqi
00029 {
00030 namespace publisher
00031 {
00032
00033 CameraPublisher::CameraPublisher( const std::string& topic, int camera_source ):
00034 topic_( topic ),
00035 is_initialized_(false),
00036 camera_source_( camera_source )
00037 {
00038 }
00039
00040 CameraPublisher::~CameraPublisher()
00041 {
00042 }
00043
00044 void CameraPublisher::publish( const sensor_msgs::ImagePtr& img, const sensor_msgs::CameraInfo& camera_info )
00045 {
00046 pub_.publish( *img, camera_info );
00047 }
00048
00049 void CameraPublisher::reset( ros::NodeHandle& nh )
00050 {
00051
00052 image_transport::ImageTransport it( nh );
00053 pub_ = it.advertiseCamera( topic_, 1 );
00054
00055
00056 if (camera_source_!=AL::kDepthCamera)
00057 {
00058
00059 std::string node_name = ros::this_node::getName();
00060 XmlRpc::XmlRpcValue args, result, payload;
00061 args[0] = node_name;
00062 args[1] = node_name;
00063 ros::master::execute("lookupNode", args, result, payload, false);
00064 args[2] = result[2];
00065
00066
00067 std::vector<std::string> topic_list;
00068 topic_list.push_back(std::string("/") + node_name + "/" + topic_ + std::string("/compressedDepth"));
00069 topic_list.push_back(std::string("/") + node_name + "/" + topic_ + std::string("/compressedDepth/parameter_updates"));
00070 topic_list.push_back(std::string("/") + node_name + "/" + topic_ + std::string("/compressedDepth/parameter_descriptions"));
00071
00072
00073 for(std::vector<std::string>::const_iterator topic = topic_list.begin(); topic != topic_list.end(); ++topic)
00074 {
00075 args[1] = *topic;
00076 ros::master::execute("unregisterPublisher", args, result, payload, false);
00077 }
00078 }
00079
00080 is_initialized_ = true;
00081 }
00082
00083 }
00084 }