GCOP  1.0
bulletrccar1.h
Go to the documentation of this file.
00001 #ifndef GCOP_BULLETRCCAR1_H
00002 #define GCOP_BULLETRCCAR1_H
00003 
00004 #include "system.h"
00005 #include "rccar.h"
00006 #include <BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h>
00007 #include <BulletDynamics/Dynamics/btRigidBody.h>
00008 #include <btBulletDynamicsCommon.h>
00009 #include "bulletworld.h"
00010 
00011 namespace gcop {
00012   
00013   using namespace std;
00014   using namespace Eigen;
00015 
00016   typedef Matrix<double, 4, 2> Matrix42d;
00017   typedef Matrix<double, 4, Dynamic> Matrix4pd;
00018   //typedef Matrix<double, 6, 1> Vector6d;
00019 
00033   class Bulletrccar1 : public Rccar 
00034   {
00035   public:
00036     Bulletrccar1(BulletWorld& m_world, vector<double> *zs_ = 0);
00037 
00038     ~Bulletrccar1()
00039     {
00040       delete m_vehicleRayCaster;
00041 
00042       delete m_vehicle;
00043 
00044       delete m_wheelShape;
00045     }
00046     
00047     double Step(Vector4d &xb, double t, const Vector4d &xa,
00048                 const Vector2d &u, double h, const VectorXd *p,
00049                 Matrix4d *A = 0, Matrix42d *B = 0, Matrix4pd *C = 0);
00050 
00051     double Step1(Vector4d &xb, const Vector2d &u, 
00052                 double h, const VectorXd *p = 0,
00053                 Matrix4d *A = 0, Matrix42d *B = 0, Matrix4pd *C = 0);
00054 
00055     double Step3(Vector4d &xb, const Vector2d &u,
00056                       const Vector4d &w, double h,
00057                       const VectorXd *p = 0,Matrix4d *A = 0, Matrix42d *B = 0, Matrix4pd *C = 0, Matrix4d *D = 0);
00058 
00059     bool reset(const Vector4d &x, double t = 0);
00060 
00061     bool NoiseMatrix(Matrix4d &Q, double t, const Vector4d &x, const Vector2d &u, double dt, const VectorXd *p);
00062 
00063     int rightIndex;
00064     int upIndex;
00065     int forwardIndex;
00066 
00067     double carmass;//Mass of the car
00068     btVector3 car_halfdims;//half dimensions of car width, height, length
00069 
00070     double  gEngineForce ;//Engine Torque
00071     double  gBreakingForce;//Breaking Force on the vehicle
00072 
00073     double maxEngineForce;
00074     double  maxBreakingForce;
00075 
00076     double  gVehicleSteering;//Vehicle Steering angle
00077     double  steeringClamp;// Clamp on Steering angle
00078     double torqueClamp;//Clamp on velocity of car
00079     double  wheelRadius;//Radius of wheel
00080     double  wheelWidth;//Width of wheel
00081     double  wheelFriction;//wheel friction usually large value
00082     double  suspensionStiffness;//Stiffness of suspension. If not enough, the car will sink into ground
00083     double  suspensionDamping;//Damping on suspension
00084     double  suspensionCompression;//Compression factor decides by how much the car will compress wrto external loads
00085     double  rollInfluence;//Decides whether the car will topple or not
00086     btScalar suspensionRestLength;//Rest length of suspension
00087     btScalar m_defaultContactProcessingThreshold;// if contact goes above this value, it will process
00088 
00089     btVector3 wheelDirectionCS0;//direction from the car towards the wheel contact point
00090     btVector3 wheelAxleCS;//Wheel Axle Direction
00091 
00092     //Parameters for the car:
00093     double initialz;
00094     double kp_steer;
00095 
00096     btTransform offsettrans;//To Account for the difference to coordinate system Usage: worldpose_inregcoordsys = offsettrans.inv()*worldpose_bullet*offsettrans
00097     btTransform offsettransinv;
00098 
00099     //Additional Hidden state for publishing/rendering trajectories:
00100     vector<double> *zs;
00101     int count_zs;
00102 
00103     //Hacky way of ensuring the vehicle_velocity is reset after every reset
00104     bool reset_drivevel;
00105 
00106     //Bullet classes for holding car
00107     btRigidBody* m_carChassis;
00108     btRaycastVehicle* m_vehicle;
00109     btCollisionShape* m_wheelShape;
00110     btRaycastVehicle::btVehicleTuning m_tuning;
00111     btVehicleRaycaster* m_vehicleRayCaster;
00112     BulletWorld &m_world;
00113     //btDynamicsWorld*    m_dynamicsWorld;
00114   };
00115 }
00116 
00117 
00118 #endif