PyVoidHandle RegisterItemSelectionCallback(object fncallback)
 {
     if( !fncallback ) {
         throw openrave_exception("callback not specified");
     }
     boost::shared_ptr<void> p = _pviewer->RegisterItemSelectionCallback(boost::bind(&PyViewerBase::_ViewerCallback,fncallback,_pyenv,_1,_2,_3));
     if( !p ) {
         throw openrave_exception("no registration callback returned");
     }
     return PyVoidHandle(p);
 }
 object GetCameraImage(int width, int height, object extrinsic, object oKK)
 {
     vector<float> vKK = ExtractArray<float>(oKK);
     if( vKK.size() != 4 ) {
         throw openrave_exception("KK needs to be of size 4");
     }
     SensorBase::CameraIntrinsics KK(vKK[0],vKK[1],vKK[2],vKK[3]);
     vector<uint8_t> memory;
     if( !_pviewer->GetCameraImage(memory, width,height,RaveTransform<float>(ExtractTransform(extrinsic)), KK) ) {
         throw openrave_exception("failed to get camera image");
     }
     std::vector<npy_intp> dims(3); dims[0] = height; dims[1] = width; dims[2] = 3;
     return toPyArray(memory,dims);
 }
Ejemplo n.º 3
0
 VideoGlobalState() {
     /* first let's make sure we are running on 1.1 */
     WORD wVer = HIWORD(VideoForWindowsVersion());
     if (wVer < 0x010a) {
         throw openrave_exception("can't init avi library");
     }
     AVIFileInit();
 }
Ejemplo n.º 4
0
void InterfaceBase::Clone(InterfaceBaseConstPtr preference, int cloningoptions)
{
    if( !preference ) {
        throw openrave_exception("invalid cloning reference",ORE_InvalidArguments);
    }
    // cannot clone the user data since it can be environment dependent!
    //__mapUserData = preference->__mapUserData;
    __struri = preference->__struri;
    __mapReadableInterfaces = preference->__mapReadableInterfaces;
    __description = preference->__description;
}
Ejemplo n.º 5
0
int PlannerBase::PlannerParameters::SetStateValues(const std::vector<dReal>& values, int options) const
{
    if( !!_setstatevaluesfn ) {
        return _setstatevaluesfn(values, options);
    }
    if( !!_setstatefn ) {
        RAVELOG_VERBOSE("Using deprecated PlannerParameters::_setstatefn, please set _setstatevaluesfn instead");
        _setstatefn(values);
        return 0;
    }
    throw openrave_exception("need to set PlannerParameters::_setstatevaluesfn");
}
Ejemplo n.º 6
0
bool InterfaceBase::SendCommand(ostream& sout, istream& sinput)
{
    string cmd;
    sinput >> cmd;
    if( !sinput ) {
        throw openrave_exception("invalid command",ORE_InvalidArguments);
    }
    boost::shared_ptr<InterfaceCommand> interfacecmd;
    {
        boost::shared_lock< boost::shared_mutex > lock(_mutexInterface);
        CMDMAP::iterator it = __mapCommands.find(cmd);
        if( it == __mapCommands.end() ) {
            throw openrave_exception(str(boost::format("failed to find command '%s' in interface %s\n")%cmd.c_str()%GetXMLId()),ORE_CommandNotSupported);
        }
        interfacecmd = it->second;
    }
    if( !interfacecmd->fn(sout,sinput) ) {
        RAVELOG_VERBOSE(str(boost::format("command failed in interface %s: %s\n")%GetXMLId()%cmd));
        return false;
    }
    return true;
}
Ejemplo n.º 7
0
 virtual bool AttachController(ControllerBasePtr controller, const std::vector<int>& dofindices, int nControlTransformation)
 {
     boost::mutex::scoped_lock lock(_mutex);
     if( nControlTransformation && !!_ptransformcontroller ) {
         throw openrave_exception("controller already attached for transformation",ORE_InvalidArguments);
     }
     FOREACHC(it,dofindices) {
         if( !!_vcontrollersbydofs.at(*it) ) {
             throw openrave_exception(str(boost::format("controller already attached to dof %d")%*it));
         }
     }
     if( !controller->Init(_probot,dofindices,nControlTransformation) ) {
         return false;
     }
     if( nControlTransformation ) {
         _ptransformcontroller = controller;
     }
     FOREACHC(it,dofindices) {
         _vcontrollersbydofs.at(*it) = controller;
     }
     _listcontrollers.push_back(controller);
     return true;
 }