修改rviz显示逻辑与joint_publisher,添加moveit2相关节点描述

This commit is contained in:
q434343
2026-03-23 00:00:57 +08:00
parent cdbca70222
commit 35bcf6765d
7 changed files with 1550 additions and 77 deletions

View File

@@ -71,7 +71,8 @@ class LiquidHandlerMiddleware(LiquidHandler):
if simulator:
if joint_config:
self._simulate_backend = UniLiquidHandlerRvizBackend(
channel_num, kwargs["total_height"], joint_config=joint_config, lh_device_id=deck.name
channel_num, kwargs["total_height"], joint_config=joint_config, lh_device_id=deck.name,
simulate_rviz=kwargs.get("simulate_rviz", True)
)
else:
self._simulate_backend = LiquidHandlerChatterboxBackend(channel_num)
@@ -770,6 +771,7 @@ class LiquidHandlerAbstract(LiquidHandlerMiddleware):
simulator: bool = False,
channel_num: int = 8,
total_height: float = 310,
**kwargs,
):
"""Initialize a LiquidHandler.
@@ -809,14 +811,20 @@ class LiquidHandlerAbstract(LiquidHandlerMiddleware):
except Exception:
backend_cls = None
if backend_cls is not None and isinstance(backend_cls, type):
backend_type = backend_cls(**backend_dict) # pass the rest of dict as kwargs
if simulator:
backend_type = LiquidHandlerChatterboxBackend(channel_num)
else:
init_kwargs = dict(backend_dict)
init_kwargs["total_height"] = total_height
init_kwargs.update(kwargs)
backend_type = backend_cls(**init_kwargs)
except Exception as exc:
raise RuntimeError(f"Failed to convert backend type '{type_str}' to class: {exc}")
else:
backend_type = backend
self._simulator = simulator
self.group_info = dict()
super().__init__(backend_type, deck, simulator, channel_num)
super().__init__(backend_type, deck, simulator, channel_num, total_height=total_height, **kwargs)
def post_init(self, ros_node: BaseROS2DeviceNode):
self._ros_node = ros_node

View File

@@ -59,6 +59,7 @@ class UniLiquidHandlerRvizBackend(LiquidHandlerBackend):
self.total_height = total_height
self.joint_config = kwargs.get("joint_config", None)
self.lh_device_id = kwargs.get("lh_device_id", "lh_joint_publisher")
self.simulate_rviz = kwargs.get("simulate_rviz", False)
if not rclpy.ok():
rclpy.init()
self.joint_state_publisher = None
@@ -69,7 +70,7 @@ class UniLiquidHandlerRvizBackend(LiquidHandlerBackend):
self.joint_state_publisher = LiquidHandlerJointPublisher(
joint_config=self.joint_config,
lh_device_id=self.lh_device_id,
simulate_rviz=True)
simulate_rviz=self.simulate_rviz)
# 启动ROS executor
self.executor = rclpy.executors.MultiThreadedExecutor()

View File

@@ -42,6 +42,7 @@ class LiquidHandlerJointPublisher(Node):
while self.resource_action is None:
self.resource_action = self.check_tf_update_actions()
time.sleep(1)
self.get_logger().info(f'Waiting for TfUpdate server: {self.resource_action}')
self.resource_action_client = ActionClient(self, SendCmd, self.resource_action)
while not self.resource_action_client.wait_for_server(timeout_sec=1.0):