Skip to content

Bugfix/dropped commands #103

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

Open
wants to merge 8 commits into
base: noetic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions stretch_core/nodes/command_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, range_rad=None, calibrated_offset_rad=None, calibrated_looked
calibrated_looked_left_offset_rad = node.controller_parameters['pan_looked_left_offset']
self.looked_left_offset_rad = calibrated_looked_left_offset_rad
self.looked_left = False


def update_joint_range(self, joint_range, node=None):
if joint_range is not None:
Expand All @@ -32,8 +33,11 @@ def update_joint_range(self, joint_range, node=None):
def init_execution(self, robot, robot_status, **kwargs):
if self.active:
_, pan_error = self.update_execution(robot_status)

robot.head.move_by('head_pan', pan_error, v_r=self.goal['velocity'], a_r=self.goal['acceleration'])
self.looked_left = pan_error > 0.0
return False
return True

def update_execution(self, robot_status, **kwargs):
self.error = None
Expand Down Expand Up @@ -65,6 +69,7 @@ def __init__(self, range_rad=None, calibrated_offset_rad=None, calibrated_lookin
backlash_transition_angle_rad = node.controller_parameters['tilt_angle_backlash_transition']
self.backlash_transition_angle_rad = backlash_transition_angle_rad
self.looking_up = False


def update_joint_range(self, joint_range, node=None):
if joint_range is not None:
Expand All @@ -81,8 +86,11 @@ def update_joint_range(self, joint_range, node=None):
def init_execution(self, robot, robot_status, **kwargs):
if self.active:
_, tilt_error = self.update_execution(robot_status)

robot.head.move_by('head_tilt', tilt_error, v_r=self.goal['velocity'], a_r=self.goal['acceleration'])
self.looking_up = self.goal['position'] > (self.backlash_transition_angle_rad + self.calibrated_offset_rad)
return False
return True

def update_execution(self, robot_status, **kwargs):
self.error = None
Expand All @@ -104,6 +112,7 @@ def joint_state(self, robot_status, **kwargs):
class WristYawCommandGroup(SimpleCommandGroup):
def __init__(self, range_rad=None, node=None):
SimpleCommandGroup.__init__(self, 'joint_wrist_yaw', range_rad, node=node)


def update_joint_range(self, joint_range, node=None):
if joint_range is not None:
Expand All @@ -119,10 +128,14 @@ def update_joint_range(self, joint_range, node=None):

def init_execution(self, robot, robot_status, **kwargs):
if self.active:
_, wrist_yaw_error = self.update_execution(robot_status)

robot.end_of_arm.move_by('wrist_yaw',
self.update_execution(robot_status)[1],
wrist_yaw_error,
v_r=self.goal['velocity'],
a_r=self.goal['acceleration'])
return False
return True

def update_execution(self, robot_status, **kwargs):
self.error = None
Expand All @@ -143,6 +156,7 @@ def __init__(self, range_robotis=None, node=None):
SimpleCommandGroup.__init__(self, 'joint_gripper_finger_left', range_robotis, acceptable_joint_error=1.0, node=node)
self.gripper_joint_names = ['joint_gripper_finger_left', 'joint_gripper_finger_right', 'gripper_aperture']
self.update_joint_range(range_robotis)


def update_joint_range(self, joint_range, node=None):
if joint_range is not None:
Expand Down Expand Up @@ -216,10 +230,13 @@ def init_execution(self, robot, robot_status, **kwargs):
gripper_robotis_error = self.gripper_conversion.aperture_to_robotis(gripper_error)
elif (self.name == 'joint_gripper_finger_left') or (self.name == 'joint_gripper_finger_right'):
gripper_robotis_error = self.gripper_conversion.finger_to_robotis(gripper_error)

robot.end_of_arm.move_by('stretch_gripper',
gripper_robotis_error,
v_r=self.goal['velocity'],
a_r=self.goal['acceleration'])
return False
return True

def update_execution(self, robot_status, **kwargs):
self.error = None
Expand Down Expand Up @@ -356,13 +373,19 @@ def set_goal(self, point, invalid_goal_callback, fail_out_of_range_goal, **kwarg
def init_execution(self, robot, robot_status, **kwargs):
if self.active:
_, extension_error_m = self.update_execution(robot_status, force_single=True)
self.retracted = extension_error_m < 0.0


robot.arm.move_by(extension_error_m,
v_m=self.goal['velocity'],
a_m=self.goal['acceleration'],
contact_thresh_pos=self.goal['contact_threshold'],
contact_thresh_neg=-self.goal['contact_threshold'] \
if self.goal['contact_threshold'] is not None else None)
self.retracted = extension_error_m < 0.0

if self.goal_reached():
return False
return True

def update_execution(self, robot_status, **kwargs):
success_callback = kwargs['success_callback'] if 'success_callback' in kwargs.keys() else None
Expand Down Expand Up @@ -408,12 +431,16 @@ def update_joint_range(self, joint_range, node=None):

def init_execution(self, robot, robot_status, **kwargs):
if self.active:
robot.lift.move_by(self.update_execution(robot_status)[1],
_, lift_error_m = self.update_execution(robot_status)
robot.lift.move_by(lift_error_m,
v_m=self.goal['velocity'],
a_m=self.goal['acceleration'],
contact_thresh_pos=self.goal['contact_threshold'],
contact_thresh_neg=-self.goal['contact_threshold'] \
if self.goal['contact_threshold'] is not None else None)
if self.goal_reached():
return False
return True

def update_execution(self, robot_status, **kwargs):
success_callback = kwargs['success_callback'] if 'success_callback' in kwargs.keys() else None
Expand Down Expand Up @@ -586,6 +613,9 @@ def init_execution(self, robot, robot_status, **kwargs):
v_m=self.goal['velocity'],
a_m=self.goal['acceleration'],
contact_thresh=self.goal['contact_threshold'])
if self.goal_reached():
return False
return True

def update_execution(self, robot_status, **kwargs):
success_callback = kwargs['success_callback'] if 'success_callback' in kwargs.keys() else None
Expand Down
11 changes: 8 additions & 3 deletions stretch_core/nodes/joint_trajectory_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,18 @@ def execute_cb(self, goal):
return

robot_status = self.node.robot.get_status() # uses lock held by robot
for c in self.command_groups:
c.init_execution(self.node.robot, robot_status)
self.node.robot.push_command()

movements_requiring_push = [c.init_execution(self.node.robot, robot_status) for c in self.command_groups]
movements_not_requiring_push_count = len(movements_requiring_push) - sum(movements_requiring_push)


if movements_not_requiring_push_count != len(commanded_joint_names):
self.node.robot.push_command()

goals_reached = [c.goal_reached() for c in self.command_groups]
update_rate = rospy.Rate(15.0)
goal_start_time = rospy.Time.now()


while not all(goals_reached):
if (rospy.Time.now() - goal_start_time) > self.node.default_goal_timeout_duration:
Expand Down