Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to attach the tool with from compas_robots.viewer.scene.robotmodelobject import RobotModelObject? robot_object.attach_tool_model(tool_model) robot_object.draw_attached_meshes() robot_object.draw_visual(),Not effective #27

Open
djy89 opened this issue Nov 7, 2024 · 2 comments

Comments

@djy89
Copy link

djy89 commented Nov 7, 2024

tool_model=...
robot_object: RobotModelObject = viewer.scene.add(model, show_lines=False, configuration=configuration)

Attach the tool

robot_object.attach_tool_model(tool_model)
robot_object.draw_attached_meshes()
robot_object.draw_visual()

Not effective?

@yck011522
Copy link
Contributor

Hello, I'm not sure I understand your issue.

Are you asking why there is the code pattern of using the Scene class?

@djy89
Copy link
Author

djy89 commented Nov 9, 2024

There is no example illustrating how to use robot_object.attach_tool() and display it on the Viewer.screen below, nor how to change the joint and have the end follow the changes. The example below only displays the robot, but not the tool attached to the robotic arm. Could the official provide a corresponding example that displays the robotic arm and end claw on the Viewer, without necessarily using ROS or Rhino for display.

Can you provide an example related to attach_tool and demonstrate how to display and update joint changes in the Viewer, ensuring that the tool at the end follows the changes, without utilizing ROS or other CAD environments。Thankyou very much。

programe:Only Robot is displayed below。

from compas_robots.viewer.scene.robotmodelobject import RobotModelObject
from compas_viewer.components import Slider
from compas_viewer import Viewer

from compas.datastructures import Mesh
from compas.geometry import Frame
from compas_robots import RobotModel
from compas_robots.model.tool import ToolModel
from compas_robots.resources import LocalPackageMeshLoader
import compas_fab
viewer = Viewer()
viewer.renderer.rendermode="lighted"
urdf_filename ='./ur5.urdf'
model = RobotModel.from_urdf_file(urdf_filename)
model.load_geometry(LocalPackageMeshLoader(compas_fab.get("universal_robot"), "ur_description"), precision=5)
configuration = model.zero_configuration()
robot_object: RobotModelObject = viewer.scene.add(model, show_lines=False, configuration=configuration) # type: ignore
viewer.ui.sidedock.show = True
##############attach_tool_model##################
mesh = Mesh.from_stl("./vacuum_gripper.stl")
frame_t = Frame([0, 0, 0.07], [1, 0, 0], [0, 1, 0])
tool_model = ToolModel(mesh, frame_t, connected_to="wrist_3_link")
robot_object.attach_tool_model(tool_model)###TODO not work!!!!
viewer.renderer.update()
##############attach_tool_model##################

def make_rotate_function(index):
def rotate(slider: Slider, value: int):
config = robot_object.configuration
config.joint_values[index] = value / 360 * 2 * 3.14159
robot_object.update_joints(config)
return rotate

for i, joint in enumerate(robot_object.configuration.joint_names):
rotate_function = make_rotate_function(i)
viewer.ui.sidedock.add(Slider(title=joint, starting_val=0, min_val=-180, max_val=180, step=1, action=rotate_function))
robot_object.update_joints(robot_object.configuration)
viewer.show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants