Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#22)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pycqa/isort: 5.10.1 → 5.12.0](PyCQA/isort@5.10.1...5.12.0)
- [github.com/psf/black: 22.10.0 → 23.1.0](psf/black@22.10.0...23.1.0)
- [github.com/codespell-project/codespell: v2.2.2 → v2.2.4](codespell-project/codespell@v2.2.2...v2.2.4)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Mar 14, 2023
1 parent 60eb340 commit f55428a
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black

Expand All @@ -43,6 +43,6 @@ repos:
- id: mdformat

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.4
hooks:
- id: codespell
1 change: 0 additions & 1 deletion examples/ex_collision_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


def main():

rclpy.init()

# Create node for this example
Expand Down
1 change: 0 additions & 1 deletion examples/ex_gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


def main():

rclpy.init()

# Create node for this example
Expand Down
1 change: 0 additions & 1 deletion examples/ex_gripper_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


def main():

rclpy.init()

# Create node for this example
Expand Down
1 change: 0 additions & 1 deletion examples/ex_joint_goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


def main():

rclpy.init()

# Create node for this example
Expand Down
1 change: 0 additions & 1 deletion examples/ex_pose_goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


def main():

rclpy.init()

# Create node for this example
Expand Down
1 change: 0 additions & 1 deletion examples/ex_servo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def main():

rclpy.init()

# Create node for this example
Expand Down
8 changes: 0 additions & 8 deletions pymoveit2/gripper_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def wait_until_executed(self):
self.__wait_until_executed_rate.sleep()

def __joint_state_callback(self, msg: JointState):

# Update only if all relevant joints are included in the message
for joint_name in self.joint_names:
if not joint_name in msg.name:
Expand All @@ -238,7 +237,6 @@ def __send_goal_async_gripper_command(
goal: GripperCommandAction.Goal,
wait_for_server_timeout_sec: Optional[float] = 1.0,
):

if not self.__gripper_command_action_client.wait_for_server(
timeout_sec=wait_for_server_timeout_sec
):
Expand All @@ -255,7 +253,6 @@ def __send_goal_async_gripper_command(
action_result.add_done_callback(self.__response_callback_gripper_command)

def __response_callback_gripper_command(self, response):

goal_handle = response.result()
if not goal_handle.accepted:
self._node.get_logger().warn(
Expand All @@ -273,7 +270,6 @@ def __response_callback_gripper_command(self, response):
)

def __result_callback_gripper_command(self, res):

if res.result().status != GoalStatus.STATUS_SUCCEEDED:
self._node.get_logger().error(
f"Action '{self.__gripper_command_action_client._action_name}' was unsuccessful: {res.result().status}"
Expand All @@ -285,7 +281,6 @@ def __result_callback_gripper_command(self, res):
def __init_gripper_command_goal(
cls, position: Union[float, List[float]], max_effort: float
) -> GripperCommandAction.Goal:

if hasattr(position, "__getitem__"):
position = position[0]

Expand All @@ -297,20 +292,17 @@ def __init_gripper_command_goal(

@property
def joint_names(self) -> List[str]:

return self.__joint_names

@property
def joint_state(self) -> Optional[JointState]:

self.__joint_state_mutex.acquire()
joint_state = self.__joint_state
self.__joint_state_mutex.release()
return joint_state

@property
def new_joint_state_available(self):

return self.__new_joint_state_available

@property
Expand Down
30 changes: 0 additions & 30 deletions pymoveit2/moveit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@ def remove_collision_mesh(self, id: str):
self.__collision_object_publisher.publish(msg)

def __joint_state_callback(self, msg: JointState):

# Update only if all relevant joints are included in the message
for joint_name in self.joint_names:
if not joint_name in msg.name:
Expand All @@ -906,7 +905,6 @@ def __joint_state_callback(self, msg: JointState):
def _send_goal_move_action_plan_only(
self, wait_for_server_timeout_sec: Optional[float] = 1.0
) -> Optional[JointTrajectory]:

# Set action goal to only do planning without execution
original_plan_only = self.__move_action_goal.planning_options.plan_only
self.__move_action_goal.planning_options.plan_only = True
Expand Down Expand Up @@ -938,7 +936,6 @@ def _send_goal_move_action_plan_only(
def _plan_kinematic_path(
self, wait_for_server_timeout_sec: Optional[float] = 1.0
) -> Optional[JointTrajectory]:

# Re-use request from move action goal
self.__kinematic_path_request.motion_plan_request = (
self.__move_action_goal.request
Expand Down Expand Up @@ -982,7 +979,6 @@ def _plan_cartesian_path(
wait_for_server_timeout_sec: Optional[float] = 1.0,
frame_id: Optional[str] = None,
) -> Optional[JointTrajectory]:

# Re-use request from move action goal
self.__cartesian_path_request.start_state = (
self.__move_action_goal.request.start_state
Expand Down Expand Up @@ -1049,7 +1045,6 @@ def _plan_cartesian_path(
def _send_goal_async_move_action(
self, wait_for_server_timeout_sec: Optional[float] = 1.0
):

stamp = self._node.get_clock().now().to_msg()
self.__move_action_goal.request.workspace_parameters.header.stamp = stamp

Expand All @@ -1072,7 +1067,6 @@ def _send_goal_async_move_action(
)

def __response_callback_move_action(self, response):

goal_handle = response.result()
if not goal_handle.accepted:
self._node.get_logger().warn(
Expand All @@ -1090,7 +1084,6 @@ def __response_callback_move_action(self, response):
)

def __result_callback_move_action(self, res):

if res.result().status != GoalStatus.STATUS_SUCCEEDED:
self._node.get_logger().error(
f"Action '{self.__move_action_client._action_name}' was unsuccessful: {res.result().status}."
Expand All @@ -1104,7 +1097,6 @@ def _send_goal_async_follow_joint_trajectory(
wait_for_server_timeout_sec: Optional[float] = 1.0,
wait_until_response: bool = False,
):

if not self.__follow_joint_trajectory_action_client.wait_for_server(
timeout_sec=wait_for_server_timeout_sec
):
Expand Down Expand Up @@ -1135,7 +1127,6 @@ def _send_goal_async_follow_joint_trajectory(
)

def __response_callback_follow_joint_trajectory(self, response):

goal_handle = response.result()
if not goal_handle.accepted:
self._node.get_logger().warn(
Expand All @@ -1155,12 +1146,10 @@ def __response_callback_follow_joint_trajectory(self, response):
)

def __response_callback_with_event_set_follow_joint_trajectory(self, response):

self.__response_callback_follow_joint_trajectory(response)
self.__future_done_event.set()

def __result_callback_follow_joint_trajectory(self, res):

if res.result().status != GoalStatus.STATUS_SUCCEEDED:
self._node.get_logger().error(
f"Action '{self.__follow_joint_trajectory_action_client._action_name}' was unsuccessful: {res.result().status}."
Expand All @@ -1172,7 +1161,6 @@ def __result_callback_follow_joint_trajectory(self, res):
def __init_move_action_goal(
cls, frame_id: str, group_name: str, end_effector: str
) -> MoveGroup.Goal:

move_action_goal = MoveGroup.Goal()
move_action_goal.request.workspace_parameters.header.frame_id = frame_id
# move_action_goal.request.workspace_parameters.header.stamp = "Set during request"
Expand Down Expand Up @@ -1209,7 +1197,6 @@ def __init_move_action_goal(
return move_action_goal

def __init_compute_fk(self):

self.__compute_fk_client = self._node.create_client(
srv_type=GetPositionFK,
srv_name="compute_fk",
Expand All @@ -1226,7 +1213,6 @@ def __init_compute_fk(self):
self.__compute_fk_req.robot_state.is_diff = False

def __init_compute_ik(self):

# Service client for IK
self.__compute_ik_client = self._node.create_client(
srv_type=GetPositionIK,
Expand Down Expand Up @@ -1255,70 +1241,57 @@ def __init_compute_ik(self):

@property
def joint_names(self) -> List[str]:

return self.__joint_names

@property
def joint_state(self) -> Optional[JointState]:

self.__joint_state_mutex.acquire()
joint_state = self.__joint_state
self.__joint_state_mutex.release()
return joint_state

@property
def new_joint_state_available(self):

return self.__new_joint_state_available

@property
def max_velocity(self) -> float:

return self.__move_action_goal.request.max_velocity_scaling_factor

@max_velocity.setter
def max_velocity(self, value: float):

self.__move_action_goal.request.max_velocity_scaling_factor = value

@property
def max_acceleration(self) -> float:

return self.__move_action_goal.request.max_acceleration_scaling_factor

@max_acceleration.setter
def max_acceleration(self, value: float):

self.__move_action_goal.request.max_acceleration_scaling_factor = value

@property
def max_cartesian_speed(self) -> float:

return self.__move_action_goal.request.max_cartesian_speed

@max_cartesian_speed.setter
def max_cartesian_speed(self, value: float):

self.__move_action_goal.request.max_cartesian_speed = value

@property
def num_planning_attempts(self) -> int:

return self.__move_action_goal.request.num_planning_attempts

@num_planning_attempts.setter
def num_planning_attempts(self, value: int):

self.__move_action_goal.request.num_planning_attempts = value

@property
def allowed_planning_time(self) -> float:

return self.__move_action_goal.request.allowed_planning_time

@allowed_planning_time.setter
def allowed_planning_time(self, value: float):

self.__move_action_goal.request.allowed_planning_time = value


Expand All @@ -1328,7 +1301,6 @@ def init_joint_state(
joint_velocities: Optional[List[str]] = None,
joint_effort: Optional[List[str]] = None,
) -> JointState:

joint_state = JointState()

joint_state.name = joint_names
Expand All @@ -1348,7 +1320,6 @@ def init_joint_state(
def init_follow_joint_trajectory_goal(
joint_trajectory: JointTrajectory,
) -> Optional[FollowJointTrajectory.Goal]:

if joint_trajectory is None:
return None

Expand All @@ -1368,7 +1339,6 @@ def init_follow_joint_trajectory_goal(
def init_dummy_joint_trajectory_from_state(
joint_state: JointState, duration_sec: int = 0, duration_nanosec: int = 0
) -> JointTrajectory:

joint_trajectory = JointTrajectory()
joint_trajectory.joint_names = joint_state.name

Expand Down
3 changes: 0 additions & 3 deletions pymoveit2/moveit2_gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,18 @@ def reset_closed(self, sync: bool = True):
)

def __open_without_planning(self):

self._send_goal_async_follow_joint_trajectory(
goal=self.__open_dummy_trajectory_goal,
wait_until_response=False,
)

def __close_without_planning(self):

self._send_goal_async_follow_joint_trajectory(
goal=self.__close_dummy_trajectory_goal,
wait_until_response=False,
)

def __del_redundant_attributes(self):

self.move_to_pose = None
self.set_pose_goal = None
self.set_position_goal = None
Expand Down
Loading

0 comments on commit f55428a

Please sign in to comment.