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_SIMULATEDPLATFORM_
00026 #define _ROBOT_SIM_SIMULATEDPLATFORM_
00027
00028 #include <robot/sim/sim>
00029
00030 #include <base/ReferencedObject>
00031 #include <base/Externalizable>
00032
00033 #include <physics/PositionableOrientable>
00034 #include <physics/Spatial>
00035 #include <physics/SpatialGroup>
00036 #include <physics/SolidSystem>
00037
00038 #include <robot/PlatformDescription>
00039
00040
00041 namespace robot {
00042 namespace sim {
00043
00044
00045
00046
00047
00048
00049 class SimulatedPlatform : public physics::Spatial, public physics::CollidableProvider, public base::Externalizable
00050 {
00051 public:
00052 SimulatedPlatform();
00053 SimulatedPlatform(ref<const robot::PlatformDescription> platformDescription, ref<physics::SolidSystem> solidSystem = ref<physics::SolidSystem>(0), bool dynamic=true);
00054 virtual ~SimulatedPlatform();
00055
00056 virtual String className() const { return String("SimulatedPlatform"); }
00057
00058 virtual void setDynamic(bool enabled) { dynamic = enabled; }
00059
00060 void setSolidSystem(ref<physics::SolidSystem> solidSystem) { this->solidSystem = solidSystem; }
00061
00062 ref<const robot::PlatformDescription> getPlatformDescription() const { return platformDescr; }
00063
00064 void construct(const base::Point3& initialPosition, const base::Orient& initialOrientation);
00065
00066 ref<physics::Solid> getPlatformSolid() const { return platformSolids[Platform]; }
00067
00068
00069 void setLeftBackWheelTorque(Real t);
00070
00071 void setLeftBackWheelVel(Real v, Real maxTorque=10.0);
00072
00073 Real getLeftBackWheelVel() const;
00074
00075
00076 void setRightBackWheelTorque(Real t);
00077
00078 void setRightBackWheelVel(Real v, Real maxTorque=10.0);
00079
00080 Real getRightBackWheelVel() const;
00081
00082
00083 void setSteeringTorque(Real t);
00084
00085 void setSteeringVel(Real v, Real maxTorque=10.0);
00086
00087 Real getSteeringAngle() const;
00088
00089
00090
00091 virtual void setPosition(const Point3& pos);
00092 virtual Point3 getPosition() const;
00093 virtual void setOrientation(const Orient& orient);
00094 virtual Orient getOrientation() const;
00095 virtual void setConfiguration(const base::Transform& configuration);
00096 virtual base::Transform getConfiguration() const;
00097
00098
00099 virtual ref<physics::Collidable> createCollidable(CollidableFlags flags = 0);
00100
00101
00102 virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const;
00103 virtual void externalize(base::Externalizer& e, const String format = "", Real version = 1.0);
00104
00105 protected:
00106
00107 ref<physics::SolidSystem> solidSystem;
00108 ref<const robot::PlatformDescription> platformDescr;
00109
00110
00111 bool dynamic;
00112
00113 enum PlatformSolids { Platform,
00114 LeftFrontWheel, RightFrontWheel,
00115 LeftBackWheel, RightBackWheel,
00116 LeftFrontWheelMount, RightFrontWheelMount,
00117 Crossbar,
00118 MaxPlatformSolids };
00119
00120 array<ref<physics::Solid> > platformSolids;
00121
00122 ref<physics::SpatialGroup> spatialGroup;
00123 void updateGroupConfigurationFromPlatformSolid() const;
00124
00125 void disableCollisions(const array<ref<physics::Collidable> >& collidables);
00126
00127
00128 ref<physics::ConstraintGroup> wheelConstraintGroup;
00129 ref<physics::HingeJoint> leftDriveHingeJoint;
00130 ref<physics::HingeJoint> rightDriveHingeJoint;
00131 ref<physics::HingeJoint> steeringHingeJoint;
00132 ref<physics::Motor> leftDriveMotor;
00133 ref<physics::Motor> rightDriveMotor;
00134 ref<physics::Motor> steeringMotor;
00135 };
00136
00137
00138 }
00139 }
00140
00141 #endif