Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "passive_joints_widget.h"
00039
00040 #include <QFormLayout>
00041 #include <QMessageBox>
00042
00043 namespace moveit_setup_assistant
00044 {
00045
00046
00047
00048 PassiveJointsWidget::PassiveJointsWidget(QWidget* parent, moveit_setup_assistant::MoveItConfigDataPtr config_data)
00049 : SetupScreenWidget(parent), config_data_(config_data)
00050 {
00051
00052 QVBoxLayout* layout = new QVBoxLayout();
00053
00054
00055
00056 HeaderWidget* header = new HeaderWidget("Passive Joints", "Specify the set of passive joints (not actuated). Joint "
00057 "state is not expected to be published for these joints.",
00058 this);
00059 layout->addWidget(header);
00060
00061
00062 joints_widget_ = new DoubleListWidget(this, config_data_, "Joint Collection", "Joint", false);
00063 connect(joints_widget_, SIGNAL(selectionUpdated()), this, SLOT(selectionUpdated()));
00064 connect(joints_widget_, SIGNAL(previewSelected(std::vector<std::string>)), this,
00065 SLOT(previewSelectedJoints(std::vector<std::string>)));
00066
00067
00068 joints_widget_->title_->setText("");
00069
00070 joints_widget_->setColumnNames("Active Joints", "Passive Joints");
00071
00072 layout->addWidget(joints_widget_);
00073
00074
00075 this->setLayout(layout);
00076 }
00077
00078
00079
00080
00081 void PassiveJointsWidget::focusGiven()
00082 {
00083 joints_widget_->clearContents();
00084
00085
00086 const robot_model::RobotModelConstPtr& model = config_data_->getRobotModel();
00087
00088
00089 const std::vector<std::string>& joints = model->getJointModelNames();
00090
00091 if (joints.size() == 0)
00092 {
00093 QMessageBox::critical(this, "Error Loading", "No joints found for robot model");
00094 return;
00095 }
00096 std::vector<std::string> active_joints;
00097 for (std::size_t i = 0; i < joints.size(); ++i)
00098 if (model->getJointModel(joints[i])->getVariableCount() > 0)
00099 active_joints.push_back(joints[i]);
00100
00101
00102 joints_widget_->setAvailable(active_joints);
00103
00104 std::vector<std::string> passive_joints;
00105 for (std::size_t i = 0; i < config_data_->srdf_->passive_joints_.size(); ++i)
00106 passive_joints.push_back(config_data_->srdf_->passive_joints_[i].name_);
00107 joints_widget_->setSelected(passive_joints);
00108 }
00109
00110
00111
00112
00113 void PassiveJointsWidget::selectionUpdated()
00114 {
00115 config_data_->srdf_->passive_joints_.clear();
00116 for (int i = 0; i < joints_widget_->selected_data_table_->rowCount(); ++i)
00117 {
00118 srdf::Model::PassiveJoint pj;
00119 pj.name_ = joints_widget_->selected_data_table_->item(i, 0)->text().toStdString();
00120 config_data_->srdf_->passive_joints_.push_back(pj);
00121 }
00122 config_data_->changes |= MoveItConfigData::PASSIVE_JOINTS;
00123 }
00124
00125
00126
00127
00128 void PassiveJointsWidget::previewSelectedJoints(std::vector<std::string> joints)
00129 {
00130
00131 Q_EMIT unhighlightAll();
00132
00133 for (int i = 0; i < joints.size(); ++i)
00134 {
00135 const robot_model::JointModel* joint_model = config_data_->getRobotModel()->getJointModel(joints[i]);
00136
00137
00138 if (!joint_model)
00139 {
00140 continue;
00141 }
00142
00143
00144 const std::string link = joint_model->getChildLinkModel()->getName();
00145
00146 if (link.empty())
00147 {
00148 continue;
00149 }
00150
00151
00152 Q_EMIT highlightLink(link, QColor(255, 0, 0));
00153 }
00154 }
00155
00156 }