39 #include <QVBoxLayout>
40 #include <QHBoxLayout>
50 QVBoxLayout* layout =
new QVBoxLayout();
52 layout->setAlignment(Qt::AlignTop);
55 auto header =
new HeaderWidget(
"ros2_control URDF Modifications",
56 "This step can add the tags to the URDF required for interfacing with ros2_control. "
57 "See https://control.ros.org/ for more info.",
59 layout->addWidget(header);
60 content_widget_ =
new QWidget(
this);
61 layout->addWidget(content_widget_);
63 this->setLayout(layout);
66 QWidget* UrdfModificationsWidget::makeInterfacesBox(
const std::string& interface_type,
67 const std::vector<std::string>& available_interfaces,
68 const std::vector<std::string>& selected_interfaces,
71 QGroupBox* box =
new QGroupBox((interface_type +
" Interfaces").c_str(), parent);
72 QVBoxLayout* box_layout =
new QVBoxLayout(parent);
73 for (
const std::string& interface_name : available_interfaces)
75 QCheckBox* check =
new QCheckBox(interface_name.c_str(), parent);
76 box_layout->addWidget(check);
78 std::string key = interface_type[0] + interface_name;
79 check_boxes_[key] = check;
81 for (
const std::string& interface_name : selected_interfaces)
83 std::string key = interface_type[0] + interface_name;
84 check_boxes_[key]->setChecked(
true);
86 box->setLayout(box_layout);
93 qDeleteAll(content_widget_->children());
96 QVBoxLayout* layout =
new QVBoxLayout();
99 layout->addWidget(
new QLabel(
"All of the joints used by this MoveIt config have already been configured using\n"
100 "ros2_control, so there is no need to modify the URDF with ros2_control tags."));
101 content_widget_->setLayout(layout);
105 QWidget* interface_widget =
new QWidget(
this);
106 QHBoxLayout* interface_layout =
new QHBoxLayout();
111 interface_layout->addWidget(makeInterfacesBox(
"Command", available_interfaces.command_interfaces,
112 selected_interfaces.command_interfaces, interface_widget));
113 interface_layout->addWidget(makeInterfacesBox(
"State", available_interfaces.state_interfaces,
114 selected_interfaces.state_interfaces, interface_widget));
116 interface_widget->setLayout(interface_layout);
117 layout->addWidget(interface_widget);
119 btn_add_interfaces_ =
new QPushButton(
"Add interfaces");
120 connect(btn_add_interfaces_, SIGNAL(clicked()),
this, SLOT(addInterfaces()));
121 layout->addWidget(btn_add_interfaces_);
123 generated_text_widget_ =
new QTextEdit();
124 generated_text_widget_->setReadOnly(
true);
125 generated_text_widget_->setText(setup_step_.
getJointsXML().c_str());
126 layout->addWidget(generated_text_widget_);
127 content_widget_->setLayout(layout);
130 std::vector<std::string> UrdfModificationsWidget::getInterfaces(
const char first_letter,
131 const std::vector<std::string>& available_interfaces)
133 std::vector<std::string> interface_names;
134 for (
const std::string& interface_name : available_interfaces)
136 std::string key = first_letter + interface_name;
137 if (check_boxes_[key]->isChecked())
139 interface_names.push_back(interface_name);
142 return interface_names;
145 void UrdfModificationsWidget::addInterfaces()
148 setup_step_.
setInterfaces(getInterfaces(
'C', available_interfaces.command_interfaces),
149 getInterfaces(
'S', available_interfaces.state_interfaces));
150 generated_text_widget_->setText(setup_step_.
getJointsXML().c_str());
156 #include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
const ControlInterfaces & getDefaultControlInterfaces() const
std::string getJointsXML() const
bool needsModification() const
Return true if there aren't ros2_control tags for all the joints.
const ControlInterfaces & getAvailableControlInterfaces() const
void setInterfaces(const std::vector< std::string > &command_interfaces, const std::vector< std::string > &state_interfaces)
Add ros2_control tags for all unconfigured joints with the specified interfaces.