Exemplo n.º 1
0
// ******************************************************************************************
// Called when setup assistant navigation switches to this screen
// ******************************************************************************************
void VirtualJointsWidget::focusGiven()
{
  // Show the current vjoints screen
  stacked_layout_->setCurrentIndex( 0 );

  // Load the data to the tree
  loadDataTable();

  // Load the avail groups to the combo box
  loadChildLinksComboBox();

}
// ******************************************************************************************
// Called when setup assistant navigation switches to this screen
// ******************************************************************************************
void EndEffectorsWidget::focusGiven()
{
  // Show the current effectors screen
  stacked_layout_->setCurrentIndex( 0 );

  // Load the data to the tree
  loadDataTable();

  // Load the avail groups to the combo box
  loadGroupsComboBox();
  loadParentComboBox();
}
Exemplo n.º 3
0
// ******************************************************************************************
// Delete currently editing item
// ******************************************************************************************
void VirtualJointsWidget::deleteSelected()
{
  // Get list of all selected items
  QList<QTableWidgetItem*> selected = data_table_->selectedItems();

  // Check that an element was selected
  if( !selected.size() )
    return;

  // Get selected name and edit it
  current_edit_vjoint_ = selected[0]->text().toStdString();

  // Confirm user wants to delete group
  if( QMessageBox::question( this, "Confirm Virtual Joint Deletion",
                             QString("Are you sure you want to delete the virtual joint '")
                             .append( current_edit_vjoint_.c_str() )
                             .append( "'?" ),
                             QMessageBox::Ok | QMessageBox::Cancel)
      == QMessageBox::Cancel )
  {
    return;
  }

  // Delete vjoint from vector
  for( std::vector<srdf::Model::VirtualJoint>::iterator vjoint_it = config_data_->srdf_->virtual_joints_.begin();
       vjoint_it != config_data_->srdf_->virtual_joints_.end(); ++vjoint_it )
  {
    // check if this is the group we want to delete
    if( vjoint_it->name_ == current_edit_vjoint_ ) // string match
    {
      config_data_->srdf_->virtual_joints_.erase( vjoint_it );
      break;
    }
  }

  // Reload main screen table
  loadDataTable();

}
Exemplo n.º 4
0
// ******************************************************************************************
// Save editing changes
// ******************************************************************************************
void VirtualJointsWidget::doneEditing()
{
  // Get a reference to the supplied strings
  const std::string vjoint_name = vjoint_name_field_->text().toStdString();
  const std::string parent_name = parent_name_field_->text().toStdString();

  // Used for editing existing groups
  srdf::Model::VirtualJoint *searched_data = NULL;

  // Check that name field is not empty
  if( vjoint_name.empty() )
  {
    QMessageBox::warning( this, "Error Saving", "A name must be given for the virtual joint!" );
    return;
  }

  // Check that parent frame name field is not empty
  if( parent_name.empty() )
  {
    QMessageBox::warning( this, "Error Saving", "A name must be given for the parent frame" );
    return;
  }

  // Check if this is an existing vjoint
  if( !current_edit_vjoint_.empty() )
  {
    // Find the group we are editing based on the goup name string
    searched_data = findVJointByName( current_edit_vjoint_ );
  }

  // Check that the vjoint name is unique
  for( std::vector<srdf::Model::VirtualJoint>::const_iterator data_it = config_data_->srdf_->virtual_joints_.begin();
       data_it != config_data_->srdf_->virtual_joints_.end();  ++data_it )
  {
    if( data_it->name_.compare( vjoint_name ) == 0 ) // the names are the same
    {
      // is this our existing vjoint? check if vjoint pointers are same
      if( &(*data_it) != searched_data )
      {
        QMessageBox::warning( this, "Error Saving", "A virtual joint already exists with that name!" );
        return;
      }
    }
  }

  // Check that a joint type was selected
  if( joint_type_field_->currentText().isEmpty() )
  {
    QMessageBox::warning( this, "Error Saving", "A joint type must be chosen!" );
    return;
  }

  // Check that a child link was selected
  if( child_link_field_->currentText().isEmpty() )
  {
    QMessageBox::warning( this, "Error Saving", "A child link must be chosen!" );
    return;
  }

  // Save the new vjoint name or create the new vjoint ----------------------------
  bool isNew = false;

  if( searched_data == NULL ) // create new
  {
    isNew = true;

    searched_data = new srdf::Model::VirtualJoint();
  }

  // Copy name data ----------------------------------------------------
  searched_data->name_ = vjoint_name;
  searched_data->parent_frame_ = parent_name;
  searched_data->child_link_ = child_link_field_->currentText().toStdString();
  searched_data->type_ = joint_type_field_->currentText().toStdString();

  bool emit_frame_notice = false;

  // Insert new vjoints into group state vector --------------------------
  if( isNew )
  {
    if (searched_data->child_link_ == config_data_->getRobotModel()->getRootLinkName())
      emit_frame_notice = true;
    config_data_->srdf_->virtual_joints_.push_back( *searched_data );
    config_data_->updateRobotModel();
  }

  // Finish up ------------------------------------------------------

  // Reload main screen table
  loadDataTable();

  // Switch to screen
  stacked_layout_->setCurrentIndex( 0 );

  // Announce that this widget is not in modal mode
  Q_EMIT isModal( false );

  // if the root frame changed for the robot, emit the signal
  if (emit_frame_notice)
  {
    Q_EMIT referenceFrameChanged();
  }
}
Exemplo n.º 5
0
void EvalMainWindow::onActionLoadDataTable()
{
  emit loadDataTable();
}
// ******************************************************************************************
// Save editing changes
// ******************************************************************************************
void EndEffectorsWidget::doneEditing()
{
  // Get a reference to the supplied strings
  const std::string effector_name = effector_name_field_->text().toStdString();

  // Used for editing existing groups
  srdf::Model::EndEffector *searched_data = NULL;

  // Check that name field is not empty
  if( effector_name.empty() )
  {
    QMessageBox::warning( this, "Error Saving", "A name must be specified for the end effector!" );
    return;    
  }

  // Check if this is an existing group
  if( !current_edit_effector_.empty() )
  {
    // Find the group we are editing based on the goup name string
    searched_data = findEffectorByName( current_edit_effector_ );
  }
  
  // Check that the effector name is unique
  for( std::vector<srdf::Model::EndEffector>::const_iterator data_it = config_data_->srdf_->end_effectors_.begin(); 
       data_it != config_data_->srdf_->end_effectors_.end();  ++data_it )
  {
    if( data_it->name_.compare( effector_name ) == 0 ) // the names are the same
    {
      // is this our existing effector? check if effector pointers are same
      if( &(*data_it) != searched_data )
      {
        QMessageBox::warning( this, "Error Saving", QString("An end-effector named '").append(effector_name.c_str()).append("'already exists!") );
        return;
      }
    }
  }

  // Check that a group was selected
  if( group_name_field_->currentText().isEmpty() )
  {
    QMessageBox::warning( this, "Error Saving", "A group that contains the links of the end-effector must be chosen!" );
    return;    
  }
  
  // Check that a parent link was selected
  if( parent_name_field_->currentText().isEmpty() )
  {
    QMessageBox::warning( this, "Error Saving", "A parent link must be chosen!" );
    return;    
  }

  const robot_model::JointModelGroup *jmg =
    config_data_->getRobotModel()->getJointModelGroup(group_name_field_->currentText().toStdString());
  if (jmg->hasLinkModel(parent_name_field_->currentText().toStdString()))
  {  
    QMessageBox::warning( this, "Error Saving", QString::fromStdString("Group " + group_name_field_->currentText().toStdString() + " contains the link " + parent_name_field_->currentText().toStdString() + ". However, the parent link of the end-effector should not belong to the group for the end-effector itself."));
    return;    
  }
  
  if (!parent_group_name_field_->currentText().isEmpty())
  {
    jmg = config_data_->getRobotModel()->getJointModelGroup(parent_group_name_field_->currentText().toStdString());
    if (!jmg->hasLinkModel(parent_name_field_->currentText().toStdString()))
    {  
      QMessageBox::warning( this, "Error Saving", QString::fromStdString("The specified parent group '" + parent_group_name_field_->currentText().toStdString() + "' must contain the specified parent link '" + parent_name_field_->currentText().toStdString() + "'."));
      return;    
    }
  }
  
  // Save the new effector name or create the new effector ----------------------------
  bool isNew = false;

  if( searched_data == NULL ) // create new
  {
    isNew = true;

    searched_data = new srdf::Model::EndEffector();
  }

  // Copy name data ----------------------------------------------------
  searched_data->name_ = effector_name;
  searched_data->parent_link_ = parent_name_field_->currentText().toStdString();
  searched_data->component_group_ = group_name_field_->currentText().toStdString();
  searched_data->parent_group_ = parent_group_name_field_->currentText().toStdString();

  // Insert new effectors into group state vector --------------------------
  if( isNew )
  {
    config_data_->srdf_->end_effectors_.push_back( *searched_data );
  }

  // Finish up ------------------------------------------------------

  // Reload main screen table
  loadDataTable();

  // Switch to screen
  stacked_layout_->setCurrentIndex( 0 ); 

  // Announce that this widget is not in modal mode
  Q_EMIT isModal( false );
}