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

Feature/robot #188

Merged
merged 8 commits into from
Jul 18, 2024
Merged

Feature/robot #188

merged 8 commits into from
Jul 18, 2024

Conversation

PingHsunTsai
Copy link
Collaborator

@PingHsunTsai PingHsunTsai commented Jul 5, 2024

What type of change is this?

@PingHsunTsai PingHsunTsai requested a review from Licini July 5, 2024 12:26
@Licini
Copy link
Collaborator

Licini commented Jul 8, 2024

The error you saw comes from L109 and L121 where the visual_object was inited before added to scene.

@@ -287,6 +287,7 @@ def init(self):
self.make_buffers()
self._update_matrix()
self.instance_color = Color.from_rgb255(*next(self.viewer.scene._instance_colors_generator))
# TODO: check robot add instance color error
self.scene.instance_colors[self.instance_color.rgb255] = self
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what I can do here is to change to self.viewer.scene just like L289 so it will be able to access it no matter when, I will push it to main now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats very cool. Then should we just use self.viewer.scene instead of self.scene in other place as well? cus it access the same instance anyway?

@PingHsunTsai
Copy link
Collaborator Author

@Licini and @tomvanmele this PR also ready!

scripts/robot.py Outdated Show resolved Hide resolved
scripts/robot.py Outdated Show resolved Hide resolved
scripts/robot.py Outdated Show resolved Hide resolved
@PingHsunTsai PingHsunTsai requested a review from Licini July 12, 2024 15:49
@Licini Licini merged commit d5f974b into main Jul 18, 2024
11 checks passed
@yck011522
Copy link

Yay. Thanks a lot for this PR.

@djy89
Copy link

djy89 commented Nov 8, 2024

do you know, in this class,robot_object: RobotModelObject = viewer.scene.add(model,..... How to assemble a robot tool,and show in viewer.(not show in ros or rhino.)
.....
robot_object: RobotModelObject = viewer.scene.add(model,.....
robot.attach_tool(tool,group,ee_link_name)
robot_object.attach_tool_model(tool.tool_model)
robot_object.update(config)
viewer.renderer.update()
。。。The above does not work。。。。

@djy89
Copy link

djy89 commented Nov 8, 2024

Thank you very much. I would like to add a tool for the robotic arm in this example and display it in the Viewer, instead of displaying the robotic arm on interfaces like ROS Rhino. We are using compas_view, But the tool I added in this way doesn't work. Can you design a robot that can attach a display example of the end tool as a reference. What issues do I need to pay attention to.
me:
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)
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()

@tomvanmele
Copy link
Member

hi,

could you post this on the forum, or on the issue tracker, instead of on a closed pull request?

thanks!

@djy89
Copy link

djy89 commented Nov 8, 2024 via email

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

Successfully merging this pull request may close these issues.

5 participants