Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
joy-teleop
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CdF
CdF 2020-2021
tools
devkit
joy-teleop
Commits
210634b5
Commit
210634b5
authored
4 years ago
by
Charles Javerliat
Browse files
Options
Downloads
Patches
Plain Diff
Update pwm service name
parent
60a2fb41
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/joy_teleop.py
+14
-12
14 additions, 12 deletions
scripts/joy_teleop.py
with
14 additions
and
12 deletions
scripts/joy_teleop.py
+
14
−
12
View file @
210634b5
...
...
@@ -15,7 +15,7 @@ from math import pi
coefAng
=
-
1
coefLin
=
1
#
# BUTTONS
# BUTTONS
B_TRIG
=
2
B_CIRC
=
1
...
...
@@ -40,7 +40,7 @@ B_DOWN = 14
B_LEFT
=
15
B_RIGHT
=
16
#
# AXES
# AXES
A_LJOYH
=
0
A_LJOYV
=
1
...
...
@@ -52,15 +52,16 @@ A_R2 = 5
########################################
class
JoyTeleopNode
():
def
joyCallback
(
self
,
data
):
if
(
data
.
buttons
[
B_START
]):
#
#
Toggle PWM
# Toggle PWM
self
.
enablePwm
(
not
self
.
pwmState
)
if
(
data
.
buttons
[
B_PS
]):
#
#
shutdown teleop
# shutdown teleop
self
.
forceQuit
=
True
self
.
angular_vel
=
data
.
axes
[
A_LJOYH
]
*
coefAng
...
...
@@ -79,14 +80,14 @@ class JoyTeleopNode():
self
.
forceQuit
=
False
self
.
publisher
=
rospy
.
Publisher
(
'
cmd_vel
'
,
Twist
,
queue_size
=
1
)
print
(
"
Waiting for /m
otors/chang
e_pwm service...
"
)
rospy
.
wait_for_service
(
'
/m
otors/chang
e_pwm
'
)
self
.
change_pwm
=
rospy
.
ServiceProxy
(
'
/m
otors/chang
e_pwm
'
,
SetBool
)
print
(
"
Waiting for /m
ccd/enabl
e_pwm service...
"
)
rospy
.
wait_for_service
(
'
/m
ccd/enabl
e_pwm
'
)
self
.
change_pwm
=
rospy
.
ServiceProxy
(
'
/m
ccd/enabl
e_pwm
'
,
SetBool
)
self
.
joySubscriber
=
rospy
.
Subscriber
(
'
joy
'
,
Joy
,
self
.
joyCallback
)
self
.
lastTimeUpdate
=
time
.
time
()
self
.
minUpdatePeriod
=
0.3
# resend data every x sec.
self
.
minUpdatePeriod
=
0.3
# resend data every x sec.
print
(
"""
LEFT JOY change speed
...
...
@@ -99,7 +100,6 @@ PS shutdown teleop
if
self
.
forceQuit
==
True
:
break
if
self
.
last_angular_vel
!=
self
.
angular_vel
:
self
.
last_angular_vel
=
self
.
angular_vel
self
.
lastTimeUpdate
=
time
.
time
()
...
...
@@ -119,11 +119,11 @@ PS shutdown teleop
strToPrint
=
"
PwmState:
\x1b
[1;32;40m{}
\x1b
[0m
\t
n
"
strToPrint
+=
"
linear_vel:
\x1b
[1;32;40m{:.3f}
\x1b
[0m
\t
"
strToPrint
+=
"
angular_vel:
\x1b
[1;32;40m{:.3f}
\x1b
[0m
"
print
(
"
\033
[A
\033
[A
"
,
flush
=
True
)
print
(
"
\033
[A
\033
[A
"
,
flush
=
True
)
print
(
strToPrint
.
format
(
"
1
"
if
self
.
pwmState
else
"
0
"
,
self
.
linear_vel
,
self
.
angular_vel
),
flush
=
True
)
flush
=
True
)
self
.
print_info
=
False
self
.
send_vel
()
...
...
@@ -153,10 +153,12 @@ PS shutdown teleop
except
rospy
.
ServiceException
as
e
:
print
(
"
Service call failed: %s
"
%
e
)
if
__name__
==
'
__main__
'
:
rospy
.
init_node
(
"
joy_teleop
"
)
try
:
JoyTeleopNode
()
except
rospy
.
ROSInterruptException
:
pass
except
rospy
.
ROSInterruptException
:
pass
This diff is collapsed.
Click to expand it.
Preview
0%
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