38 #include <boost/make_shared.hpp> 55 return (di1.
uri_.compare(di2.
uri_) < 0);
59 typedef std::set<AstraDeviceInfo, AstraDeviceInfoComparator>
DeviceSet;
67 openni::OpenNI::DeviceConnectedListener(),
68 openni::OpenNI::DeviceDisconnectedListener(),
69 openni::OpenNI::DeviceStateChangedListener()
79 for (
int i = 0; i < device_info_list.
getSize(); ++i)
81 onDeviceConnected(&device_info_list[i]);
94 ROS_INFO(
"Device \"%s\" error state changed to %d\n", pInfo->
getUri(), state);
99 onDeviceConnected(pInfo);
105 onDeviceDisconnected(pInfo);
112 boost::mutex::scoped_lock l(device_mutex_);
119 device_set_.erase(device_info_wrapped);
120 device_set_.insert(device_info_wrapped);
126 boost::mutex::scoped_lock l(device_mutex_);
131 device_set_.erase(device_info_wrapped);
136 boost::mutex::scoped_lock l(device_mutex_);
140 result->reserve(device_set_.size());
142 std::set<AstraDeviceInfo, AstraDeviceInfoComparator>::const_iterator it;
143 std::set<AstraDeviceInfo, AstraDeviceInfoComparator>::const_iterator it_end = device_set_.end();
145 for (it = device_set_.begin(); it != it_end; ++it)
146 result->push_back(it->uri_);
153 boost::mutex::scoped_lock l(device_mutex_);
157 result->reserve(device_set_.size());
159 DeviceSet::const_iterator it;
160 DeviceSet::const_iterator it_end = device_set_.end();
162 for (it = device_set_.begin(); it != it_end; ++it)
163 result->push_back(*it);
170 boost::mutex::scoped_lock l(device_mutex_);
172 return device_set_.size();
189 device_listener_ = boost::make_shared<AstraDeviceListener>();
198 if (singelton_.get()==0)
199 singelton_ = boost::make_shared<AstraDeviceManager>();
206 return device_listener_->getConnectedDeviceInfos();
211 return device_listener_->getConnectedDeviceURIs();
216 return device_listener_->getNumOfConnectedDevices();
227 int serial_len = 100;
228 char serial[serial_len];
238 openni_device.
close();
249 return boost::make_shared<AstraDevice>(
"");
253 return boost::make_shared<AstraDevice>(device_URI);
261 std::vector<AstraDeviceInfo>::const_iterator it;
262 std::vector<AstraDeviceInfo>::const_iterator it_end = device_info->end();
264 for (it = device_info->begin(); it != it_end; ++it)
266 stream <<
"Uri: " << it->uri_ <<
" (Vendor: " << it->vendor_ <<
267 ", Name: " << it->name_ <<
268 ", Vendor ID: " << it->vendor_id_ <<
269 ", Product ID: " << it->product_id_ <<
boost::mutex device_mutex_
std::string getSerial(const std::string &device_URI) const
boost::shared_ptr< AstraDevice > getDevice(const std::string &device_URI)
boost::shared_ptr< std::vector< AstraDeviceInfo > > getConnectedDeviceInfos() const
virtual void onDeviceConnected(const openni::DeviceInfo *pInfo)
static Status addDeviceConnectedListener(DeviceConnectedListener *pListener)
static void enumerateDevices(Array< DeviceInfo > *deviceInfoList)
#define THROW_OPENNI_EXCEPTION(format,...)
bool operator()(const AstraDeviceInfo &di1, const AstraDeviceInfo &di2)
boost::shared_ptr< std::vector< AstraDeviceInfo > > getConnectedDeviceInfos()
static void removeDeviceConnectedListener(DeviceConnectedListener *pListener)
static Status addDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Status getProperty(int propertyId, void *data, int *dataSize) const
static Status initialize()
std::size_t getNumOfConnectedDevices()
boost::shared_ptr< AstraDevice > getAnyDevice()
boost::shared_ptr< std::vector< std::string > > getConnectedDeviceURIs()
static void removeDeviceStateChangedListener(DeviceStateChangedListener *pListener)
boost::shared_ptr< std::vector< std::string > > getConnectedDeviceURIs() const
static void removeDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
static const char * getExtendedError()
virtual ~AstraDeviceManager()
Status open(const char *uri)
static boost::shared_ptr< AstraDeviceManager > getSingelton()
std::ostream & operator<<(std::ostream &stream, const AstraDevice &device)
const char * getUri() const
static boost::shared_ptr< AstraDeviceManager > singelton_
const AstraDeviceInfo astra_convert(const openni::DeviceInfo *pInfo)
virtual void onDeviceStateChanged(const openni::DeviceInfo *pInfo, openni::DeviceState state)
std::set< AstraDeviceInfo, AstraDeviceInfoComparator > DeviceSet
virtual void onDeviceDisconnected(const openni::DeviceInfo *pInfo)
std::size_t getNumOfConnectedDevices() const
static Status addDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)