def getallrobots(package, robotnames, ending= '.urdf.xacro'): for robot in robotnames: github = GithubPackageMeshLoader(package[0], package[1], package[2]) print(github) filename = robot + ending print(filename) # print(str(gh_model.headers)) # print(str(gh_model.status)) gh_model = github.load_urdf(filename) print(str(gh_model.url)) model = RobotModel.from_urdf_file(gh_model) model.load_geometry(github) # print(model) artist = RobotModelArtist(model, layer=robot)
# Before running this example, make sure to run # "docker compose up" on the docker/moveit folder import compas from compas_fab.backends import RosClient from compas_rhino.artists import RobotModelArtist # Set high precision to import meshes defined in meters compas.PRECISION = '12f' # Load robot and its geometry with RosClient('localhost') as ros: robot = ros.load_robot(load_geometry=True) robot.artist = RobotModelArtist(robot.model, layer='COMPAS::Robot Viz') robot.artist.clear_layer() robot.artist.draw()
import compas from compas.robots import GithubPackageMeshLoader from compas.robots import RobotModel from compas_rhino.artists import RobotModelArtist # Set high precision to import meshes defined in meters compas.PRECISION = '12f' # Select Github repository, package and branch where the model is stored r = 'ros-industrial/abb' p = 'abb_irb6600_support' b = 'kinetic-devel' github = GithubPackageMeshLoader(r, p, b) urdf = github.load_urdf('irb6640.urdf') # Create robot model from URDF model = RobotModel.from_urdf_file(urdf) # Also load geometry model.load_geometry(github) # Draw model artist = RobotModelArtist(model, layer='COMPAS::Robot Viz') artist.clear_layer() artist.draw_visual()
model.load_geometry(github) # print(model) artist = RobotModelArtist(model, layer=robot) # artist.scale(1000) # artist.draw_visual() # getallrobots(UR_packages, UR_robots) fanuc_package = ['ros-industrial/fanuc', 'fanuc_m16ib_support', 'kinetic-devel'] fanuc_robots = [ 'm16ib20' ] # getallrobots(fanuc_package,fanuc_robots,'.xacro') abb_package = ['ros-industrial/abb', 'abb_irb6600_support', 'kinetic-devel'] abb_robots = [ 'irb6640' ] # getallrobots(abb_package, abb_robots, '.urdf') # github = GithubPackageMeshLoader('ros-industrial/universal_robot', 'ur_description', 'kinetic-devel') package_path = 'universal_robot' model = RobotModel.from_urdf_file('universal_robot\ur_description\urdf\ur10_robot.urdf') loader = LocalPackageMeshLoader(package_path, 'ur_description') model.load_geometry(loader) artist = RobotModelArtist(model, layer='COMPAS FAB::Example2') artist.draw_visual() artist.draw_collision()
for frame in frames: artist = FrameArtist(frame, scale=0.3, layer="Frames::{}".format(frame.name)) artist.clear_layer() artist.draw() for a, b in pairwise(frames): line = Line(a.point, b.point) artist = LineArtist(line, layer="Links::{}".format(a.name)) artist.draw() tpl = Cylinder(Circle(Plane(Point(0, 0, 0), Vector(0, 0, 1)), 0.05), 0.2) for frame, axis in zip(frames, axes): point = frame.point normal = Vector(axis.x, axis.y, axis.z) plane = Plane(point, normal) frame = Frame.from_plane(plane) X = Transformation.from_frame(frame) cylinder = tpl.transformed(X) artist = CylinderArtist(cylinder, layer="Axes::{}".format(axis.name)) artist.clear_layer() artist.draw() artist = RobotModelArtist(robot, layer="Robot") artist.clear_layer() artist.update(state, collision=False) artist.draw() compas_rhino.wait()
# add first link to robot link0 = robot.add_link("world") # add second link to robot mesh = Mesh.from_shape(cylinder) link1 = robot.add_link("link1", visual_mesh=mesh, visual_color=(0.2, 0.5, 0.6)) # add the joint between the links axis = (0, 0, 1) origin = Frame.worldXY() robot.add_joint("joint1", Joint.CONTINUOUS, link0, link1, origin, axis) # add another link mesh = Mesh.from_shape(cylinder) # create a copy! link2 = robot.add_link("link2", visual_mesh=mesh, visual_color=(0.5, 0.6, 0.2)) # add another joint to 'glue' the link to the chain origin = Frame((length, 0, 0), (1, 0, 0), (0, 1, 0)) robot.add_joint("joint2", Joint.CONTINUOUS, link1, link2, origin, axis) artist = RobotModelArtist(robot) # Exercise: Update the robot's configuration names = ['joint1', 'joint2'] values = [0, 0] joint_state = dict(zip(names, values)) artist.update(joint_state) artist.draw_visual() artist.redraw()
import compas compas.PRECISION = '12f' from compas.robots import * from compas_rhino.artists import RobotModelArtist r = 'ros-industrial/abb' p = 'abb_irb6600_support' b = 'kinetic-devel' github = GithubPackageMeshLoader(r, p, b) urdf = github.load_urdf('irb6640.urdf') robot = RobotModel.from_urdf_file(urdf) robot.load_geometry(github) RobotModelArtist(robot).draw_visual()
import compas from compas_fab.backends import RosClient from compas_rhino.artists import RobotModelArtist # Set high precision to import meshes defined in meters compas.PRECISION = '12f' with RosClient() as ros: # Load complete model from ROS robot = ros.load_robot(load_geometry=True) # Visualize robot robot.artist = RobotModelArtist(robot.model, layer='COMPAS FAB::Example') robot.artist.clear_layer() robot.artist.draw_visual()
head_link = model.add_link('head', visual_meshes=[head, beak]) neck_joint_origin = Frame([0, 0, 4], [1, 0, 0], [0, 1, 0]) model.add_joint('neck_joint', Joint.FIXED, torso_link, head_link, origin=neck_joint_origin) tail = Sphere([0, 0, 0], 1) tail_link = model.add_link('tail', visual_meshes=[tail]) tail_joint_origin = Frame([0, 0, -4], [1, 0, 0], [0, 1, 0]) model.add_joint('tail_joint', Joint.FIXED, torso_link, tail_link, origin=tail_joint_origin) hat = Cylinder(Circle(Plane([0, 0, 0], [0, 0, 1]), .8), 1.5) brim = Cylinder(Circle(Plane([0, 0, -1.5 / 2], [0, 0, 1]), 1.4), .1) hat_link = model.add_link('hat', visual_meshes=[hat, brim]) hat_joint_origin = Frame([0, 0, 1 - .3 + 1.5 / 2], [1, 0, 0], [0, 1, 0]) model.add_joint('hat_joint', Joint.FIXED, head_link, hat_link, origin=hat_joint_origin) artist = RobotModelArtist(model, layer='COMPAS::Example Robot') artist.clear_layer() artist.draw_visual()
# add first link to robot link0 = model.add_link("world") # add second link to robot mesh = Mesh.from_shape(cylinder) link1 = model.add_link("link1", visual_mesh=mesh, visual_color=(0.2, 0.5, 0.6)) # add the joint between the links axis = (0, 0, 1) origin = Frame.worldXY() model.add_joint("joint1", Joint.CONTINUOUS, link0, link1, origin, axis) # add another link mesh = Mesh.from_shape(cylinder) # create a copy! link2 = model.add_link("link2", visual_mesh=mesh, visual_color=(0.5, 0.6, 0.2)) # add another joint to 'glue' the link to the chain origin = Frame((length, 0, 0), (1, 0, 0), (0, 1, 0)) model.add_joint("joint2", Joint.CONTINUOUS, link1, link2, origin, axis) # Create a configuration object matching the number of joints in your model # configuration = .... # Update the model using the artist artist = RobotModelArtist(model) # artist.update ... # Render everything artist.draw_visual() artist.redraw()
from compas.geometry import Frame from compas.robots import LocalPackageMeshLoader from compas.robots import RobotModel from compas_rhino.artists import RobotModelArtist from ur_kinematics import inverse_kinematics_ur5 loader = LocalPackageMeshLoader('models', 'ur_description') model = RobotModel.from_urdf_file(loader.load_urdf('ur5.urdf')) model.load_geometry(loader) f = Frame((0.417, 0.191, -0.005), (-0.000, 1.000, 0.000), (1.000, 0.000, 0.000)) f.point /= 0.001 sols = inverse_kinematics_ur5(f) artist = RobotModelArtist(model, layer='COMPAS::Robot Viz') artist.clear_layer() for joint_values in sols: # Create joint state dictionary joint_names = model.get_configurable_joint_names() joint_state = dict(zip(joint_names, joint_values)) artist.update(joint_state) artist.draw_visual()