Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arm Teleop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CREATE Lab
Robot hand
ADAPT Hand
ros_ws
Arm Teleop
Commits
dd52842f
Commit
dd52842f
authored
11 months ago
by
Kai Junge
Browse files
Options
Downloads
Patches
Plain Diff
After MARS.
parent
bbb22575
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
arm_teleop/arm_teleop_node.py
+29
-10
29 additions, 10 deletions
arm_teleop/arm_teleop_node.py
with
29 additions
and
10 deletions
arm_teleop/arm_teleop_node.py
+
29
−
10
View file @
dd52842f
...
...
@@ -27,6 +27,7 @@ class ArmTeleopNode(Node):
# Main loop
self
.
mainloop
=
self
.
create_timer
(
0.001
,
self
.
mainloop_callback
)
self
.
transloop
=
self
.
create_timer
(
0.01
,
self
.
translation_callback
)
# Publisher
self
.
franka_pose_publisher
=
self
.
create_publisher
(
Float64MultiArray
,
'
/franka/pose_demand
'
,
10
)
...
...
@@ -34,12 +35,12 @@ class ArmTeleopNode(Node):
# Subscriber
self
.
franka_cartesian_pose_subscriber
=
self
.
create_subscription
(
Float64MultiArray
,
'
/franka/pose
'
,
self
.
cart_pos_callback
,
10
)
self
.
target_translation_subscriber
=
self
.
create_subscription
(
Float64MultiArray
,
'
/franka/translation_demand
'
,
self
.
translation_callback
,
10
)
#
self.target_translation_subscriber = self.create_subscription(Float64MultiArray, '/franka/translation_demand', self.translation_callback, 10)
self
.
target_orientation_subscriber
=
self
.
create_subscription
(
Float64MultiArray
,
'
/franka/orientation_demand
'
,
self
.
orientation_callback
,
10
)
self
.
hand_wrist_servo_position_subscriber
=
self
.
create_subscription
(
Float64MultiArray
,
'
/hand_wrist/servo_positions
'
,
self
.
hand_wrist_servo_callback
,
10
)
# Variables
self
.
translation_de
mand
=
None
self
.
translation_de
lta
=
[
0.0
,
0.0
,
0.0
]
self
.
orientation_demand
=
None
self
.
current_franka_pose
=
None
self
.
current_hand_wrist_servo_pos
=
None
...
...
@@ -61,13 +62,22 @@ class ArmTeleopNode(Node):
else
:
return
False
def
translation_callback
(
self
,
msg
:
Float64MultiArray
):
self
.
translation_demand
=
msg
def
translation_callback
(
self
):
scale
=
0.001
if
abs
(
self
.
gp
.
axis_data
[
"
Ly
"
])
>
0.3
:
self
.
translation_delta
[
2
]
+=
self
.
gp
.
axis_data
[
"
Ly
"
]
*
scale
*
-
1
if
abs
(
self
.
gp
.
axis_data
[
"
Lx
"
])
>
0.3
:
self
.
translation_delta
[
1
]
+=
self
.
gp
.
axis_data
[
"
Lx
"
]
*
scale
self
.
last_translation_update
=
cp
(
time
.
time
())
def
orientation_callback
(
self
,
msg
:
Float64MultiArray
):
self
.
orientation_demand
=
msg
self
.
last_orientation_update
=
cp
(
time
.
time
())
# print("asdf")
def
cart_pos_callback
(
self
,
msg
:
Float64MultiArray
):
self
.
current_franka_pose
=
msg
...
...
@@ -78,29 +88,38 @@ class ArmTeleopNode(Node):
def
gamepad_callback
(
self
,
gamepad_raw_msg
:
Joy
):
self
.
gp
.
convert_joy_msg_to_dictionary
(
gamepad_raw_msg
)
def
is_trigger
(
self
):
is_trigger
=
False
if
abs
(
self
.
gp
.
axis_data
[
"
Lx
"
])
>
0.5
or
abs
(
self
.
gp
.
axis_data
[
"
Ly
"
])
>
0.5
:
is_trigger
=
True
return
is_trigger
def
mainloop_callback
(
self
):
if
(
self
.
current_franka_pose
is
None
)
or
(
self
.
current_hand_wrist_servo_pos
is
None
):
return
if
self
.
gp
.
button_data
[
"
L1
"
]
==
1
and
self
.
is_active
==
False
:
if
(
self
.
gp
.
button_data
[
"
L1
"
]
==
1
or
self
.
is_trigger
())
and
self
.
is_active
==
False
:
self
.
initial_pose
=
list
(
cp
(
self
.
current_franka_pose
.
data
))
self
.
initial_pose_wrist
=
[
self
.
current_hand_wrist_servo_pos
.
data
[
13
],
self
.
current_hand_wrist_servo_pos
.
data
[
14
]]
self
.
is_active
=
True
self
.
waiting_timer
=
cp
(
time
.
time
())
self
.
translation_delta
=
[
0.0
,
0.0
,
0.0
]
print
(
"
reset
"
)
if
self
.
gp
.
button_data
[
"
L1
"
]
==
0
:
if
self
.
gp
.
button_data
[
"
L1
"
]
==
0
and
(
self
.
is_trigger
()
==
False
)
:
self
.
is_active
=
False
# print("zero")
if
self
.
is_active
and
(
time
.
time
()
-
self
.
waiting_timer
>
0.5
):
target_pose
=
cp
(
self
.
initial_pose
)
target_wrist
=
cp
(
self
.
initial_pose_wrist
)
print_msg
=
"
\n
"
if
(
self
.
translation_de
mand
is
not
None
)
and
self
.
check_timer
(
"
translation
"
):
if
(
self
.
translation_de
lta
is
not
None
)
and
self
.
check_timer
(
"
translation
"
):
print_msg
+=
"
Translation
"
for
i
in
range
(
3
):
target_pose
[
i
]
=
cp
(
self
.
translation_de
mand
[
i
])
target_pose
[
i
]
+
=
cp
(
self
.
translation_de
lta
[
i
])
if
(
self
.
orientation_demand
is
not
None
)
and
self
.
check_timer
(
"
orientation
"
):
print_msg
+=
"
Orientation
"
...
...
@@ -135,7 +154,7 @@ class ArmTeleopNode(Node):
# print([self.current_hand_wrist_servo_pos.data[13], self.current_hand_wrist_servo_pos.data[14]])
# print(self.orientation_demand.data[7], self.orientation_demand.data[8])
print
(
left
,
right
)
#
print(left, right)
print
(
""
)
# print_msg += ("\n" + posestamp_message_as_str(target_pose))
# self.get_logger().info(print_msg, throttle_duration_sec = 0.1)
...
...
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