shady.sim.multi
Class MemberShadySim

java.lang.Object
  extended by shady.common.ShadyCommon
      extended by shady.sim.ShadySim
          extended by shady.sim.multi.MemberShadySim
All Implemented Interfaces:
MemberShadyCommonAPI, ShadyCommonAPI, MemberShadySimAPI, ShadySimAPI

public class MemberShadySim
extends ShadySim
implements MemberShadySimAPI

MemberShady simulator implementation.

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

Nested Class Summary
protected  class MemberShadySim.MemberGripperMotion
          Extends MemberShadySim.MemberGripperMotion to synchronize on multiShadySim while ShadySim.Motion.stepping if we have one.
protected  class MemberShadySim.MemberRotateMotion
          Extends MemberShadySim.MemberRotateMotion to synchronize on multiShadySim while ShadySim.Motion.stepping if we have one and to MultiEnvironment.place() as necessary.
 
Nested classes/interfaces inherited from class shady.sim.ShadySim
ShadySim.BarrelMotion, ShadySim.GripperMotion, ShadySim.Motion, ShadySim.RotateMotion, ShadySim.ShadeMotion, ShadySim.SimultaneousMotion
 
Field Summary
private static java.lang.String cvsid
          CVS id.
protected  int index
          Our index in multiShadySim.
protected  MultiShadySimAPI multiShadySim
          The MultiShadySim of which we're a member.
 
Fields inherited from class shady.sim.ShadySim
discreteMode, SLEEP_GRANULARITY, STEP_TIME
 
Fields inherited from class shady.common.ShadyCommon
accountingInfo, accumulatedBarrelRotation, accumulatedShadeRotation, accumulating, BARREL_NAME, bodySegment, CC, clock, DEFAULT_GRIPPER_SLOP, DEFAULT_SHADE_OPEN_ANGLE, DEFAULT_SHADE_SLOP, DEFAULT_UPDATE_TIME, ENERGY, FAULT_NAME, GRIPPER_OPERATION_NAME, name, NOMINAL_BARREL_ROTATE_POWER, NOMINAL_BARREL_ROTATION_LIMIT, NOMINAL_BARREL_ROTATION_SPEED, NOMINAL_CENTER_TO_CENTER_DISTANCE, NOMINAL_GRIPPER_CLOSE_POWER, NOMINAL_GRIPPER_CLOSE_TIME, NOMINAL_GRIPPER_OPEN_POWER, NOMINAL_GRIPPER_OPEN_TIME, NOMINAL_GRIPPER_WIDTH, NOMINAL_MIN_ENERGY, NOMINAL_QUIESCENT_POWER, NOMINAL_SHADE_ROTATION_SPEED, NOMINAL_TOTAL_BATTERY_ENERGY, NOMINAL_TOTAL_LENGTH, pose, state, TIME, updateThread, wouldDuelOverride, wouldTiltOverride
 
Fields inherited from interface shady.common.ShadyCommonAPI
CLOSED_STATE, COLLISION, ESTOP, GRIPPER_CLOSE, GRIPPER_OPEN, GRIPPER_OPERATION_TARGET_STATE, IMPLEMENTATION_FAULT, LEFT, LOW_BATTERY, MOTION_LIMIT, OPEN_STATE, OVER_CURRENT, OVER_TEMP, RIGHT, TILT, TIMEOUT, UNALIGNED, UNKNOWN, WOULD_COLLIDE, WOULD_DUEL, WOULD_MOTION_LIMIT, WOULD_TILT
 
Constructor Summary
MemberShadySim()
          Create a MemberShadySim with no pose.
MemberShadySim(ShadyPose pose)
          Create a MemberShadySim with a given pose.
 
Method Summary
 boolean bothGrippersClosed()
          Check whether both grippers are closed.
protected  void closeGripperPost(int barrel, Point.OnSegment gripPoint)
          Last part of ShadyCommon.closeGripper(int, Point.OnSegment).
protected  void closeGripperPostImpl(int barrel, Point.OnSegment gripPoint)
          Implementation of openGripperPost(int), separated so that we can synchronize on multiShadySim if we have one.
 int getIndex()
          Get the zero-based index of this member in its MultiShady.
 MultiShadyCommonAPI getMultiShady()
          Get the MultiShady to which this MemberShady belongs.
protected  vona.time.Clock makeClock()
          Instantiate ShadyCommon.clock.
protected  ShadySim.GripperMotion makeGripperMotion(int barrel, double ds)
          Make a GripperMotion for ShadySim.reallySetGripper(int, double).
protected  ShadySim.RotateMotion makeRotateMotion(int barrel, double dt)
          Make a RotateMotion for ShadySim.reallyRotateBarrel(int, double).
protected  java.lang.Thread makeUpdateThread()
          Instantiate ShadyCommon.updateThread.
protected  void openGripperPost(int barrel)
          Last part of ShadyCommon.openGripper(int).
protected  void openGripperPostImpl(int barrel)
          Implementation of openGripperPost(int), separated so that we can synchronize on multiShadySim if we have one.
protected  int rotateBarrelPost(int barrel, double dt, double energy, double time)
          Third part of ShadyCommon.rotateBarrel(int, double).
(package private)  void setClockFromMulti(vona.time.Clock clock)
          Hook so MultiShadySim can set our ShadyCommon.clock from its constructor.
 void setIndex(int index)
          Set the zero-based index of this member in its MultiShady.
 void setMultiShady(MultiShadyCommonAPI multiShady)
          Set the MultiShady to which this MemberShady belongs.
 boolean setPose(ShadyPose newPose)
          Set the mechanism pose (by copy).
protected  boolean setPoseImpl(ShadyPose newPose)
          Implementation of setPose(shady.common.ShadyPose), separated so that we can synchronize on multiShadySim if we have one.
(package private)  void updateFromMulti(double dt)
          Update from MultiShadySim.
protected  boolean wouldDuel(boolean enableFault)
          Check whether the barrels would duel on rotation.
 
Methods inherited from class shady.sim.ShadySim
chargeBattery, doSimultaneousMotion, getAccel, getDiscreteMode, getGripperTime, getRotateBarrelTime, getRotateShadeTime, getShadyTime, pause, reallyRotateBarrel, reallyRotateShade, reallySetGripper, rechargeBattery, reset, rotateBarrel, rotateShade, setAccel, setDiscreteMode, setGripper, shadySleep, stop, unPause
 
Methods inherited from class shady.common.ShadyCommon
appendBarrelString, appendHTMLFontTag, barrelName, beginAccumulatingMotion, checkBarrel, checkEnergy, checkFault, checkGripperOperation, closeGripper, closeGripper, closeGripperPre, closeShade, disableTiltCheck, endAccumulatingMotion, faultName, getAccountingInfo, getAccountingInfo, getBarrelAngle, getBarrelRotationLimit, getCenterToCenterDistance, getClock, getCurrentPower, getCurrentTime, getFault, getFault, getFaultDetails, getGripperOperationTargetState, getGripperSlop, getGripperState, getGripperWidth, getGripQuality, getName, getNumActiveActuators, getPose, getPose, getShadeAngle, getShadeOpenAngle, getShadeSlop, getState, getState, getTotalLength, getUpdateTime, gripperOperationName, gripperStateName, gripperStateName, isAccumulatingMotion, isGripperAligned, isGripperAligned, isGripperClosed, isGripperOpen, isNameSet, isShadeClosed, isShadeOpen, makeAccountingInfo, makeState, openGripper, openGripperPre, openShade, otherBarrel, otherGripperOperation, pick, pick, reallyGetCurrentBatteryEnergy, reallyGetTotalBatteryEnergy, reestablishState, resetAccounting, rotateBarrel, rotateBarrelPre, rotateBarrelTo, setFault, setGripper, setGripperPost, setGripperPre, setName, setState, setWouldDuelOverride, setWouldTiltOverride, simultaneousMotion, toString, toString, toString, toString, update, updateState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface shady.common.multi.MemberShadyCommonAPI
setFault
 
Methods inherited from interface shady.sim.ShadySimAPI
chargeBattery, getAccel, getDiscreteMode, getShadyTime, pause, rechargeBattery, setAccel, setDiscreteMode, shadySleep, unPause
 
Methods inherited from interface shady.common.ShadyCommonAPI
beginAccumulatingMotion, closeGripper, closeGripper, closeShade, endAccumulatingMotion, faultName, getAccountingInfo, getAccountingInfo, getBarrelAngle, getBarrelRotationLimit, getCenterToCenterDistance, getClock, getCurrentPower, getFault, getFault, getFaultDetails, getGripperState, getGripperWidth, getGripQuality, getName, getNumActiveActuators, getPose, getPose, getShadeAngle, getShadeOpenAngle, getState, getState, getTotalLength, isAccumulatingMotion, isGripperAligned, isGripperAligned, isGripperClosed, isGripperOpen, isNameSet, isShadeClosed, isShadeOpen, openGripper, openShade, pick, reset, resetAccounting, rotateBarrel, rotateBarrelTo, rotateShade, setName, setState, setWouldDuelOverride, setWouldTiltOverride, simultaneousMotion, stop
 

Field Detail

cvsid

private static final java.lang.String cvsid

CVS id.

See Also:
Constant Field Values

index

protected int index

Our index in multiShadySim.


multiShadySim

protected MultiShadySimAPI multiShadySim

The MultiShadySim of which we're a member.

Constructor Detail

MemberShadySim

public MemberShadySim(ShadyPose pose)

Create a MemberShadySim with a given pose.

Parameters:
pose - the pose

MemberShadySim

public MemberShadySim()

Create a MemberShadySim with no pose.

Method Detail

setIndex

public void setIndex(int index)

Set the zero-based index of this member in its MultiShady.

Specified by:
setIndex in interface MemberShadyCommonAPI
Parameters:
index - the zero-based index of this member in its MultiShady, or -1 to unset

getIndex

public int getIndex()

Get the zero-based index of this member in its MultiShady.

Specified by:
getIndex in interface MemberShadyCommonAPI
Returns:
the zero-based index of this member in its MultiShady, or -1 if not set

setMultiShady

public void setMultiShady(MultiShadyCommonAPI multiShady)

Set the MultiShady to which this MemberShady belongs.

This impl requires multiShady to be a MultiShadySimAPI.

Specified by:
setMultiShady in interface MemberShadyCommonAPI
Parameters:
multiShady - the MultiShady to which this MemberShady belongs, null to unset

getMultiShady

public MultiShadyCommonAPI getMultiShady()

Get the MultiShady to which this MemberShady belongs.

Specified by:
getMultiShady in interface MemberShadyCommonAPI
Returns:
the MultiShady to which this MemberShady belongs, null if unset

bothGrippersClosed

public boolean bothGrippersClosed()

Check whether both grippers are closed.

Specified by:
bothGrippersClosed in interface MemberShadyCommonAPI
Returns:
true iff both grippers are closed

wouldDuel

protected boolean wouldDuel(boolean enableFault)

Check whether the barrels would duel on rotation.

This impl considers a duel to be when both grippers are closed on grounded MultiSegments.

.

Overrides:
wouldDuel in class ShadyCommon
Parameters:
enableFault - whether to set a ShadyCommonAPI.WOULD_DUEL fault if the barrels would duel and not ShadyCommon.wouldDuelOverride
Returns:
true iff the barrels would duel on rotation

makeRotateMotion

protected ShadySim.RotateMotion makeRotateMotion(int barrel,
                                                 double dt)

Make a RotateMotion for ShadySim.reallyRotateBarrel(int, double).

This is a hook so subclasses can also subclass RotateMotion.

Params same as the ShadySim.RotateMotion constr.

This impl returns a new MemberShadySim.MemberRotateMotion.

Overrides:
makeRotateMotion in class ShadySim
Returns:
a RotateMotion corresponding to barrel and dt

rotateBarrelPost

protected int rotateBarrelPost(int barrel,
                               double dt,
                               double energy,
                               double time)

Third part of ShadyCommon.rotateBarrel(int, double).

Updates ShadyCommon.accountingInfo, and if any rotation occurred with the distal gripper open, and we have a pose, unsets ShadyPose.distalPoint.

Extends superclass impl to MultiEnvironment.place() if we have a valid pose, some rotation was performed, and bothGrippersClosed().

Overrides:
rotateBarrelPost in class ShadyCommon
Parameters:
barrel - same as for ShadyCommon.rotateBarrel(int, double)
dt - the movement in degrees of barrel
energy - the energy used while rotating in Joules, or -1 if unavailable
time - the time spent rotating in seconds
Returns:
the fault state after rotating

makeGripperMotion

protected ShadySim.GripperMotion makeGripperMotion(int barrel,
                                                   double ds)

Make a GripperMotion for ShadySim.reallySetGripper(int, double).

This is a hook so subclasses can also subclass GripperMotion.

Params same as the ShadySim.GripperMotion constr.

This impl returns a new MemberShadySim.MemberGripperMotion.

Overrides:
makeGripperMotion in class ShadySim
Returns:
a GripperMotion corresponding to barrel and ds

closeGripperPost

protected void closeGripperPost(int barrel,
                                Point.OnSegment gripPoint)

Last part of ShadyCommon.closeGripper(int, Point.OnSegment).

If we have a pose and we just closed the distal barrel, then update ShadyCommon.pose's ShadyPose.distalPoint.

Extends superclass impl to synchronize on multiShadySim if we have one and to update the connectivity graph and MultiEnvironment.place().

Overrides:
closeGripperPost in class ShadyCommon
Parameters:
barrel - same as for ShadyCommon.closeGripper(int, Point.OnSegment)
gripPoint - same as for ShadyCommon.closeGripper(int, Point.OnSegment)

closeGripperPostImpl

protected void closeGripperPostImpl(int barrel,
                                    Point.OnSegment gripPoint)

Implementation of openGripperPost(int), separated so that we can synchronize on multiShadySim if we have one.


openGripperPost

protected void openGripperPost(int barrel)

Last part of ShadyCommon.openGripper(int).

Conjugates ShadyCommon.pose if any and if necessary.

Extends superclass impl to synchronize on multiShadySim if we have one and to update the connectivity graph and call MultiEnvironment.place().

Overrides:
openGripperPost in class ShadyCommon
Parameters:
barrel - same as for ShadyCommon.openGripper(int)

openGripperPostImpl

protected void openGripperPostImpl(int barrel)

Implementation of openGripperPost(int), separated so that we can synchronize on multiShadySim if we have one.


setPose

public boolean setPose(ShadyPose newPose)

Set the mechanism pose (by copy).

Note that if the distal barrel is closed after setting newPose that newPose.distalPoint and newPose.invertDistalSense must be valid and consistent.

Extends superclass impl to synchronize on multiShadySim if we have one and to update the connectivity graph.

Specified by:
setPose in interface ShadyCommonAPI
Overrides:
setPose in class ShadyCommon
Parameters:
newPose - the pose to set, null for none. State will be copied only if pose and pose.state are not null.
Returns:
true iff the state was set

setPoseImpl

protected boolean setPoseImpl(ShadyPose newPose)

Implementation of setPose(shady.common.ShadyPose), separated so that we can synchronize on multiShadySim if we have one.


updateFromMulti

void updateFromMulti(double dt)

Update from MultiShadySim.

Parameters:
dt - time since last update in accelseconds

makeClock

protected vona.time.Clock makeClock()

Instantiate ShadyCommon.clock.

This is a hook to allow subclasses to implement the clock differently.

This impl just returns a new Clock.

This impl returns a new SuperClock.

Members reference the MultiShady's clock, so this impl returns null.

Overrides:
makeClock in class ShadySim
Returns:
the clock

setClockFromMulti

void setClockFromMulti(vona.time.Clock clock)

Hook so MultiShadySim can set our ShadyCommon.clock from its constructor.

.


makeUpdateThread

protected java.lang.Thread makeUpdateThread()

Instantiate ShadyCommon.updateThread.

Default impl assumes we have a ShadyCommon.clock and returns a new vona.time.AccelTime.PeriodicThread from ShadyCommon.clock that calls ShadyCommon.update(double) with period ShadyCommon.getUpdateTime().

This is a hook to allow subclasses to implement the update thread differently.

Members don't have their own update threads, so this impl returns null.

Overrides:
makeUpdateThread in class ShadyCommon
Returns:
the update thread, not started