Sawyer Controller

This file acts as a wrapper for the intera interface to control the sawyer arm. It contains a class with various methods for a controlling the sawyer arm to throw a bean bag.

class the_mighty_sawyer.sawyer_controller.MoveArm[source]

Class containing methods to fully interact with the sawyer arm.

CloseGripper()[source]

Calls the method to close the gripper.

EnableRobot()[source]

Enables the Sawyer robot.

InitializeGripper()[source]

Calls the sequence of methods to calibrate the gripper. This should be at the beginning of every launch.

OpenGripper()[source]

Calls the method to open the gripper.

actuate_gripper(state)[source]

Method to actuate the grippers given an input.

INPUT:
state (bool): value of 1 to open the grippers and 0 to close
do_over_hand_toss(release_angle=None, throwing_speed=None, target_angle=None)[source]

Calls the the subsequent functions to throw the bag with an overhanded throw. This is good for up to a 3 ft throw outside of sawyers range.

INPUT:

release_angle: Change the angle threshold that the gripper will open at during the throwing motion

throwing_speed: Set the ratio for the speed of all joints during the throwing motion

target_angle: Change the angle of the base joint to point the throwing motion in a different direction

do_under_hand_toss(release_angle=None, throwing_speed=None, target_angle=None)[source]

Calls the the subsequent functions to throw the bag with an underhanded throw. This is good for up to a 3 inch throw outside of sawyers range.

INPUT:

release_angle: Change the angle threshold that the gripper will open at during the throwing motion

throwing_speed: Set the ratio for the speed of all joints during the throwing motion

target_angle: Change the angle of the base joint to point the throwing motion in a different direction

go_to_bag_pos(delay_time)[source]

DEPRICIATED Move the wrist area forward by 90deg. from the home position. Ideally, this is called when the robot is already located at the home position.

This method is called to indicate that sawyer has identified a bean bag using the arm camera and will wait for 3 second for a user to position a bag between its gripper.

INPUT: delay_time: amount of seconds sawyer will give the user to position a bag. Should be any number > 0

go_to_home_pos()[source]

Moves the arm to a preconfigured home position by setting joint angles directly.

This position has the arm folded up infront of the base with the arm camera facing forward. The arm camera will be used to start searching for a bean bag.

initializaton()[source]

Higher-level function that performs Sawyer-related initializations.

overhand_throw()[source]

This function actuates the arm to throw overhanded. It should be called directly after the overhand throw start position.

overhand_throw_start()[source]

Moves the arm to a preset position to prepare for an overhanded throw.

This function only is able to target the area to sawyer left.

print_joint_states()[source]

Prints the joint angle for all joints

print_pose()[source]

Prints the pose of the end effector

reset_default_settings()[source]

This method is used to reset the class parameters to their initial values.

underhand_throw()[source]

This function actuates the arm to throw underhanded. It should be called directly after the underhand throw start position.

underhand_throw_start()[source]

Moves the arm to a preset position to prepare for an underhanded throw.

This motion is done in two stages to avoid motions close to the body.

Image Library

Provides functions for visual aspects of project (cameras, display images, etc).

the_mighty_sawyer.imagelib.display_png(img_name, bg_color=(255, 255, 255))[source]

Displays a png image from imagaes/display directory on Sawyer’s screen. Cannot handle images larger than 1024 x 600. Good emojis here: https://emojiisland.com/pages/free-download-emoji-icons-png :param img_name: (string) - name of image to display :param bg_color: (b, g, r) color to make background

the_mighty_sawyer.imagelib.put_text(text, bg_color=(255, 255, 255), text_color=(0, 0, 0), scale=3, thickness=4)[source]

Write text to Sawyer’s display screen

Parameters:
  • text – string- test to displya
  • bg_color – (b,g,r)- background color
  • text_color – (b,g,r)- text color
  • scale – float- font size
  • thickness – float- font thickness
Returns:

the_mighty_sawyer.imagelib.set_exposure(cam, val)[source]

sets exposure of selected camera

the_mighty_sawyer.imagelib.switch_camera(cam)[source]

Change active camera feed on Sawyer :param cam: (string) camera to activate (head, arm)

Helper Functions

General Helper Functions

the_mighty_sawyer.tms_helper_functions.find_true(alist)[source]

Find the indices in a list where they are Trues

the_mighty_sawyer.tms_helper_functions.get_dist(pose1, pose2)[source]

Calculates the Euclidean distance between two poses.

the_mighty_sawyer.tms_helper_functions.get_params_from_yaml(filename)[source]

Opens yaml file (from the relative path) and returns the data