Skip to content

Parameters documentation #5

@belalhmedan90

Description

@belalhmedan90

Hi, thanks for the excellent work, I want to ask please about where I can get a documentation regarding the params used here, I tried these params tpp_test_cfg.yml :

mesh_modifiers:
  - name: NormalsFromMeshFaces
tool_path_planner:
  name: Multi
  gui_plugin_name: CrossHatchPlaneSlicer
  planners:
    - name: PlaneSlicer
      direction_generator:
        name: PrincipalAxis
        rotation_offset: 1.571
      origin_generator:
        name: AABBCenter
      line_spacing: 0.1
      point_spacing: 0.025
      min_hole_size: 0.100
      search_radius: 0.100
      min_segment_size: 0.200
      bidirectional: false
    - name: PlaneSlicer
      direction_generator:
        name: PCARotated
        direction_generator:
          name: PrincipalAxis
          rotation_offset: 1.571
        rotation_offset: 1.571
      origin_generator:
        name: AABBCenter
      line_spacing: 0.100
      point_spacing: 0.025
      min_hole_size: 0.100
      search_radius: 0.100
      min_segment_size: 0.200
      bidirectional: false
tool_path_modifiers:
  - name: SnakeOrganization

with this Service client:

#!/usr/bin/env python3
import rclpy
from rclpy.executors import MultiThreadedExecutor
from rclpy.callback_groups import ReentrantCallbackGroup
from rclpy.node import Node
from noether_ros.msg import ToolPaths
from noether_ros.srv import PlanToolPath
import open3d as o3d
import numpy as np


class ToolPathPlannerClient(Node):
    def __init__(self):
        super().__init__('tool_path_planner_client')
        self._cb_group = ReentrantCallbackGroup()
        self.client = self.create_client(PlanToolPath, '/plan_tool_path', callback_group=self._cb_group)

    def call_service(self):
        if not self.client.wait_for_service(timeout_sec=3.0):
            self._logger.error(f"Service {self.client.srv_name} is not available!")
            return

        req = PlanToolPath.Request()
        mesh_path = "scaled_small_box.ply"
        config_path = "tpp_test_cfg.yml"

        req.mesh_file = mesh_path
        req.mesh_frame = "world"
        req.config = config_path

        self._logger.info(
            f"Calling /plan_tool_path with:\n"
            f"  mesh   = {mesh_path}\n"
            f"  config = {config_path}"
        )

        future = self.client.call_async(req)
        rclpy.spin_until_future_complete(node=self, future=future, executor=self.executor,timeout_sec=70.0)

        if future.result() is not None:
            res: PlanToolPath.Response = future.result()
            self._logger.info(f"Success: {res.success}")
            self._logger.info(f"Message: {res.message}")
            self._logger.info(f"Tool paths: {len(res.tool_paths)}")
            toolpaths_group : ToolPaths = res.tool_paths
            self.visualize_tool_paths(toolpaths_group, mesh_path)
        else:
            self._logger.error("Service call failed.")

    def visualize_tool_paths(self, toolpaths_group, mesh_path, frame_size=0.05):

        def create_frame(
            translation: np.ndarray = np.zeros((3,), dtype=np.float32),
            orientation: np.ndarray = np.eye(3, dtype=np.float32),
            frame_size=0.1,
        ) -> o3d.geometry.TriangleMesh:
            frame_pose = o3d.geometry.TriangleMesh.create_coordinate_frame(
                size=frame_size, origin=translation
            )
            frame_pose.rotate(orientation)
            return frame_pose

        # Load the mesh
        mesh = o3d.io.read_triangle_mesh(mesh_path)
        mesh.compute_vertex_normals()
        mesh.paint_uniform_color([0.8, 0.8, 0.8])  # light gray

        geometries = [mesh]

        # Convert each pose in each segment to a coordinate frame
        for toolpaths in toolpaths_group:
            for toolpath in toolpaths.tool_paths:
                for segment in toolpath.segments:
                    # segment is a PoseArray
                    for pose in segment.poses:
                        translation = np.array([pose.position.x,
                                                pose.position.y,
                                                pose.position.z])
                        # Convert quaternion to rotation matrix
                        q = pose.orientation
                        # w, x, y, z
                        w, x, y, z = q.w, q.x, q.y, q.z
                        orientation = np.array([
                            [1 - 2*y**2 - 2*z**2, 2*x*y - 2*z*w, 2*x*z + 2*y*w],
                            [2*x*y + 2*z*w, 1 - 2*x**2 - 2*z**2, 2*y*z - 2*x*w],
                            [2*x*z - 2*y*w, 2*y*z + 2*x*w, 1 - 2*x**2 - 2*y**2]
                        ])
                        frame = create_frame(translation, orientation, frame_size)
                        geometries.append(frame)

        o3d.visualization.draw_geometries(geometries)

        
def main(args=None):
    rclpy.init(args=args)
    node = ToolPathPlannerClient()
    executor = MultiThreadedExecutor()
    executor.add_node(node)
    node.call_service()
    executor.shutdown()
    node.destroy_node()
    rclpy.shutdown()

if __name__ == "__main__":
    main()

but the result doesn't look quite good, hence I would like to know please where I can find the params (as they don't match 100% the param names here) in order to find a better combination, thanks in advance.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions