Main Page Class Hierarchy Compound List File List Compound Members File Members

# Pusher Class Reference

`#include <Pusher.h>`

Inheritance diagram for Pusher:

List of all members.

## Detailed Description

This class implements the pushing behavior of the robot. The robot approaches the cube and tries to push it to its cluster point. If the robot meets other robots on its way it tries to avoid them.

Author:
  Jia L. Du

## Public Member Functions
| Pusher ()
int | activate ()
## Static Public Attributes
const int | ARRIVED = 0
const int | CUBE_LOST = 1
const int | DRIVE_STALLED = 2
## Private Member Functions
int | approachCube ()
bool | avoidRobot ()
bool | checkForCube (bool backup)
int | pushCube ()
bool | chooseClusterPoint (bool forceChoiceOfClusterPoint)
## Private Attributes
int | minimumWaitingPeriod
int | maximumWaitingPeriod
## Static Private Attributes
const int | APPROACH_CUBE_ARRIVED = 22
const int | APPROACH_CUBE_CUBE_LOST = 21
const int | APPROACH_CUBE_MET_ROBOT = 20
const int | APPROACH_CUBE_NEW_CLUSTER_POINT_CHOSEN = 23
const int | PUSH_CUBE_MET_ROBOT = 10
const int | PUSH_CUBE_CUBE_LOST = 11
const int | PUSH_CUBE_ARRIVED = 12

## Constructor & Destructor Documentation

Pusher::Pusher | ( |  | ) |

## Member Function Documentation

int Pusher::activate | ( |  | ) |

| Activates this behavior Returns: A result code indicating why this behavior terminated. Pusher.ARRIVED, PUSHER. CUBE_LOST or Pusher.DRIVE_STALLED

int Pusher::approachCube | ( |  | ) | `[private]`

| Makes the robot approaching the closest cube such that the robot has a good starting position to push the cube to its cluster point in a next step. If no radio communication is used: To determine a common cluster point this method also calls Pusher::chooseClusterPoint to measure the cluster density around the cube to approach. If favorable the location of the cube to approach is chosen as new cluster point (i.e. if there are more cubes in this area then at the home cluster point we start pushing cubes to here as this is faster. And if every robot pushes cubes to the larger cluster points at the end a single cluster point will remain) See also: Pusher::chooseClusterPoint Returns: Pusher::APPROACH_CUBE_ARRIVED or Pusher::APPROACH_CUBE_MET_ROBOT or Pusher::APPROACH_CUBE_CUBE_LOST or Pusher::APPROACH_CUBE_NEW_CLUSTER_POINT_CHOSEN

bool Pusher::avoidRobot | ( |  | ) | `[private]`

| Used to avoid other robots by backing up and trying to go back to the old position after a random time See also: minimumWaitingPeriod maximumWaitingPeriod Returns: true if successful

bool Pusher::checkForCube | ( | bool | backup | ) | `[private]`

  | Tries to retrieve or re-discover a lost cube by turning slightly left and right Parameters:
  backup | if true the robot backs up before trying to re- discover the cube
Returns: true if successful

bool Pusher::chooseClusterPoint | ( | bool | forceChoiceOfClusterPoint | ) | `[private]`

  | If no communication is used the Pusher determines the cluster point for the robot. It does that by comparing the cube density of its own cluster with the density of the newly detected cluster. It chooses the cluster with the higher density as the new cluster point. A new cluster point is set by resetting the robot position. (0,0) is always used as cluster point position as it is easier to push cubes to that position. Thus if a new cluster point is chosen the current robot position is adapted See also: Behavior::myClusterPointDensity Parameters:
  forceChoiceOfClusterPoint | if true the robot is forced to choose a new cluster point, even if the density of the cluster in front of the robot is smaller then the home cluster density (This flag is used to re-measure the home cluster density and re-set the robot's coordinate system after arriving home from a pushing operation)
Returns: true if a new cluster point was chosen

int Pusher::pushCube | ( |  | ) | `[private]`

| Makes the robot pushing the cube in front of him to its cluster point, i.e. (0,0). This methods uses Drive::driveCurveTo to push the cube to the cluster point, that means the angle from the current position (x,y,phi) of the robot to the cluster point should be less then 135 degrees, preferably less then 60 degrees. The robot uses the front infra-red sensor to check if the cube is still there. If the robot meets an obstacle it tries to avoid the obstacle and retrieve the cube See also: Drive::driveCurveTo Pusher::avoidRobot Returns: Pusher::PUSH_CUBE_CUBE_LOST or Pusher::PUSH_CUBE_ARRIVED or Pusher::PUSH_CUBE_MET_ROBOT

## Member Data Documentation

const int Pusher::APPROACH_CUBE_ARRIVED = 22`[static, private]`

| Used internally as result code for Pusher::approachCube()

const int Pusher::APPROACH_CUBE_CUBE_LOST = 21`[static, private]`

| Used internally as result code for Pusher::approachCube()

const int Pusher::APPROACH_CUBE_MET_ROBOT = 20`[static, private]`

| Used internally as result code for Pusher::approachCube()

const int Pusher::APPROACH_CUBE_NEW_CLUSTER_POINT_CHOSEN = 23`[static, private]`

| Used internally as result code for Pusher::approachCube()

const int Pusher::ARRIVED = 0`[static]`

| Used as result code for Pusher::activate()

const int Pusher::CUBE_LOST = 1`[static]`

| Used as result code for Pusher::activate()

const int Pusher::DRIVE_STALLED = 2`[static]`

| Used as result code for Pusher::activate()

int Pusher::maximumWaitingPeriod`[private]`

| Determines how long the robot should wait at most before trying to continue its task after being interrupted by another robot See also: Pusher::avoidRobot()

int Pusher::minimumWaitingPeriod`[private]`

| Determines how long the robot should wait at least before trying to continue its task after being interrupted by another robot See also: Pusher::avoidRobot()

const int Pusher::PUSH_CUBE_ARRIVED = 12`[static, private]`

| Used internally as result code for Pusher::pushCube()

const int Pusher::PUSH_CUBE_CUBE_LOST = 11`[static, private]`

| Used internally as result code for Pusher::pushCube()

const int Pusher::PUSH_CUBE_MET_ROBOT = 10`[static, private]`

| Used internally as result code for Pusher::pushCube()