From f0976d233048c79ff9160e60f3e2650c5f711ddf Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 10 Sep 2021 11:15:10 +0000 Subject: [PATCH 1/3] [/src/baxter_interface/robot_enable.py] fix OSError, e -> OSError as e for Python3 --- src/baxter_interface/robot_enable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/baxter_interface/robot_enable.py b/src/baxter_interface/robot_enable.py index 78bf45f..c12ef50 100644 --- a/src/baxter_interface/robot_enable.py +++ b/src/baxter_interface/robot_enable.py @@ -164,7 +164,7 @@ def reset(self): timeout_msg=error_env, body=pub.publish ) - except OSError, e: + except OSError as e: if e.errno == errno.ETIMEDOUT: if self._state.error == True and self._state.stopped == False: rospy.logwarn(error_nonfatal) From 5f652d645cb3609d2df7ab3f2ca2e761ade8e29c Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 10 Sep 2021 11:15:54 +0000 Subject: [PATCH 2/3] [src/joint_trajectory_action/joint_trajectory_action.py] fix TabError: inconsistent use of tabs and spaces in indentation, for Python3 --- .../joint_trajectory_action.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/joint_trajectory_action/joint_trajectory_action.py b/src/joint_trajectory_action/joint_trajectory_action.py index 0b0ec42..d5e1779 100644 --- a/src/joint_trajectory_action/joint_trajectory_action.py +++ b/src/joint_trajectory_action/joint_trajectory_action.py @@ -211,20 +211,20 @@ def _update_feedback(self, cmd_point, jnt_names, cur_time): self._server.publish_feedback(self._fdbk) def _reorder_joints_ff_cmd(self, joint_names, point): - joint_name_order = self._limb.joint_names() - pnt = JointTrajectoryPoint() - pnt.time_from_start = point.time_from_start - pos_cmd = dict(zip(joint_names, point.positions)) - for jnt_name in joint_name_order: - pnt.positions.append(pos_cmd[jnt_name]) + joint_name_order = self._limb.joint_names() + pnt = JointTrajectoryPoint() + pnt.time_from_start = point.time_from_start + pos_cmd = dict(zip(joint_names, point.positions)) + for jnt_name in joint_name_order: + pnt.positions.append(pos_cmd[jnt_name]) if point.velocities: - vel_cmd = dict(zip(joint_names, point.velocities)) - for jnt_name in joint_name_order: - pnt.velocities.append(vel_cmd[jnt_name]) + vel_cmd = dict(zip(joint_names, point.velocities)) + for jnt_name in joint_name_order: + pnt.velocities.append(vel_cmd[jnt_name]) if point.accelerations: - accel_cmd = dict(zip(joint_names, point.accelerations)) - for jnt_name in joint_name_order: - pnt.accelerations.append(accel_cmd[jnt_name]) + accel_cmd = dict(zip(joint_names, point.accelerations)) + for jnt_name in joint_name_order: + pnt.accelerations.append(accel_cmd[jnt_name]) return pnt def _command_stop(self, joint_names, joint_angles, start_time, dimensions_dict): From 54ebdf1d76f0380c83c534f6d8bb288a19ef914a Mon Sep 17 00:00:00 2001 From: Soonhyo Kim <91313250+soonhyo@users.noreply.github.com> Date: Thu, 12 Oct 2023 10:12:01 +0900 Subject: [PATCH 3/3] Resolving Compatibility Issue between python2 and python3 (#1) * fixed map function of python2 to list(map) in feedback position error code * add absolute_import for the compatibility of python2,3 --------- Co-authored-by: s-kim --- .../joint_trajectory_action.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/joint_trajectory_action/joint_trajectory_action.py b/src/joint_trajectory_action/joint_trajectory_action.py index d5e1779..862f02e 100644 --- a/src/joint_trajectory_action/joint_trajectory_action.py +++ b/src/joint_trajectory_action/joint_trajectory_action.py @@ -28,14 +28,16 @@ """ Baxter RSDK Joint Trajectory Action Server """ +from __future__ import absolute_import + import bisect from copy import deepcopy import math import operator import numpy as np -import bezier -import minjerk +from . import bezier +from . import minjerk import rospy @@ -58,6 +60,11 @@ import baxter_interface +# Python2's xrange equals Python3's range, and xrange is removed on Python3 +if not hasattr(__builtins__, 'xrange'): + xrange = range + + class JointTrajectoryActionServer(object): def __init__(self, limb, reconfig_server, rate=100.0, mode='position_w_id', interpolation='bezier'): @@ -203,10 +210,11 @@ def _update_feedback(self, cmd_point, jnt_names, cur_time): self._fdbk.desired.time_from_start = rospy.Duration.from_sec(cur_time) self._fdbk.actual.positions = self._get_current_position(jnt_names) self._fdbk.actual.time_from_start = rospy.Duration.from_sec(cur_time) - self._fdbk.error.positions = map(operator.sub, - self._fdbk.desired.positions, - self._fdbk.actual.positions - ) + self._fdbk.error.positions = list(map(operator.sub, + self._fdbk.desired.positions, + self._fdbk.actual.positions + ) + ) self._fdbk.error.time_from_start = rospy.Duration.from_sec(cur_time) self._server.publish_feedback(self._fdbk)