Handlers

Shared

dummySensor.py - Dummy Sensor Handler

Displays a silly little window for faking sensor values by clicking on buttons.

class handlers.share.dummySensor.sensorHandler(proj, shared_data)
buttonPress(button_name, init_value, initial=False)

Return a boolean value corresponding to the state of the sensor with name sensor_name If such a sensor does not exist, returns None

button_name (string): Name of the sensor whose state is interested init_value (bool): The initial state of the sensor (default=False)

regionBit(name, init_region, bit_num, initial=False)

Return the value of bit #bit_num in the bit-vector encoding of the currently selected region

name (string): Unique identifier for region sensor (default=”target”) init_region (region): Name of the sensor whose state is interested bit_num (int): The index of the bit to return

dummyActuator.py - Dummy Actuator Handler

Does nothing more than print the actuator name and state; for testing purposes.

class handlers.share.dummyActuator.actuatorHandler(proj, shared_data)
setActuator(name, actuatorVal, initial)

Pretends to set actuator of name name to be in state val (bool).

name (string): Name of the actuator

Pose

basicSimPose.py - 2D Pose provider for basicSimulator

class handlers.pose.basicSimPose.poseHandler(proj, shared_data)
getPose(cached=False)

Returns the most recent (x,y,theta) reading from basic simulator

NullPose.py - Pose Handler for single region without Vicon

class handlers.pose.NullPose.poseHandler(proj, shared_data, initial_region)
getPose(cached=False)
setPose(x, y, theta)
class handlers.pose.rosPose.poseHandler(proj, shared_data, modelName='pr2')
getPose(cached=False)

viconPose.py - Pose Handler for Vicon System

class handlers.pose.viconPose.poseHandler(proj, shared_data, host, port, x_VICON_name, y_VICON_name, theta_VICON_name)
getPose(cached=False)

Drive

differentialDrive.py - Differential Drive Handler

Converts a desired global velocity vector into translational and rotational rates for a differential-drive robot, using feedback linearization.

class handlers.drive.differentialDrive.driveHandler(proj, shared_data, d=0.6)
setVelocity(x, y, theta=0)

holonomicDrive.py - Ideal Holonomic Point Drive Handler

Passes velocity requests directly through. Used for ideal holonomic point robots.

class handlers.drive.holonomicDrive.driveHandler(proj, shared_data, multiplier, maxspeed)
setVelocity(x, y, theta=0)

Motion Control

heatController.py - Potential Field Region-to-Region Motion Control

Uses the heat-controller to take a current position, current region, and destination region and return a global velocity vector that will help us get there

class handlers.motionControl.heatController.motionControlHandler(proj, shared_data)
get_controller(current, next, last, cache={})

Wrapper for the controller factory, with caching.

gotoRegion(current_reg, next_reg, last=False)

If last is true, we will move to the center of the region.

Returns True if we are outside the supposed current_reg

vectorController.py - Vector Addition Motion Controller

Uses the vector field algorithm developed by Stephen R. Lindemann to calculate a global velocity vector to take the robot from the current region to the next region, through a specified exit face.

class handlers.motionControl.vectorController.motionControlHandler(proj, shared_data)
gotoRegion(current_reg, next_reg, last=False)

If last is True, we will move to the center of the destination region.

Returns True if we’ve reached the destination region.

RRTController.py - Rapidly-Exploring Random Trees Motion Controller

Uses Rapidly-exploring Random Tree Algorithm to generate paths given the starting position and the goal point.

class handlers.motionControl.RRTController.motionControlHandler(proj, shared_data, robot_type, max_angle_goal, max_angle_overlap, plotting)
buildTree(p, theta, regionPoly, nextRegionPoly, q_gBundle, face_normal, last=False)

This function builds the RRT tree. p : x,y position of the robot theta : current orientation of the robot regionPoly : current region polygon nextRegionPoly : next region polygon q_gBundle : coordinates of q_goals that the robot can reach face_normal : the normal vector of each face corresponding to each goal point in q_gBundle

createRegionPolygon(region, hole=None)

This function takes in the region points and make it a Polygon.

data_gen()
generateNewNode(V, V_theta, E, Other, regionPoly, stuck, append_after_latest_node=False)

Generate a new node on the current tree matrix V : the node matrix V_theta : the orientation matrix E : the tree matrix (or edge matrix) Other : the matrix containing the velocity and angular velocity(omega) information regionPoly: the polygon of current region stuck : count on the number of times failed to generate new node append_after_latest_node : append new nodes to the latest node (True only if the previous node addition is successful)

getNode(p, V, E, last=False)

This function calculates the velocity for the robot with RRT. The inputs are (given in order):

p = the current x-y position of the robot

E = edges of the tree (2 x No. of nodes on the tree) V = points of the tree (2 x No. of vertices) last = True, if the current region is the last region

= False, if the current region is NOT the last region
getVelocity(p, V, E, last=False)

This function calculates the velocity for the robot with RRT. The inputs are (given in order):

p = the current x-y position of the robot E = edges of the tree (2 x No. of nodes on the tree) V = points of the tree (2 x No. of vertices) last = True, if the current region is the last region

= False, if the current region is NOT the last region
gotoRegion(current_reg, next_reg, last=False)

If last is True, we will move to the center of the destination region. Returns True if we’ve reached the destination region.

jplot()
orientation_bound(theta)

make sure the returned angle is between 0 to 2*pi

plotMap(mappedRegions)

Plotting regions and obstacles with matplotlib.pyplot

number: figure number (see on top)

plotPoly(c, string, w=1)

Plot polygons inside the boundary c = polygon to be plotted with matlabplot string = string that specify color w = width of the line plotting

Robot-specific handlers

TODO