int main()
{
     pthread_t hOutput;
     int msqid;

     if	(InitializeConnections(&hOutput, &msqid)) {
          perror("Error in initialization");
          return 1;
     }

     if (master) {
          pthread_mutex_lock(&count_mutex);
          pthread_cond_wait(&count_threshold_cv, &count_mutex);
          pthread_mutex_unlock(&count_mutex);

          HandleMasterInput(hOutput, msqid);
     } else {
          HandleSlaveInput(msqid);
     }


     // cleaning up
     if (master) {
          pthread_join(hOutput, NULL);
          msgctl(msqid, IPC_RMID, NULL);
          pthread_mutex_destroy(&count_mutex);
          pthread_cond_destroy(&count_threshold_cv);
     }

     return 0;
}
Exemplo n.º 2
0
    void TerrainWeightEditor::Initialize()
    {
        if (fw_->IsHeadless())
            return;

        QUiLoader loader;
        loader.setLanguageChangeEnabled(true);
        QString str("./data/ui/terrainwtex_editor.ui");
        QFile file(str);
        if(!file.exists())
        {
            EnvironmentModule::LogError("Cannot find " +str.toStdString()+ " file");
            return;
        }

        editor_widget_ = loader.load(&file, this);
        if (editor_widget_ == 0)
            return;

//        UiProxyWidget *editor_proxy = fw_->Ui()->AddWidgetToScene(this);
//        if (editor_proxy == 0)
//            return;

//        ui->AddWidgetToMenu(this, tr("Terrain Texture Weightmap Editor"));
//        ui->RegisterUniversalWidget("Weights", editor_proxy);

        QSpinBox *box = editor_widget_->findChild<QSpinBox*>("brush_size");
        if(box)
        {
            brush_size_max_ = box->maximum();
            brush_size_ = box->value();
        }
        box = editor_widget_->findChild<QSpinBox*>("brush_modifier");
        if(box)
            brush_modifier_ = box->maximum();

        QDoubleSpinBox *dbox = editor_widget_->findChild<QDoubleSpinBox*>("brush_falloff");
        if(dbox)
            falloff_percentage_ = dbox->value();

        InitializeCanvases();
        InitializeConnections();
        emit BrushValueChanged();
    }
Exemplo n.º 3
0
/// Controller initialization in non-realtime
bool PR2JointController::init(pr2_mechanism_model::RobotState *robot,
                            ros::NodeHandle &nh)
{
    m_node = nh;
    
    //Initialize connections to other nodes through topics/services
    if (!InitializeConnections())
    {
        ROS_ERROR("PR2JointController could not connect to topics");
        return false;
    }

    if (!ConnectArmJoints(robot))
    {
        ROS_ERROR("PR2JointController could not initialize joint states");
        return false;
    }

    m_dblRUpperArmRollJointEffort = 0;
    m_dblRShoulderPanJointEffort = 0;
    m_dblRShoulderLiftJointEffort = 0;
    m_dblRForearmRollJointEffort = 0;
    m_dblRElbowFlexJointEffort = 0;
    m_dblRWristFlexJointEffort = 0;
    m_dblRWristRollJointEffort = 0;
    
    m_dblLUpperArmRollJointEffort = 0;
    m_dblLShoulderPanJointEffort = 0;
    m_dblLShoulderLiftJointEffort = 0;
    m_dblLForearmRollJointEffort = 0;
    m_dblLElbowFlexJointEffort = 0;
    m_dblLWristFlexJointEffort = 0;
    m_dblLWristRollJointEffort = 0;
    
    m_dblHeadPanJointEffort = 0;
    m_dblHeadTiltJointEffort = 0;

    return true;
}