Skip to Content
MaintainedWandelscriptExamples

Wandelscript examples

Play around with our simple Wandelscript examples and copy-paste them into Robot Pad. Make yourself familiar with the syntax and structure of Wandelscript. Find the complete example collection  on GitHub.

Examples that require replacing sample values with your actual cell values, e.g. robot controllers, I/Os, etc., are marked with prerequisites below the code.

Below most of the examples, you’ll find a button that directs you to the corresponding quickstart section for more information.

Just copy and paste

Blending

tcp("Flange") home = (-200, -600, 250, 0, -pi, 0) blending(0) blending_start = __ms_blending # =0 velocity(1000) move via p2p() to home move via line() to (0, 200, 0, 0, 0, 0) :: home with blending(1) blending_after_single_line = __ms_blending # =0 with blending(2): blending_in_context = __ms_blending # =2 move via line() to (200, 200, 0, 0, 0, 0) :: home with blending(500) blending_in_context_after_single_line = __ms_blending # =2 blending_after_context = __ms_blending # =0 move via p2p() to home def move_line_1(pose): move via line() to pose :: home return __ms_blending blending_initial_in_function = move_line_1((200, 200, 0, 0, 0, 0)) # =0 with blending(3): blending_in_context_in_function = move_line_1((200, 200, 0, 0, 0, 0)) # =3 move via line() to (200, 0, 0, 0, 0, 0) :: home with blending(500) blending_in_context_after_single_line_in_function = __ms_blending # =3 blending_end = __ms_blending # =0

Bottle opener

This example requires you to add the TCP Bottle_opener_s to your robot in Setup.

# This requires the "Bottle_opener_s" TCP to exist in your robot. home = (552.9, 339.5, 274, 1.2232, -2.8803, 0.0255) bottle = (671.9, 411.4, 210, -0.9615, 2.304, 0.3044) moveOpen = (-12,0,-10,0,0.65,0) Bottle_opener_s = frame("Bottle_opener_s") velocity(50) move Bottle_opener_s via p2p() to home # approach move Bottle_opener_s via line() to bottle :: (0,0,-10,0,0,0) # open velocity(10) move Bottle_opener_s via line() to bottle wait(750) move Bottle_opener_s via line() to bottle :: moveOpen # retreat velocity(50) move Bottle_opener_s via line() to (-10, 0, 20, 0, 0, 0) :: bottle :: moveOpen move Bottle_opener_s via p2p() to home

Expressions

a = 1 + 4 b = 4 * 2 + 3 c = 3 + 4 * 2 d = (3 + 4) * 2 e = a * 4 f = 4 - 6 g = 3 - 2 h = - 8 + 5 i = - (8 + 5) j, k = [1, 4] l = 3 < 4 m = 4 < 3 n = True == True o = False == True p = a == 5 q = 5 == a r = a == 4 s = a == a t = a - 1 == 4 u = 4 == a - 1 v = a + 1 == a + 1 w = a + 1 == a + 2 x = True != True y = False != True z = a != e def true(): return True aa = true() == true() ab = [1, 2, 3][0] == [1, 2, 3][0]

Functions

a = 1 + 4 b = 4 * 2 + 3 c = 3 + 4 * 2 d = (3 + 4) * 2 e = a * 4 f = 4 - 6 g = 3 - 2 h = - 8 + 5 i = - (8 + 5) j, k = [1, 4] l = 3 < 4 m = 4 < 3 n = True == True o = False == True p = a == 5 q = 5 == a r = a == 4 s = a == a t = a - 1 == 4 u = 4 == a - 1 v = a + 1 == a + 1 w = a + 1 == a + 2 x = True != True y = False != True z = a != e def true(): return True aa = true() == true() ab = [1, 2, 3][0] == [1, 2, 3][0]

Functional poses

a = (1, 2, 3, 0.4, 0.5, 0.6) b = (4, 2, 5, 0.1, 0.3, 0.5) c = a :: b def func_a(): return a def func_b(): return b func_c1 = func_a :: b evaled_c1 = func_c1() func_c2 = a :: func_b evaled_c2 = func_c2() func_c3 = func_a :: func_b evaled_c3 = func_c3()

Controller specific

Read pose

tcp("Flange") move via p2p() to (-200, -600, 300, 0, pi, 0) move via line() to (-250, -600, 300, 0, pi, 0) a = planned_pose() python_print(a) b = read(robot, 'pose') python_print(b)

Prerequisite: Replace robot with the controller id.

With I/Os

Asynchronous write

write(controller, 'tool_out[0]', True) move via p2p() to (-200, -600, 300, 0, -3, 0) write(controller, 'tool_out[0]', False) move via line() to (-200, -600, 100) a = read(controller, 'tool_out[0]') write(controller, 'tool_out[0]', True) move via line() to (-200, -600, 150) b = read(controller, 'tool_out[0]')

Prerequisite:

  • I/O has to be defined in your cell. Replace tool_out[0] with the I/O.
  • Replace controller with the controller id.

Find edge from 4 poses

start_left = (775.2, -473.7, 262.2, 2.916, -0.062, 1.195) # pose whose xy-plane is parallel to the left surface and the origin is close to start position end_left = (795.4, 60.7, 272.7, 2.92, -0.062, 1.185) # pose whose xy-plane is parallel to the left surface and the origin is close to end position start_right = (799.8, -467.0, 265.4, 2.866, -0.213, -1.158) # pose whose xy-plane is parallel to the right surface and the origin is close to start position end_right = (817.1, 54.6, 255.7, 2.866, -0.213, -1.158) # pose whose xy-plane is parallel to the right surface and the origin is close to end position radius = 8 # the desired radius of the final edge spacing = 40 # the distance between to zig-zag corners edge_poses = find_edge_from_4_poses(start_left, end_left, start_right, end_right) start = to_position(edge_poses[0]) end = to_position(edge_poses[1]) n = int(distance(start, end) / spacing) plane_orientations = [to_orientation(edge_poses[0]), to_orientation(edge_poses[1])] center_rotation = interpolate(plane_orientations[0], plane_orientations[1], 0.5) offset = (0, 0, -radius, 0, 0, 0) offset_from_axis = center_rotation :: (0, 0, distance_from_corner(edge_poses[0], edge_poses[1], radius), 0, 0, 0) :: ~center_rotation b = 0 move via p2p() to (0, 0, 100, 0, 0, 0) :: to_pose(start) :: offset_from_axis :: plane_orientations[0] :: offset :: (0, 0, -100, 0, 0, 0) move via line() to to_pose(start) :: offset_from_axis :: plane_orientations[0] :: offset sync write(controller, "10020#0009", True) sync for i = 0..<int(n / 2): c = b a = interpolate(to_pose(start), to_pose(end),(2 * i + 1) / n ) :: offset_from_axis :: center_rotation :: offset b = interpolate(to_pose(start), to_pose(end),(2 * i + 2) / n ) :: offset_from_axis :: plane_orientations[modulo(i + 1, 2)] :: offset python_print(to_position(b)) move via arc(a) to b # FIX: without the following line the last motion is a circular and the first motion cannot be a circular move via p2p() to b if i == 1: test_pose = planned_pose() sync write(controller, "10020#0009", False) sync

Prerequisite:

  • Ensure that start_left, end_left, start_right and end_right can be reached collision-free by the robot.
  • Replace controller with the controller id.
  • I/O has to be defined in your cell. Replace 10020#0009 with the I/O.
Last updated on