shady.common
Class ShadyState

java.lang.Object
  extended by shady.common.ShadyState
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ShadyState
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A representation of the intrinsic state of the mechanism.

The barrel angles (barrelAngle) are defined so that when they are 0 the corresponding gripper can attach to an environment segment that is coincident with the line joining the barrel centers. A positive barrel angle means that the barrel has rotated counterclockwise relative to the vector pointing from the left barrel to the right barrel.

We can define the "left barrel vector" as the unit vector which starts at the left barrel center and makes the CCW angle leftAngle from the vector that starts at the left barrel center and ends at the right barrel center.

A "right barrel vector" can be defined in a rotationally-symmetric way, i.e. it is the unit vector which starts at the right barrel center and makes the CCW angle rightAngle from the vector that starts at the left barrel center and ends at the right barrel center.

We can define the shady body vector as the vector from the left barrel center to the right barrel center.

The gripper states (gripperState) are always in the range [0.0, 1.0]. 0.0 means fully open, 1.0 means fully closed.

A number of coordinate frames are defined for the Shady mechanism. All are right-handed. Coordinate frames:

left mechanism frame
origin at left barrel center, +x towards right barrel center, +z pointing away from the window (into the room interior)
left barrel frame
origin at left barrel center, +x along left barrel vector, +z pointing away from the window (into the room interior)
mechanism frame
origin at bone center, +x towards right barrel center, +z pointing away from the window (into the room interior)
right mechanism frame
origin at right barrel center, +x towards left barrel center, +z pointing away from the window (into the room interior)
right barrel frame
origin at right barrel center, +x along right barrel vector, +z pointing away from the window (into the room interior)
Note that the +y axes of the mechanism, left mechanism, and left barrel frame (when the left barrel is at angle 0) all point "up" (towards the sky) when shady is horizontal, but the +y axes of the right mechanism frame and the right barrel frame (when the right barrel is at angle 0) point down.

Copyright (C) 2006 Marsette A. Vona, III

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Author:
Marsette (Marty) A. Vona, III
See Also:
Serialized Form

Field Summary
 double[] barrelAngle
          The angles of the barrels, in degrees.
static double CLOSED_STATE
          Identifies a closed gripper.
 double currentPower
          The current total power usage, in Watts.
private static java.lang.String cvsid
          CVS id.
 int fault
          The current Fault, or 0 if none.
 java.lang.String faultDetails
          Human-readable details of the current Fault, or null if none.
static int GRIPPER_CLOSE
          Identifies a gripper close operation.
static int GRIPPER_OPEN
          Identifies a gripper open operation.
 double[] gripperState
          The states of the grippers.
static int LEFT
          Identifies the left barrel.
 int numActiveActuators
          The current number of active actuators.
static double OPEN_STATE
          Identifies an open gripper.
static int RIGHT
          Identifies the right barrel.
 double shadeAngle
          Current signed shade angle in CCW degrees.
 
Constructor Summary
ShadyState()
           
 
Method Summary
 ShadyState copy()
          Return a clone().
 ShadyState copyInto(ShadyState dest)
          Copy into dest.
 int decNumActiveActuators()
          Decreases the number of active actuators by one, iff it was > 0.
 double getBarrelAngle(int barrel)
          Get a barrel angle.
 double getCurrentPower()
          Get the current power of the whole mechanism in Watts.
 int getFault()
          Convenience method covers getFault(java.lang.String[]) without getting the details.
 int getFault(java.lang.String[] faultDetails)
          Get the current fault.
 double getGripperState(int barrel)
          Get a gripper state.
 int getNumActiveActuators()
          Gets the number of active actuators.
 double getShadeAngle()
          Convenience synchronized accessor.
 int incNumActiveActuators()
          Increases the number of active actuators by one.
 void setBarrelAngle(int barrel, double angle)
          Set a barrel angle.
 void setCurrentPower(double currentPower)
          Set the current power of the whole mechanism in Watts.
 boolean setFault(int fault, java.lang.String faultDetails)
          Atomically set fault and faultDetails iff there is no existing fault.
 void setGripperState(int barrel, double state)
          Set a gripper state.
 void setShadeAngle(double shadeAngle)
          Convenience synchronized accessor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsid

private static final java.lang.String cvsid

CVS id.

See Also:
Constant Field Values

LEFT

public static final int LEFT

Identifies the left barrel.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT

Identifies the right barrel.

See Also:
Constant Field Values

CLOSED_STATE

public static final double CLOSED_STATE

Identifies a closed gripper.

See Also:
Constant Field Values

OPEN_STATE

public static final double OPEN_STATE

Identifies an open gripper.

See Also:
Constant Field Values

GRIPPER_CLOSE

public static final int GRIPPER_CLOSE

Identifies a gripper close operation.

See Also:
Constant Field Values

GRIPPER_OPEN

public static final int GRIPPER_OPEN

Identifies a gripper open operation.

See Also:
Constant Field Values

barrelAngle

public double[] barrelAngle

The angles of the barrels, in degrees.

See class header doc for semantics.


gripperState

public double[] gripperState

The states of the grippers.

See class header doc for semantics.


shadeAngle

public double shadeAngle

Current signed shade angle in CCW degrees.


currentPower

public double currentPower

The current total power usage, in Watts.


numActiveActuators

public int numActiveActuators

The current number of active actuators.


fault

public int fault

The current Fault, or 0 if none.

Once the mechanism enters a fault state, that state will persist at least until ShadyCommonAPI.reset() is called. That is, while the mechanism is in fault, no subsequent fault will be registered.

Implementations must fail-fast calls to the mutator methods ShadyCommonAPI.rotateBarrel(int, double), ShadyCommonAPI.openGripper(int), and ShadyCommonAPI.closeGripper(int, shady.common.Point.OnSegment) while the mechanism is in fault.

Additional details may be available from faultDetails.


faultDetails

public java.lang.String faultDetails

Human-readable details of the current Fault, or null if none.

Constructor Detail

ShadyState

public ShadyState()
Method Detail

getBarrelAngle

public double getBarrelAngle(int barrel)

Get a barrel angle.

Parameters:
barrel - the barrel angle to get
Returns:
the requested barrel angle

setBarrelAngle

public void setBarrelAngle(int barrel,
                           double angle)

Set a barrel angle.

No limit checking is done.

Parameters:
barrel - the barrel angle to get
angle - the angle

getGripperState

public double getGripperState(int barrel)

Get a gripper state.

Parameters:
barrel - the barrel containing the gripper to get
Returns:
the state of the gripper in the range [0.0, 1.0], with 0.0 open and 1.0 closed

setGripperState

public void setGripperState(int barrel,
                            double state)

Set a gripper state.

Parameters:
barrel - the barrel containing the gripper to get
state - the state of the gripper in the range [0.0, 1.0], with 0.0 open and 1.0 closed

getShadeAngle

public double getShadeAngle()

Convenience synchronized accessor.


setShadeAngle

public void setShadeAngle(double shadeAngle)

Convenience synchronized accessor.


setCurrentPower

public void setCurrentPower(double currentPower)

Set the current power of the whole mechanism in Watts.

Parameters:
currentPower - the current power of the whole mechanism in Watts

getCurrentPower

public double getCurrentPower()

Get the current power of the whole mechanism in Watts.

Returns:
the current power of the whole mechanism in Watts

getNumActiveActuators

public int getNumActiveActuators()

Gets the number of active actuators.

Returns:
the number of active actuators

incNumActiveActuators

public int incNumActiveActuators()

Increases the number of active actuators by one.

Returns:
the number of active actuators after inc

decNumActiveActuators

public int decNumActiveActuators()

Decreases the number of active actuators by one, iff it was > 0.

Returns:
the number of active actuators after dec

setFault

public boolean setFault(int fault,
                        java.lang.String faultDetails)

Atomically set fault and faultDetails iff there is no existing fault.

Parameters:
fault - the fault to set (0 to set no fault)
faultDetails - the fault details to set, may be null
Returns:
true iff there was no existing fault

getFault

public int getFault(java.lang.String[] faultDetails)

Get the current fault.

Parameters:
faultDetails - if non-null and containing at least one element, the first element of this array is set on return to the current fault details
Returns:
the current fault

getFault

public int getFault()

Convenience method covers getFault(java.lang.String[]) without getting the details.


copy

public ShadyState copy()

Return a clone().

Returns:
a clone

copyInto

public ShadyState copyInto(ShadyState dest)

Copy into dest.

Parameters:
dest - the destination of the copy, or null to cons a new one
Returns:
the copy