00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ROBOT_SIM_SIMULATEDSERIALMANIPULATOR_
00026 #define _ROBOT_SIM_SIMULATEDSERIALMANIPULATOR_
00027
00028 #include <robot/sim/sim>
00029
00030 #include <robot/sim/SimulatedKinematicChain>
00031
00032 #include <physics/SolidSystem>
00033 #include <physics/Solid>
00034 #include <physics/Motor>
00035 #include <physics/Spatial>
00036 #include <physics/SpatialGroup>
00037 #include <physics/CollidableProvider>
00038 #include <physics/CollisionDetector>
00039 #include <physics/CollisionResponseHandler>
00040
00041 #include <robot/sim/SimulatedManipulatorDescription>
00042 #include <robot/sim/SimulatedTool>
00043
00044
00045 namespace robot {
00046 namespace sim {
00047
00048
00049
00050
00051
00052
00053 class SimulatedSerialManipulator : public SimulatedKinematicChain
00054 {
00055 public:
00056 SimulatedSerialManipulator(bool dynamic=true);
00057 SimulatedSerialManipulator(ref<physics::SolidSystem> solidSystem, bool dynamic=true);
00058 SimulatedSerialManipulator(ref<const robot::ManipulatorDescription> manipulatorDescription, ref<physics::SolidSystem> solidSystem, bool dynamic=true);
00059
00060 virtual String className() const { return String("SimulatedSerialManipulator"); }
00061
00062 virtual void setDynamic(bool enabled) { dynamic = enabled; }
00063
00064 virtual void setSolidSystem(ref<physics::SolidSystem> solidSystem)
00065 { this->solidSystem = solidSystem; }
00066
00067 ref<const SimulatedManipulatorDescription> getManipulatorDescription() const { return manipulatorDescr; }
00068
00069 ref<physics::Solid> getBaseSolid() const
00070 { return baseSolid; }
00071
00072
00073 void setJointForce(Int j, Real f);
00074
00075
00076
00077 void setJointVel(Int j, Real v, Real maxForce=10.0);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 void setJointPos(Int j, Real p);
00088
00089
00090
00091
00092 Real getJointPos(Int j) const;
00093
00094
00095 Real getJointVel(Int j) const;
00096
00097 base::Point3 getEEPosition() const;
00098 base::Orient getEEOrientation() const;
00099
00100
00101
00102 bool checkProximity(ref<SimulatedTool> tool);
00103
00104
00105 ref<SimulatedTool> getToolInProximity() const { return proximityTool; }
00106
00107
00108 bool isToolGrasped() const { return toolGrasped; }
00109
00110
00111
00112 bool graspTool();
00113
00114
00115 void releaseGrasp();
00116
00117
00118
00119
00120
00121 Real getClosestObjectDistance(Int link) const;
00122
00123
00124 Vector3 getClosestObjectDirection(Int link) const;
00125
00126
00127 Real getClosestObjectSensorPosition(Int link) const;
00128
00129
00130
00131
00132 virtual void setPosition(const Point3& pos);
00133 virtual Point3 getPosition() const;
00134 virtual void setOrientation(const Orient& orient);
00135 virtual Orient getOrientation() const;
00136 virtual void setConfiguration(const base::Transform& configuration);
00137 virtual base::Transform getConfiguration() const;
00138
00139
00140 virtual ref<physics::Collidable> createCollidable(CollidableFlags flags = 0);
00141
00142
00143 virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const;
00144 virtual void externalize(base::Externalizer& e, const String format = "", Real version = 1.0);
00145 virtual void externalize(base::Externalizer& e, const String format = "", Real version = 1.0) const
00146 { Externalizable::externalize(e,format,version); }
00147
00148 protected:
00149 SimulatedSerialManipulator(const SimulatedSerialManipulator& sm) { Unimplemented; }
00150
00151 ref<const SimulatedManipulatorDescription> manipulatorDescr;
00152
00153
00154 void construct(const base::Point3& initialPosition, const base::Orient& initialOrientation);
00155
00156
00157
00158 array<base::Dimension3> computeLinkDimensions(const array<Real>& linkRadii);
00159
00160
00161
00162 TransformInfo computeLinkTransforms(const Transform& mountTransform, const base::Vector& q) const;
00163
00164
00165
00166
00167 virtual void createLinks(const array<base::Dimension3>& linkDims);
00168
00169
00170 virtual void positionLinks(const TransformInfo& transformInfo);
00171
00172 virtual void disableCollisions(const array<ref<physics::Collidable> >& collidables,
00173 const array<ref<physics::Collidable> >& proximityCollidables);
00174
00175 virtual void attachJoints(const TransformInfo& transformInfo);
00176
00177
00178 void setToolInProximity(ref<SimulatedTool> tool) { proximityTool = tool; }
00179
00180 virtual void handleCollision(ref<physics::CollisionState> collisionState);
00181
00182
00183 mutable Transform mountConfiguration;
00184 Transform mountToBaseSolid;
00185 Transform eeToEESolid;
00186
00187 ref<physics::Solid> baseSolid;
00188 ref<physics::Solid> endSolid;
00189
00190 array<ref<physics::SpatialGroup> > linkGroups;
00191
00192
00193 Real proximityDistance;
00194 Real proximityAngle;
00195
00196 ref<SimulatedTool> proximityTool;
00197 bool toolGrasped;
00198
00199
00200 friend class SimulatedRobot;
00201 friend class ProximityCollisionResponseHandler;
00202 friend class base::Serializable::SerializableDerivedInstantiator<SimulatedSerialManipulator>;
00203 };
00204
00205
00206
00207 }
00208 }
00209
00210 #endif