-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add joint position controller GUI, also enable tests for GUI plugins #534
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
166c0e7
Beginning joint position controller
chapulina 1c5ae3b
Add GUI test
chapulina fe7636f
documentation tweaks
chapulina ce009a6
tooltip and initial blocked state
chapulina ed0cdfb
Merge branch 'ign-gazebo3' into chapulina/3/joint_gui
chapulina 5ab230d
Help, fix startup
chapulina 08904d0
Add reset, fix updating values from ECM
chapulina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
gz_add_gui_plugin(JointPositionController | ||
SOURCES | ||
JointPositionController.cc | ||
QT_HEADERS | ||
JointPositionController.hh | ||
TEST_SOURCES | ||
JointPositionController_TEST.cc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (C) 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
import QtQuick 2.9 | ||
import QtQuick.Controls 2.2 | ||
import QtQuick.Layouts 1.3 | ||
import "qrc:/JointPositionController" | ||
import "qrc:/qml" | ||
|
||
Rectangle { | ||
id: joint | ||
height: slider.height | ||
width: jointPositionController.width | ||
color: index % 2 == 0 ? lightGrey : darkGrey | ||
|
||
// Position value | ||
property double value: 0.0 | ||
|
||
// Horizontal margins | ||
property int margin: 15 | ||
|
||
Connections { | ||
target: joint | ||
onValueChanged: { | ||
jointPositionController.onCommand(model.name, joint.value); | ||
spin.value = joint.value; | ||
slider.value = joint.value; | ||
} | ||
} | ||
|
||
RowLayout { | ||
anchors.fill: parent | ||
spacing: 0 | ||
|
||
Item { | ||
height: parent.height | ||
width: margin | ||
} | ||
|
||
Text { | ||
text: model.name | ||
Layout.alignment: Qt.AlignVCenter | ||
Layout.preferredWidth: 100 | ||
elide: Text.ElideRight | ||
ToolTip { | ||
visible: ma.containsMouse | ||
delay: Qt.styleHints.mousePressAndHoldInterval | ||
text: model.name | ||
y: -30 | ||
enter: null | ||
exit: null | ||
} | ||
MouseArea { | ||
id: ma | ||
anchors.fill: parent | ||
hoverEnabled: true | ||
acceptedButtons: Qt.RightButton | ||
} | ||
} | ||
|
||
IgnSpinBox { | ||
id: spin | ||
value: model.value | ||
minimumValue: model.min | ||
maximumValue: model.max | ||
decimals: 2 | ||
onEditingFinished: { | ||
joint.value = spin.value | ||
} | ||
} | ||
|
||
Text { | ||
text: model.min.toFixed(2) | ||
Layout.alignment: Qt.AlignVCenter | ||
} | ||
|
||
Slider { | ||
id: slider | ||
Layout.alignment: Qt.AlignVCenter | ||
Layout.fillWidth: true | ||
from: model.min | ||
to: model.max | ||
value: model.value | ||
onMoved: { | ||
joint.value = slider.value | ||
} | ||
} | ||
|
||
Text { | ||
text: model.max.toFixed(2) | ||
Layout.alignment: Qt.AlignVCenter | ||
} | ||
|
||
Item { | ||
height: parent.height | ||
width: margin | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the
stepSize
is1
but I think0.1
would be a better increment. Also, I think usingonValueChanged
instead ofonEditingFinished
is more user friendly, the user doesn't have to hit enter every time they want to update a joint when using the spinboxThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are very good suggestions. I started with both of them, but I had to revert to using
onEditingFinished
when I worked on the reset button.While working on reset, I noticed that the values on the GUI were not being updated to reflect the actual state of the robot. When I fixed that, I realized I couldn't use
onValueChanged
, because that signal doesn't differentiate the value being changed by the user, or from the ECM. So what was happening was that the intermediate state of a joint moving would be sent as a new command, and the joint would tend to return to its original position in a negative feedback loop. It's hard to explain with words, see what happened withonValueChanged
:This is all on 08904d0, let me know what you think.