Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qubo_gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robotics at Maryland
qubo_gui
Commits
a56a5f2d
Commit
a56a5f2d
authored
5 months ago
by
Jeffrey Fisher
Browse files
Options
Downloads
Patches
Plain Diff
Thrust publisher
parent
4cf749d1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qubo_gui/teleop.py
+34
-1
34 additions, 1 deletion
qubo_gui/teleop.py
with
34 additions
and
1 deletion
qubo_gui/teleop.py
+
34
−
1
View file @
a56a5f2d
...
...
@@ -6,6 +6,9 @@ import logging
import
threading
import
numpy
as
np
# ROS
import
rclpy
# rqt and QT
from
qt_gui.plugin
import
Plugin
from
python_qt_binding
import
QtCore
...
...
@@ -13,12 +16,17 @@ from python_qt_binding.QtCore import Qt, QTimer
from
python_qt_binding.QtWidgets
import
QWidget
,
QLabel
,
QSlider
,
QPushButton
,
QHBoxLayout
,
QVBoxLayout
class
TeleopPlugin
(
Plugin
):
channel
=
'
/wrench
'
def
__init__
(
self
,
context
):
super
(
TeleopPlugin
,
self
).
__init__
(
context
)
self
.
_context
=
context
self
.
setObjectName
(
"
TeleopPlugin
"
)
# Access the RQT ROS node.
self
.
_node
=
self
.
_context
.
node
self
.
_widget
=
QWidget
()
self
.
label_joy_x
=
QLabel
(
"
X: 000000
"
,
parent
=
self
.
_widget
)
...
...
@@ -29,16 +37,41 @@ class TeleopPlugin(Plugin):
context
.
add_widget
(
self
.
_widget
)
self
.
thrust_publisher_
=
self
.
_node
.
create_publisher
(
Wrench
,
self
.
channel
,
10
)
@QtCore.Slot
()
def
_monitor_joy
(
self
):
self
.
label_joy_x
.
setText
(
f
"
X:
{
self
.
_joy
.
LeftJoystickX
}
"
)
x
=
-
self
.
_joy
.
LeftJoystickY
y
=
-
self
.
_joy
.
LeftJoystickX
z
=
0
if
self
.
_joy
.
A
and
self
.
_joy
.
B
else
1
if
self
.
_joy
.
A
else
-
1
if
self
.
_joy
.
B
else
0
roll
=
self
.
_joy
.
RightJoystickX
pitch
=
-
self
.
_joy
.
RightJoystickY
yaw
=
0
if
self
.
_joy
.
LeftTrigger
>
0.5
and
self
.
_joy
.
RightTrigger
>
0.5
else
1
if
self
.
_joy
.
LeftTrigger
>
0.5
else
-
1
if
self
.
_joy
.
RightTrigger
>
0.5
else
0
thrust_arr
=
[
x
,
y
,
z
,
roll
,
pitch
,
yaw
]
thrust_arr
=
map
(
XboxController
.
scale
,
thrust_arr
)
thrust_arr
=
[
thrust
*
max
for
thrust
,
max
in
zip
(
thrust_arr
,
self
.
_joy
.
thrustMax
)]
thrust_arr
=
np
.
clip
(
thrust_arr
,
[
-
max
for
max
in
self
.
_joy
.
thrustMax
],
self
.
_joy
.
thrustMax
)
thrust_arr
=
list
(
map
(
lambda
thrust
:
thrust
if
abs
(
thrust
)
>
self
.
_joy
.
thrustMin
else
0
,
thrust_arr
))
scale
=
5
thrust_msg
=
Wrench
()
thrust_msg
.
force
.
x
=
float
(
scale
*
thrust_arr
[
0
])
thrust_msg
.
force
.
y
=
float
(
scale
*
thrust_arr
[
1
])
thrust_msg
.
force
.
z
=
float
(
scale
*
thrust_arr
[
2
])
thrust_msg
.
torque
.
x
=
float
(
scale
*
thrust_arr
[
3
])
thrust_msg
.
torque
.
y
=
float
(
scale
*
thrust_arr
[
4
])
thrust_msg
.
torque
.
z
=
float
(
scale
*
thrust_arr
[
5
])
self
.
thrust_publisher_
.
publish
(
thrust_msg
)
class
XboxController
(
object
):
MAX_TRIG_VAL
=
math
.
pow
(
2
,
8
)
MAX_JOY_VAL
=
math
.
pow
(
2
,
15
)
def
__init__
(
self
):
self
.
LeftJoystickY
=
0
self
.
LeftJoystickX
=
0
self
.
RightJoystickY
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment