moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
passive_joints_widget.cpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2012, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Dave Coleman */
36
37// SA
40
41// Qt
42#include <QFormLayout>
43#include <QLabel>
44#include <QMessageBox>
45#include <QTableWidget>
46
47namespace moveit_setup
48{
49namespace srdf_setup
50{
51// ******************************************************************************************
52// Constructor
53// ******************************************************************************************
55{
56 // Basic widget container
57 QVBoxLayout* layout = new QVBoxLayout();
58
59 // Top Header Area ------------------------------------------------
60
61 auto header = new HeaderWidget(
62 "Define Passive Joints",
63 "Specify the set of passive joints (not actuated). Joint state is not expected to be published for these joints.",
64 this);
65 layout->addWidget(header);
66
67 // Joints edit widget
68 joints_widget_ = new DoubleListWidget(this, "Joint Collection", "Joint", false);
69 connect(joints_widget_, SIGNAL(selectionUpdated()), this, SLOT(selectionUpdated()));
70 connect(joints_widget_, SIGNAL(previewSelected(std::vector<std::string>)), this,
71 SLOT(previewSelectedJoints(std::vector<std::string>)));
72
73 // Set the title
74 joints_widget_->title_->setText("");
75
76 joints_widget_->setColumnNames("Active Joints", "Passive Joints");
77
78 layout->addWidget(joints_widget_);
79
80 // Finish Layout --------------------------------------------------
81 setLayout(layout);
82}
83
84// ******************************************************************************************
85//
86// ******************************************************************************************
88{
90
91 std::vector<std::string> active_joints = setup_step_.getActiveJoints();
92
93 if (active_joints.empty())
94 {
95 QMessageBox::critical(this, "Error Loading", "No joints found for robot model");
96 return;
97 }
98
99 // Set the available joints (left box)
100 joints_widget_->setAvailable(active_joints);
101
103}
104
105// ******************************************************************************************
106//
107// ******************************************************************************************
108void PassiveJointsWidget::selectionUpdated()
109{
111}
112
113// ******************************************************************************************
114// Called from Double List widget to highlight joints
115// ******************************************************************************************
116void PassiveJointsWidget::previewSelectedJoints(const std::vector<std::string>& joints)
117{
118 // Unhighlight all links
120
121 for (const std::string& joint : joints)
122 {
123 std::string link = setup_step_.getChildOfJoint(joint);
124 // Check that a joint model/link was found
125 if (link.empty())
126 {
127 continue;
128 }
129
130 // Highlight link
131 rviz_panel_->highlightLink(link, QColor(255, 0, 0));
132 }
133}
134
135} // namespace srdf_setup
136} // namespace moveit_setup
137
138#include <pluginlib/class_list_macros.hpp> // NOLINT
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
void setColumnNames(const QString &col1, const QString &col2)
Set the names of the two columns in the widget.
std::vector< std::string > getSelectedValues() const
Return all the values that are in the "selected" subset.
void setAvailable(const std::vector< std::string > &items)
Loads the available data list.
void setSelected(const std::vector< std::string > &items)
Set the right box.
void highlightLink(const std::string &link_name, const QColor &color)
The GUI code for one SetupStep.
void focusGiven() override
Received when this widget is chosen from the navigation menu.
std::vector< std::string > getPassiveJoints() const
Return all passive joint names (according to srdf)
std::string getChildOfJoint(const std::string &joint_name) const
std::vector< std::string > getActiveJoints() const
Return all active (non-fixed) joint names.
void setPassiveJoints(const std::vector< std::string > &passive_joints)