From 3f73c26e7596a7ad1317e3eecc78c1e0cb7a47cb Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Tue, 18 Aug 2026 15:46:26 +1000 Subject: [PATCH] fix: Robot._to_dict() uses set_alpha(), deprecated by spatialgeometry spatialgeometry deprecated Shape.set_alpha() in favour of an opacity property (still functionally identical -- set_alpha just does `self.opacity = alpha` -- but emits a FutureWarning on every call). Robot._to_dict() calls it on every link/gripper geometry and collision shape, so any env.add_robot(robot) in Swift triggers the warning. Switch to the opacity property directly. --- src/roboticstoolbox/robot/Robot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/roboticstoolbox/robot/Robot.py b/src/roboticstoolbox/robot/Robot.py index be3c0d9f0..1335f709c 100644 --- a/src/roboticstoolbox/robot/Robot.py +++ b/src/roboticstoolbox/robot/Robot.py @@ -160,11 +160,11 @@ def _to_dict(self, robot_alpha=1.0, collision_alpha=0.0): for link in self.links: if robot_alpha > 0: for gi in link.geometry: - gi.set_alpha(robot_alpha) + gi.opacity = robot_alpha ob.append(gi.to_dict()) if collision_alpha > 0: for gi in link.collision: - gi.set_alpha(collision_alpha) + gi.opacity = collision_alpha ob.append(gi.to_dict()) # Do the grippers now @@ -172,11 +172,11 @@ def _to_dict(self, robot_alpha=1.0, collision_alpha=0.0): for link in gripper.links: if robot_alpha > 0: for gi in link.geometry: - gi.set_alpha(robot_alpha) + gi.opacity = robot_alpha ob.append(gi.to_dict()) if collision_alpha > 0: for gi in link.collision: - gi.set_alpha(collision_alpha) + gi.opacity = collision_alpha ob.append(gi.to_dict()) # for o in ob: