bool HapticDeviceWrapper::open(Searchable &config)
{
    portStemName=config.check("name",
                              Value(HAPTICDEVICE_WRAPPER_DEFAULT_NAME)).asString().c_str();
    verbosity=config.check("verbosity",Value(0)).asInt();
    int period=config.check("period",
                            Value(HAPTICDEVICE_WRAPPER_DEFAULT_PERIOD)).asInt();
    setRate(period);

    if (config.check("subdevice"))
    {
        Property p(config.toString().c_str());
        p.setMonitor(config.getMonitor(),"subdevice");
        p.unput("device");
        p.put("device",config.find("subdevice").asString());

        if (driver.open(p))
        {
            IHapticDevice *d;
            driver.view(d);
            attach(d);
        }
        else
        {
            yError("*** Haptic Device Wrapper: failed to open the driver!");
            return false;
        }
    }

    if (verbosity>0)
        yInfo("*** Haptic Device Wrapper: opened");

    return true;
}
Пример #2
0
bool ServerSerial::open(Searchable& prop)
{
    verb = (prop.check("verbose",Value(0),"Specifies if the device is in verbose mode (0/1).").asInt())>0;
    if (verb)
        printf("running with verbose output\n");

    Value *name;
    if (prop.check("subdevice",name,"name of specific control device to wrap")) {
        printf("Subdevice %s\n", name->toString().c_str());
        if (name->isString()) {
            // maybe user isn't doing nested configuration
            Property p;
            p.setMonitor(prop.getMonitor(),
                            "subdevice"); // pass on any monitoring
            p.fromString(prop.toString());
            p.put("device",name->toString());
            poly.open(p);
        } else {
            Bottle subdevice = prop.findGroup("subdevice").tail();
            poly.open(subdevice);
        }
        if (!poly.isValid()) {
            printf("cannot make <%s>\n", name->toString().c_str());
        }
    } else {
        printf("\"--subdevice <name>\" not set for server_serial\n");
        return false;
    }

    if (!poly.isValid()) {
        return false;
    }

    ConstString rootName =
        prop.check("name",Value("/serial"),
                    "prefix for port names").asString().c_str();

    command_buffer.attach(toDevice);
    reply_buffer.attach(fromDevice);

    command_buffer.useCallback(callback_impl);

    toDevice.open((rootName+"/in").c_str());
    fromDevice.open((rootName+"/out").c_str());



    if (poly.isValid())
        poly.view(serial);

    if(serial != NULL) {
        start();
        return true;
    }

    printf("subdevice <%s> doesn't look like a serial port (no appropriate interfaces were acquired)\n",
                    name->toString().c_str());

    return false;
}
Пример #3
0
bool JoypadControlServer::openAndAttachSubDevice(Searchable& prop)
{
    Property p;

    m_subDeviceOwned = new PolyDriver;

    p.fromString(prop.toString().c_str());
    p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
    p.unput("device");
    p.put("device",prop.find("subdevice").asString());  // subdevice was already checked before

    // if error occour during open, quit here.
    m_subDeviceOwned->open(p);

    if (!m_subDeviceOwned->isValid())
    {
        yError("JoypadControlServer: opening subdevice... FAILED\n");
        return false;
    }
    m_isSubdeviceOwned = true;
    if(!attach(m_subDeviceOwned))
        return false;

    if(!m_parser.configure(m_device) )
    {
        yError() << "JoypadControlServer: error configuring interfaces for parsers";
        return false;
    }

    openPorts();
    PeriodicThread::setPeriod(m_period);
    return PeriodicThread::start();
}
Пример #4
0
bool RGBDSensorWrapper::openAndAttachSubDevice(Searchable& prop)
{
    Property p;
    subDeviceOwned = new PolyDriver;
    p.fromString(prop.toString().c_str());

    p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
    p.unput("device");
    p.put("device",prop.find("subdevice").asString());  // subdevice was already checked before

    // if error occour during open, quit here.
    yDebug("opening IRGBDSensor subdevice\n");
    subDeviceOwned->open(p);

    if (!subDeviceOwned->isValid())
    {
        yError("opening controlBoardWrapper2 subdevice... FAILED\n");
        return false;
    }
    isSubdeviceOwned = true;
    if(!attach(subDeviceOwned))
        return false;

    RateThread::setRate(rate);
    RateThread::start();
    return true;
}
Пример #5
0
bool RGBDSensorWrapper::openAndAttachSubDevice(Searchable& prop)
{
    Property p;
    subDeviceOwned = new PolyDriver;
    p.fromString(prop.toString().c_str());

    p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
    p.unput("device");
    p.put("device",prop.find("subdevice").asString());  // subdevice was already checked before

    // if error occour during open, quit here.
    yDebug("opening IRGBDSensor subdevice\n");
    subDeviceOwned->open(p);

    if (!subDeviceOwned->isValid())
    {
        yError("opening controlBoardWrapper2 subdevice... FAILED\n");
        return false;
    }
    isSubdeviceOwned = true;
    if(!attach(subDeviceOwned))
        return false;

    // Configuring parsers
    IRgbVisualParams * rgbVis_p;
    IDepthVisualParams * depthVis_p;

    subDeviceOwned->view(rgbVis_p);
    subDeviceOwned->view(depthVis_p);

    if(!parser.configure(sensor_p) )
    {
        yError() << "RGBD wrapper: error configuring interfaces for parsers";
        return false;
    }
    /*
    bool conf = rgbParser.configure(rgbVis_p);
    conf &= depthParser.configure(depthVis_p);

    if(!conf)
    {
        yError() << "RGBD wrapper: error configuring interfaces for parsers";
        return false;
    }
    */

    RateThread::setRate(rate);
    RateThread::start();
    return true;
}
Пример #6
0
bool AcousticMap::open(Searchable& config) {

    bool ok = true;

    if(!config.check("name")) {
        std::cout << "AuditoryMap: Error, module base name not found in configuration. Start the module with the --name option.." << std::endl;
        return false;
    }

    // module base name
    std::string strModuleName = std::string(config.find("name").asString().c_str());

    // look for group EGO_SPHERE_ACOUSTIC_MAP
    Bottle botConfigAcoustic(config.toString().c_str());
    botConfigAcoustic.setMonitor(config.getMonitor());
    if (!config.findGroup("EGO_SPHERE_ACOUSTIC_MAP").isNull()) {
        botConfigAcoustic.clear();
        botConfigAcoustic.fromString(config.findGroup("EGO_SPHERE_ACOUSTIC_MAP", "Loading visual map configuration  from group EGO_SPHERE_ACOUSTIC_MAP.").toString());
    }

    _salienceDecayRate = botConfigAcoustic.check("decayAcoustic",
                         Value(0.95),
                         "Decay for the acoustic saliency map (double).").asDouble();
    _resXAcoustic = botConfigAcoustic.check("resXAcoustic",
                                            Value(80),
                                            "Width of internal acoustic map (int)").asInt();
    _resYAcoustic = botConfigAcoustic.check("resYAcoustic",
                                            Value(60),
                                            "Height of internal acoustic map (int)").asInt();
    _imgCart.resize(_resXAcoustic,_resYAcoustic);
    _imgRemapX.resize(_resXAcoustic,_resYAcoustic);
    _imgRemapY.resize(_resXAcoustic,_resYAcoustic);
    _imgSpher.resize(_resXAcoustic,_resYAcoustic);
    _imgMapResA.resize(_resXAcoustic,_resYAcoustic);

    ok = ok && _prtVctSound.open(std::string(strModuleName + std::string("/mapAuditory/vct_in")).c_str());

    return ok;
}