本文整理汇总了C++中yarp::os::Searchable::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Searchable::find方法的具体用法?C++ Searchable::find怎么用?C++ Searchable::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yarp::os::Searchable
的用法示例。
在下文中一共展示了Searchable::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
bool SerialDeviceDriver::open(yarp::os::Searchable& config) {
SerialDeviceDriverSettings config2;
strcpy(config2.CommChannel, config.check("comport",Value("COM3"),"name of the serial channel").asString().c_str());
this->verbose = (config.check("verbose",Value(1),"Specifies if the device is in verbose mode (0/1).").asInt())>0;
config2.SerialParams.baudrate = config.check("baudrate",Value(9600),"Specifies the baudrate at which the communication port operates.").asInt();
config2.SerialParams.xonlim = config.check("xonlim",Value(0),"Specifies the minimum number of bytes in input buffer before XON char is sent. Negative value indicates that default value should be used (Win32)").asInt();
config2.SerialParams.xofflim = config.check("xofflim",Value(0),"Specifies the maximum number of bytes in input buffer before XOFF char is sent. Negative value indicates that default value should be used (Win32). ").asInt();
//RANDAZ: as far as I undesrood, the exit condition for recv() function is NOT readmincharacters || readtimeoutmsec. It is readmincharacters && readtimeoutmsec.
//On Linux. if readmincharacters params is set !=0, recv() may still block even if readtimeoutmsec is expired.
//On Win32, for unknown reason, readmincharacters seems to be ignored, so recv () returns after readtimeoutmsec. Maybe readmincharacters is used if readtimeoutmsec is set to -1?
config2.SerialParams.readmincharacters = config.check("readmincharacters",Value(1),"Specifies the minimum number of characters for non-canonical read (POSIX).").asInt();
config2.SerialParams.readtimeoutmsec = config.check("readtimeoutmsec",Value(100),"Specifies the time to wait before returning from read. Negative value means infinite timeout.").asInt();
// config2.SerialParams.parityenb = config.check("parityenb",Value(0),"Enable/disable parity checking.").asInt();
yarp::os::ConstString temp = config.check("paritymode",Value("EVEN"),"Specifies the parity mode (EVEN, ODD, NONE). POSIX supports even and odd parity. Additionally Win32 supports mark and space parity modes.").asString().c_str();
config2.SerialParams.paritymode = temp.c_str();
config2.SerialParams.ctsenb = config.check("ctsenb",Value(0),"Enable & set CTS mode. Note that RTS & CTS are enabled/disabled together on some systems (RTS/CTS is enabled if either <code>ctsenb</code> or <code>rtsenb</code> is set).").asInt();
config2.SerialParams.rtsenb = config.check("rtsenb",Value(0),"Enable & set RTS mode. Note that RTS & CTS are enabled/disabled together on some systems (RTS/CTS is enabled if either <code>ctsenb</code> or <code>rtsenb</code> is set).\n- 0 = Disable RTS.\n- 1 = Enable RTS.\n- 2 = Enable RTS flow-control handshaking (Win32).\n- 3 = Specifies that RTS line will be high if bytes are available for transmission.\nAfter transmission RTS will be low (Win32).").asInt();
config2.SerialParams.xinenb = config.check("xinenb",Value(0),"Enable/disable software flow control on input.").asInt();
config2.SerialParams.xoutenb = config.check("xoutenb",Value(0),"Enable/disable software flow control on output.").asInt();
config2.SerialParams.modem = config.check("modem",Value(0),"Specifies if device is a modem (POSIX). If not set modem status lines are ignored. ").asInt();
config2.SerialParams.rcvenb = config.check("rcvenb",Value(0),"Enable/disable receiver (POSIX).").asInt();
config2.SerialParams.dsrenb = config.check("dsrenb",Value(0),"Controls whether DSR is disabled or enabled (Win32).").asInt();
config2.SerialParams.dtrdisable = config.check("dtrdisable",Value(0),"Controls whether DTR is disabled or enabled.").asInt();
config2.SerialParams.databits = config.check("databits",Value(7),"Data bits. Valid values 5, 6, 7 and 8 data bits. Additionally Win32 supports 4 data bits.").asInt();
config2.SerialParams.stopbits = config.check("stopbits",Value(1),"Stop bits. Valid values are 1 and 2.").asInt();
if (config.check("line_terminator_char1", "line terminator character for receiveLine(), default '\r'"))
line_terminator_char1 = config.find("line_terminator_char1").asInt();
if (config.check("line_terminator_char2", "line terminator character for receiveLine(), default '\n'"))
line_terminator_char2 = config.find("line_terminator_char2").asInt();
return open(config2);
}
示例2: printf
bool yarp::dev::OpenNI2DeviceDriverClient::open(yarp::os::Searchable& config){
string localPortPrefix,remotePortPrefix;
inUserSkeletonPort = outPort = NULL;
skeletonData = new OpenNI2SkeletonData();
if(config.check("localName")) localPortPrefix = config.find("localName").asString();
else {
printf("\t- Error: localName element not found in PolyDriver.\n");
return false;
}
if(config.check("remoteName")) remotePortPrefix = config.find("remoteName").asString();
else {
printf("\t- Error: remoteName element not found in PolyDriver.\n");
return false;
}
string remotePortIn = remotePortPrefix+":i";
if(!NetworkBase::exists(remotePortIn.c_str())){
printf("\t- Error: remote port not found. (%s)\n\t Check if OpenNI2DeviceDriverServer is running.\n",remotePortIn.c_str());
return false;
}
if(!connectPorts(remotePortPrefix,localPortPrefix)) {
printf("\t- Error: Could not connect or create ports.\n");
return false;
}
inUserSkeletonPort->useCallback(*this);
inDepthFramePort->useCallback(*this);
inImageFramePort->useCallback(*this);
return true;
}
示例3: open
bool BatteryWrapper::open(yarp::os::Searchable &config)
{
Property params;
params.fromString(config.toString().c_str());
if (!config.check("period"))
{
yError() << "BatteryWrapper: missing 'period' parameter. Check you configuration file\n";
return false;
}
else
_rate = config.find("period").asInt();
if (!config.check("name"))
{
yError() << "BatteryWrapper: missing 'name' parameter. Check you configuration file; it must be like:";
yError() << " name: full name of the port, like /robotName/deviceId/sensorType:o";
return false;
}
else
{
streamingPortName = config.find("name").asString().c_str();
rpcPortName = streamingPortName + "/rpc:i";
setId("batteryWrapper");
}
if(!initialize_YARP(config) )
{
yError() << sensorId << "Error initializing YARP ports";
return false;
}
return true;
}
示例4: yError
bool yarp::dev::LocationsServer::open(yarp::os::Searchable &config)
{
m_local_name.clear();
m_local_name = config.find("local").asString().c_str();
m_ros_enabled = false;
if (m_local_name == "")
{
yError("LocationsServer::open() error you have to provide valid local name");
return false;
}
if (config.check("ROS_enabled"))
{
m_ros_enabled = true;
m_rosNode = new yarp::os::Node("/LocationServer");
m_rosPublisherPort.topic("/locationServerMarkers");
}
if (config.check("locations_file"))
{
std::string location_file = config.find("locations_file").asString();
bool ret = load_locations(location_file);
if (ret) { yInfo() << "Location file" << location_file << "successfully loaded."; }
else { yError() << "Problems opening file" << location_file; }
}
if (config.check("period"))
{
m_period = config.find("period").asInt();
}
else
{
m_period = 10;
yWarning("LocationsServer: using default period of %d ms" , m_period);
}
ConstString local_rpc = m_local_name;
local_rpc += "/rpc";
if (!m_rpc_port.open(local_rpc.c_str()))
{
yError("LocationsServer::open() error could not open rpc port %s, check network", local_rpc.c_str());
return false;
}
m_rpc_port.setReader(*this);
return true;
}
示例5: open
bool JoypadControlClient::open(yarp::os::Searchable& config)
{
if(config.check("help"))
{
yInfo() << "parameter:\n\n" <<
"local - prefix of the local port\n" <<
"remote - prefix of the port provided to and opened by JoypadControlServer\n";
}
if(!config.check("local"))
{
yError() << "JoypadControlClient: unable to 'local' parameter.. check configuration file";
return false;
}
m_local = config.find("local").asString();
if(!m_rpcPort.open(m_local + "/rpc:o"))
{
yError() << "JoypadControlClient: unable to open rpc port..";
return false;
}
yInfo() << "rpc port opened.. starting the handshake";
if(!config.check("remote"))
{
yError() << "JoypadControlClient: unable to find the 'remote' parameter.. check configuration file";
return false;
}
m_remote = config.find("remote").asString();
if(!yarp::os::NetworkBase::connect(m_local + "/rpc:o", m_remote + "/rpc:i"))
{
yError() << "handshake failed.. unable to connect to remote port" << m_remote + "/rpc:i";
return false;
}
yInfo() << "handshake succeded! retrieving info";
if(!getJoypadInfo())
{
yError() << "unable to get joypad info..";
return false;
}
watchdog.start();
return true;
}
示例6:
bool DynamixelAX12::configure(yarp::os::Searchable &config)
{
yarp::os::Value indexValue = config.find("SENSORINDEX");
yarp::os::Bottle *indexBottle = indexValue.asList();
this->initMotorIndex(indexBottle);
return true;
}
示例7: open
//DEVICE DRIVER
bool GazeboYarpLaserSensorDriver::open(yarp::os::Searchable& config)
{
yarp::os::LockGuard guard(m_mutex);
//Get gazebo pointers
std::string sensorScopedName(config.find(YarpLaserSensorScopedName.c_str()).asString().c_str());
m_parentSensor = dynamic_cast<gazebo::sensors::RaySensor*>(GazeboYarpPlugins::Handler::getHandler()->getSensor(sensorScopedName));
if (!m_parentSensor)
{
yError() << "Error, sensor" << sensorScopedName << "was not found" ;
return false ;
}
//Connect the driver to the gazebo simulation
this->m_updateConnection = gazebo::event::Events::ConnectWorldUpdateBegin(boost::bind(&GazeboYarpLaserSensorDriver::onUpdate, this, _1));
m_max_angle = m_parentSensor->AngleMax().Degree();
m_min_angle = m_parentSensor->AngleMin().Degree();
m_max_range = m_parentSensor->RangeMax();
m_min_range = m_parentSensor->RangeMin();
m_samples = m_parentSensor->RangeCount();
m_rate = m_parentSensor->UpdateRate();
m_sensorData.resize(m_samples, 0.0);
m_enable_clip_range = false;
return true;
}
示例8: sensorScopedName
bool yarp::dev::GazeboYarpMultiCameraDriver::open(yarp::os::Searchable& config)
{
//Get gazebo pointers
std::string sensorScopedName(config.find(YarpScopedName.c_str()).asString().c_str());
m_parentSensor = (gazebo::sensors::MultiCameraSensor*)GazeboYarpPlugins::Handler::getHandler()->getSensor(sensorScopedName);
if (!m_parentSensor) {
yError() << "GazeboYarpMultiCameraDriver Error: camera sensor was not found";
return false;
}
m_vertical_flip = config.check("vertical_flip");
m_horizontal_flip = config.check("horizontal_flip");
m_display_timestamp = config.check("display_timestamp");
m_display_time_box = config.check("display_time_box");
m_vertical = config.check("vertical");
#if GAZEBO_MAJOR_VERSION >= 7
m_camera_count = this->m_parentSensor->CameraCount();
#else
m_camera_count = this->m_parentSensor->GetCameraCount();
#endif
for (unsigned int i = 0; i < m_camera_count; ++i) {
#if GAZEBO_MAJOR_VERSION >= 7
m_camera.push_back(m_parentSensor->Camera(i));
#else
m_camera.push_back(m_parentSensor->GetCamera(i));
#endif
if(m_camera[i] == NULL) {
yError() << "GazeboYarpMultiCameraDriver: camera" << i << "pointer is not valid";
return false;
}
#if GAZEBO_MAJOR_VERSION >= 7
m_width.push_back(m_camera[i]->ImageWidth());
m_height.push_back(m_camera[i]->ImageHeight());
#else
m_width.push_back(m_camera[i]->GetImageWidth());
m_height.push_back(m_camera[i]->GetImageHeight());
#endif
m_max_width = std::max(m_max_width, m_width[i]);
m_max_height = std::max(m_max_height, m_height[i]);
m_bufferSize.push_back(3 * m_width[i] * m_height[i]);
m_dataMutex.push_back(new yarp::os::Semaphore());
m_dataMutex[i]->wait();
m_imageBuffer.push_back(new unsigned char[m_bufferSize[i]]);
memset(m_imageBuffer[i], 0x00, m_bufferSize[i]);
m_dataMutex[i]->post();
m_lastTimestamp.push_back(yarp::os::Stamp());
}
// Connect all the cameras only when everything is set up
for (unsigned int i = 0; i < m_camera_count; ++i) {
this->m_updateConnection.push_back(this->m_camera[i]->ConnectNewImageFrame(boost::bind(&yarp::dev::GazeboYarpMultiCameraDriver::captureImage, this, i, _1, _2, _3, _4, _5)));
}
return true;
}
示例9: open
//DEVICE DRIVER
bool GazeboYarpForceTorqueDriver::open(yarp::os::Searchable& config)
{
std::cout << "GazeboYarpForceTorqueDriver::open() called" << std::endl;
m_dataMutex.wait();
m_forceTorqueData.resize(YarpForceTorqueChannelsNumber, 0.0);
m_dataMutex.post();
//Get gazebo pointers
std::string sensorScopedName(config.find(YarpScopedName.c_str()).asString().c_str());
std::cout << "GazeboYarpForceTorqueDriver::open is looking for sensor " << sensorScopedName << "..." << std::endl;
m_parentSensor = (gazebo::sensors::ForceTorqueSensor*)GazeboYarpPlugins::Handler::getHandler()->getSensor(sensorScopedName);
if (!m_parentSensor)
{
std::cout << "Error, ForceTorque sensor was not found" << std::endl;
return AS_ERROR;
}
//Connect the driver to the gazebo simulation
this->m_updateConnection = gazebo::event::Events::ConnectWorldUpdateBegin(boost::bind(&GazeboYarpForceTorqueDriver::onUpdate, this, _1));
std::cout << "GazeboYarpForceTorqueDriver::open() returning true" << std::endl;
return true;
}
示例10: checkRequiredParamIsVectorOfString
// \todo TODO bug ?
bool checkRequiredParamIsVectorOfString(yarp::os::Searchable& config,
const std::string& paramName,
std::vector<std::string> & output_vector)
{
bool correct = !(config.findGroup(paramName).isNull());
if( correct )
correct = true;
{
Bottle ids = config.findGroup(paramName).tail();
std::cout << "ids : " << ids.toString() << std::endl;
std::cout << "ids : " << config.find(paramName).toString() << std::endl;
output_vector.resize(ids.size());
for(int i = 0; i < ids.size(); i++ )
{
output_vector[i] = ids.get(i).asString().c_str();
}
}
if( !correct )
{
yError("CanBusInertialMTB: problem loading parameter %s as vector of string",paramName.c_str());
}
return correct;
}
示例11: open
bool BmsBattery::open(yarp::os::Searchable& config)
{
bool correct=true;
//debug
yDebug("%s\n", config.toString().c_str());
Bottle& group_general = config.findGroup("GENERAL");
Bottle& group_serial = config.findGroup("SERIAL_PORT");
if (group_general.isNull())
{
yError() << "Insufficient parameters to BmsBattery, section GENERAL missing";
return false;
}
if (group_serial.isNull())
{
yError() << "Insufficient parameters to BmsBattery, section SERIAL_PORT missing";
return false;
}
int period=config.find("thread_period").asInt();
setRate(period);
Property prop;
std::string ps = group_serial.toString();
prop.fromString(ps);
prop.put("device", "serialport");
//open the driver
driver.open(prop);
if (!driver.isValid())
{
yError() << "Error opening PolyDriver check parameters";
#ifndef DEBUG_TEST
return false;
#endif
}
//open the serial interface
driver.view(pSerial);
if (!pSerial)
{
yError("Error opening serial driver. Device not available");
#ifndef DEBUG_TEST
return false;
#endif
}
// Other options
this->logEnable = group_general.check("logToFile", Value(0), "enable / disable the log to file").asBool();
this->verboseEnable = group_general.check("verbose", Value(0), "enable/disable the verbose mode").asBool();
this->screenEnable = group_general.check("screen", Value(0), "enable/disable the screen output").asBool();
this->debugEnable = group_general.check("debug", Value(0), "enable/disable the debug mode").asBool();
this->shutdownEnable = group_general.check("shutdown", Value(0), "enable/disable the automatic shutdown").asBool();
RateThread::start();
return true;
}
示例12: yError
bool yarp::dev::Map2DClient::open(yarp::os::Searchable &config)
{
m_local_name.clear();
m_map_server.clear();
m_local_name = config.find("local").asString().c_str();
m_map_server = config.find("remote").asString().c_str();
if (m_local_name == "")
{
yError("Map2DClient::open() error you have to provide valid local name");
return false;
}
if (m_map_server == "")
{
yError("Map2DClient::open() error you have to provide valid remote name");
return false;
}
std::string local_rpc1 = m_local_name;
local_rpc1 += "/mapClient_rpc";
std::string remote_rpc1 = m_map_server;
remote_rpc1 += "/rpc";
if (!m_rpcPort_to_Map2DServer.open(local_rpc1.c_str()))
{
yError("Map2DClient::open() error could not open rpc port %s, check network", local_rpc1.c_str());
return false;
}
bool ok=false;
ok=Network::connect(local_rpc1.c_str(), remote_rpc1.c_str());
if (!ok)
{
yError("Map2DClient::open() error could not connect to %s", remote_rpc1.c_str());
return false;
}
return true;
}
示例13: KinectSkeletonData
bool yarp::dev::KinectDeviceDriverClient::open(yarp::os::Searchable& config){
string localPortPrefix,remotePortPrefix;
_inUserSkeletonPort = _outPort = NULL;
_skeletonData = new KinectSkeletonData();
if(config.check("localPortPrefix")) localPortPrefix = config.find("localPortPrefix").asString();
else {
printf("\t- Error: localPortPrefix element not found in PolyDriver.\n");
return false;
}
if(config.check("remotePortPrefix")) remotePortPrefix = config.find("remotePortPrefix").asString();
else {
printf("\t- Error: remotePortPrefix element not found in PolyDriver.\n");
return false;
}
Network yarp;
string remotePortIn = remotePortPrefix+":i";
if(!yarp.exists(remotePortIn.c_str())){
printf("\t- Error: remote port not found. (%s)\n\t Check if KinectDeviceDriverServer is running.\n",remotePortIn.c_str());
return false;
}
if(!connectPorts(remotePortPrefix,localPortPrefix)) {
printf("\t- Error: Could not connect or create ports.\n");
return false;
}
//_portMod = new PortCtrlMod();
//_portMod->setInterfaceDriver(this);
_inUserSkeletonPort->useCallback(*this);
_inDepthMapPort->useCallback(*this);
_inImageMapPort->useCallback(*this);
return true;
}
示例14: checkRequiredParamIsInt
bool checkRequiredParamIsInt(yarp::os::Searchable& config,
const std::string& paramName)
{
bool correct = config.check(paramName);
if( correct )
{
correct = config.find(paramName).isInt();
}
if( !correct )
{
yError("CanBusInertialMTB: problem loading parameter %s as int",paramName.c_str());
}
return correct;
}
示例15: open
bool YarpJointDev::open ( yarp::os::Searchable& config ) {
yarp::os::Value partName = config.find ( "part" );
if ( partName.isNull() || !partName.isString() )
return false;
_chain = boost::shared_ptr<NaoJointChain> (
new NaoJointChain ( std::string ( partName.asString() ) ) );
/// Initializing trajectory speeds to max speed.
for ( unsigned i = 0; i < _chain->GetNumberOfJoints(); ++i )
_refSpeeds.push_back ( 1.0f );
_maxRefSpeed = 1.0f;
return true;
}