remove old and unrelated code relative to this specific branch
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6418 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 1f08d4b4bd04fd0ffc645a4b70c50d6dbc294dce Former-commit-id: 8a9577bf6cfcb5dc66ac4a747026ef9158238b8c
This commit is contained in:
parent
3e4ad96540
commit
9530b20507
6 changed files with 10 additions and 354 deletions
|
@ -1164,29 +1164,11 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
|||
car->_steerCmd = leftSteer + rightSteer;
|
||||
|
||||
/* Force feedback hack */
|
||||
//float force = car->_steerTq * 32760 * 5;
|
||||
//float force = car->_steerTq * 32760 / 400 * -1;
|
||||
tdble skidAng = atan2(car->_speed_Y, car->_speed_X) - car->_yaw;
|
||||
NORM_PI_PI(skidAng);
|
||||
//tdble skidAng=0;
|
||||
//float force = (car->_steerTq/10 /*- skidAng*/ * 32760);//adjusted by skid
|
||||
//copysign(1.0f,car->_steerCmd) *
|
||||
//float force = copysign(1.0f,car->_steerCmd) * -1 * (sqrt(fabs(car->_steerCmd)));//basic autocenter
|
||||
//float force = car->_speed_Y - (car->priv.wheel[0].forces.y + car->priv.wheel[0].forces.x)/2;
|
||||
//car->_wheelSlipAccel(REAR_RGT)
|
||||
//force = force * skidAng ;
|
||||
|
||||
//car->_pitch
|
||||
//float multiplier = 3 + (car->_dimension_x - 4); //the longer the car the stronger the effect
|
||||
float multiplier = 4; //the longer the car the stronger the effect
|
||||
//telemetry.log("Dimension-y", car->_dimension_y);
|
||||
//telemetry.log("Dimension-z", car->_dimension_z);
|
||||
force = (force + (car->_steerTq*multiplier)) / 2; //try to smooth it
|
||||
//force = force * 32760;
|
||||
//float force = (skidAng * car->_steerCmd * 32760);//adjusted by skid
|
||||
float multiplier = 4;
|
||||
force = (force + (car->_steerTq*multiplier)) / 2; //make the force smoother
|
||||
|
||||
// if force is below 0 we turn anticlock-wise
|
||||
// if force is over 0 we turn clock-wise
|
||||
// if force is below 0 we turn anticlock-wise
|
||||
// if force is over 0 we turn clock-wise
|
||||
gfctrlJoyConstantForce(int((cmd[CMD_LEFTSTEER].val) / GFCTRL_JOY_NUMBER), abs((int)force), force < 0 ? 9000 : 27000 );
|
||||
//gfctrlJoyRumble(int((cmd[CMD_LEFTSTEER].val) / GFCTRL_JOY_NUMBER), 0.9);
|
||||
|
||||
|
@ -1643,101 +1625,6 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
|||
if (force > 32760) force = 32760;
|
||||
if (force < -32760) force = -32760;
|
||||
|
||||
extern GfTelemetry telemetry;
|
||||
telemetry.start();//start a new "data row"
|
||||
//telemetry.log("paramName","ParamValue");
|
||||
|
||||
|
||||
//tdble skidAng = atan2(car->_speed_Y, car->_speed_X) - car->_yaw;
|
||||
//NORM_PI_PI(skidAng);
|
||||
|
||||
telemetry.log("Time-RaceTime",(float)s->currentTime);
|
||||
telemetry.log("Time-LapTime", (float)car->_curLapTime);
|
||||
|
||||
telemetry.log("SteerTq-steerTq",car->_steerTq);
|
||||
telemetry.log("FF-appliedForce",force);
|
||||
|
||||
telemetry.log("Slip-Slip",slip);
|
||||
|
||||
telemetry.log("SpeedX-sX", car->_speed_x);
|
||||
telemetry.log("SpeedY-sY", car->_speed_y);
|
||||
telemetry.log("SpeedZ-sZ", car->_speed_z);
|
||||
|
||||
telemetry.log("AccelX-aX", (float)car->_accel_x);
|
||||
telemetry.log("AccelY-aY", (float)car->_accel_y);
|
||||
telemetry.log("AccelZ-aZ", (float)car->_accel_z);
|
||||
|
||||
telemetry.log("Lap-Lap", (float)car->_laps);
|
||||
telemetry.log("DistFromStartLine-Dist", (float)HCtx[idx]->distToStart);
|
||||
|
||||
telemetry.log("Pitch-Pitch", car->_pitch);
|
||||
telemetry.log("Roll-Roll", car->_roll);
|
||||
telemetry.log("Yaw-Yaw", car->_yaw);
|
||||
telemetry.log("Yawrate-Yawrate", car->_yaw_rate);
|
||||
|
||||
telemetry.log("PitchD-Pitch", (float)RAD2DEG(car->_pitch));
|
||||
telemetry.log("RollD-Roll", (float)RAD2DEG(car->_roll));
|
||||
telemetry.log("YawD-Yaw", (float)RAD2DEG(car->_yaw));
|
||||
|
||||
telemetry.log("Command-Steer", (float)car->_steerCmd);
|
||||
telemetry.log("TrottleBrake-Throttle", (float)car->_accelCmd);
|
||||
telemetry.log("TrottleBrake-Brake", (float)car->_brakeCmd);
|
||||
|
||||
telemetry.log("Gear-Gear", (float)HCtx[idx]->gear);
|
||||
telemetry.log("Speed-Speed", (float)car->_speed_x);
|
||||
telemetry.log("EngineRPM-EngineRPM", (float)car->_enginerpm);
|
||||
|
||||
telemetry.log("Position-x", car->_pos_X);
|
||||
telemetry.log("Position-y", car->_pos_Y);
|
||||
telemetry.log("Position-z", car->_pos_Z);
|
||||
|
||||
telemetry.log("Damage-Damage", car->_dammage);
|
||||
telemetry.log("Collision-Collision", car->priv.collision);
|
||||
telemetry.log("Fuel-Fuel", car->_fuel);
|
||||
|
||||
telemetry.log("BrakeTemp-FR",car->_brakeTemp(0));
|
||||
telemetry.log("BrakeTemp-FL",car->_brakeTemp(1));
|
||||
telemetry.log("BrakeTemp-RR",car->_brakeTemp(2));
|
||||
telemetry.log("BrakeTemp-RL",car->_brakeTemp(3));
|
||||
|
||||
/*
|
||||
telemetry.log("MU-FR",car->priv.wheel[0].effectiveMu);
|
||||
telemetry.log("MU-FL",car->priv.wheel[1].effectiveMu);
|
||||
telemetry.log("MU-RR",car->priv.wheel[2].effectiveMu);
|
||||
telemetry.log("MU-RL",car->priv.wheel[3].effectiveMu);
|
||||
*/
|
||||
|
||||
//car->wheel[0].forces.y
|
||||
/*
|
||||
telemetry.log("ZFORCE-FR",car->priv.wheel[0].forces.y);
|
||||
telemetry.log("ZFORCE-FL",car->priv.wheel[1].forces.y);
|
||||
telemetry.log("ZFORCE-RR",car->priv.wheel[2].forces.y);
|
||||
telemetry.log("ZFORCE-RL",car->priv.wheel[3].forces.y);
|
||||
* /
|
||||
|
||||
|
||||
//telemetry.log("Dimension-x", car->_dimension_x);
|
||||
|
||||
|
||||
|
||||
|
||||
//track segment that the car is on
|
||||
//carElt->_wheelSeg(i)
|
||||
|
||||
//center of gravity of the car
|
||||
//telemetry.log("GC-GC",car->pub.DynGC); //.acc.x vel.x
|
||||
//telemetry.log("GC-GCg",car->pub.DynGCg); //.acc.x vel.x pos.x //see car.h
|
||||
|
||||
//telemetry.log("",);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
GfOut("FRNT_RGT = %f\n", car->_wheel[FRNT_RGT]);
|
||||
GfOut("FRNT_LFT = %f\n" , car->_wheel[FRNT_LFT]); //based on 36000 degree of rotation
|
||||
*/
|
||||
|
||||
|
||||
HCtx[idx]->lap = car->_laps;
|
||||
}//common_drive
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <fstream> // std::fstream
|
||||
|
@ -1002,174 +1001,3 @@ GfSleep(double seconds)
|
|||
{
|
||||
SDL_Delay((Uint32)(seconds*1000)); // ms.
|
||||
}
|
||||
|
||||
//to string (from c++11)
|
||||
template <typename T>
|
||||
std::string to_string(T value)
|
||||
{
|
||||
std::ostringstream os ;
|
||||
os << value ;
|
||||
return os.str() ;
|
||||
}
|
||||
|
||||
|
||||
GfTelemetry::GfTelemetry(){
|
||||
// this->params_names.append("\"loop\"");
|
||||
this->lastDataLogTime = std::clock();
|
||||
this->count = 0;
|
||||
this->doLog=true;
|
||||
this->headerWritten=false;
|
||||
}
|
||||
GfTelemetry::~GfTelemetry(){
|
||||
}
|
||||
void GfTelemetry::start(){
|
||||
//GfOut("\n\n\n#############%i\n\n\n\n\n\n", this->params_values.size());
|
||||
//write to file every 10kb
|
||||
if(this->params_values.size() > 10000){
|
||||
this->plot();
|
||||
}
|
||||
|
||||
//how much time is passed from the last run
|
||||
std::clock_t curTime = std::clock();
|
||||
float elapsedTime = (curTime - this->lastDataLogTime) / (float) CLOCKS_PER_SEC;
|
||||
|
||||
//GfOut("\n%f\n", elapsedTime);
|
||||
this->data.clear();
|
||||
if (elapsedTime > 0.1){
|
||||
//GfOut("\n%f\n", elapsedTime);
|
||||
this->lastDataLogTime = std::clock();
|
||||
this->doLog=true;
|
||||
this->count= this->count+1;
|
||||
this->params_values.append("\r\n");
|
||||
// this->params_values.append(to_string(count));
|
||||
|
||||
}else{
|
||||
this->doLog=false;
|
||||
}
|
||||
|
||||
}
|
||||
void GfTelemetry::end(){
|
||||
|
||||
}
|
||||
void GfTelemetry::log(std::string name, std::string value){
|
||||
name.insert(0,"\"");
|
||||
name.append("\"");
|
||||
|
||||
if(this->doLog){
|
||||
|
||||
std::map<std::string,std::string>::iterator it;
|
||||
it = this->data.find(name);
|
||||
|
||||
if (it == this->data.end()){
|
||||
this->data[name] = value;
|
||||
std::size_t found = this->params_names.find(name,0);
|
||||
|
||||
if(found==std::string::npos){
|
||||
this->params_names.append(name);
|
||||
this->params_names.append(",");
|
||||
|
||||
}
|
||||
|
||||
this->params_values.append(value);
|
||||
this->params_values.append(",");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
void GfTelemetry::log(std::string name, int value){
|
||||
if(this->count==0){
|
||||
return;
|
||||
}
|
||||
return this->log(name,to_string(value));
|
||||
}
|
||||
void GfTelemetry::log(std::string name, float value){
|
||||
if(this->count==0){
|
||||
return;
|
||||
}
|
||||
return this->log(name,to_string(value));
|
||||
}
|
||||
|
||||
void GfTelemetry::plot(){
|
||||
std::string output;
|
||||
|
||||
output.append("\r\n");
|
||||
//output.append(this->params_names);
|
||||
|
||||
if(!this->headerWritten){
|
||||
output.append("\r\n");
|
||||
output.append(this->params_names);
|
||||
this->headerWritten=true;
|
||||
}
|
||||
|
||||
output.append(this->params_values);
|
||||
|
||||
std::string telemetryFile = GfLocalDir();
|
||||
telemetryFile.append("telemetry.txt");
|
||||
|
||||
FILE * pFile;
|
||||
pFile = fopen (telemetryFile.c_str(), "a"); //"a"=append to file "w"=empty file and write to it
|
||||
fwrite (output.data() , sizeof(char), output.length(), pFile);
|
||||
fclose (pFile);
|
||||
|
||||
//empty the strings
|
||||
this->params_values.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
/*
|
||||
void GfTelemetry::createSqliteDb(){
|
||||
int result;
|
||||
std::string telemetryDb = GfLocalDir();
|
||||
telemetryDb.append("telemetry.db");
|
||||
|
||||
result = sqlite3_open(telemetryDb, telemetryDb.c_str());
|
||||
if (result) {
|
||||
GfLogError("Unable to open Database: %s\n", sqlite3_errmsg(replayDB));
|
||||
sqlite3_close(replayDB);
|
||||
replayDB = NULL;
|
||||
} else {
|
||||
GfLogInfo("Replay Database Opened 0x8%8.8X\n\n\n\n", replayDB);
|
||||
|
||||
// speed up database by turning of synchronous behaviour, ie. don't wait for disk
|
||||
sqlite3_exec(replayDB, "PRAGMA synchronous = OFF", NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
void GfTelemetry::openSqliteDb(){
|
||||
|
||||
}
|
||||
void GfTelemetry::closeSqliteDb(){
|
||||
sqlite3_close(replayDB);
|
||||
}
|
||||
|
||||
void GfTelemetry::createSqliteTable(){
|
||||
char query[200];
|
||||
int result;
|
||||
|
||||
sprintf(query, "CREATE TABLE IF NOT EXISTS data (timestamp, lap, datablob BLOB)", i);
|
||||
result = sqlite3_exec(replayDB, query, 0, 0, 0);
|
||||
if (result) {
|
||||
printf("Unable to create table data: %s\n", sqlite3_errmsg(replayDB));
|
||||
}
|
||||
|
||||
}
|
||||
void GfTelemetry::saveData(){
|
||||
char query[200];
|
||||
int result;
|
||||
|
||||
// Do everything in 1 transaction for speed
|
||||
sqlite3_exec(replayDB, "BEGIN TRANSACTION", NULL, NULL, NULL);
|
||||
|
||||
sprintf(query, "INSERT INTO car%d (timestamp, lap, datablob) VALUES (%f, %d, ?)", nCarInd,
|
||||
pSource->s->currentTime, pSrcCar->_laps);
|
||||
|
||||
result = sqlite3_exec(replayDB, query, 0, 0, 0);
|
||||
|
||||
if (result) {
|
||||
GfLogInfo("Unable to instert into table: %s\n", sqlite3_errmsg(replayDB));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
GfTelemetry telemetry;
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#endif
|
||||
|
||||
#include "osspec.h"
|
||||
#include <ctime>
|
||||
#include <map>
|
||||
|
||||
// DLL exported symbols declarator for Windows.
|
||||
#ifdef WIN32
|
||||
|
@ -999,31 +997,6 @@ TGF_API void GfFormFreeCommandNew(void *cmd);
|
|||
// Maximun value of a key code (Has to be the least greater 2^N - 1 >= SDLK_LAST)
|
||||
#define GF_MAX_KEYCODE 0x1FF
|
||||
|
||||
TGF_API class GfTelemetry{
|
||||
public:
|
||||
void start();
|
||||
void log (std::string name, std::string value);
|
||||
void log (std::string name, int value);
|
||||
void log (std::string name, float value);
|
||||
void plot();
|
||||
std::clock_t lastDataLogTime;
|
||||
int count;
|
||||
bool doLog;
|
||||
bool headerWritten;
|
||||
std::map<std::string,std::string> data;
|
||||
|
||||
void end();
|
||||
std::string params_names;
|
||||
std::string params_values;
|
||||
//constructor
|
||||
GfTelemetry();
|
||||
|
||||
//destructor
|
||||
~GfTelemetry();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* __TGF__H__ */
|
||||
|
||||
|
||||
|
|
|
@ -258,9 +258,6 @@ main(int argc, char *argv[])
|
|||
const std::string strAppName(pApp->name());
|
||||
delete pApp;
|
||||
|
||||
extern GfTelemetry telemetry;
|
||||
telemetry.plot();
|
||||
|
||||
// That's all (but trace what we are doing).
|
||||
if (piUserItf && piRaceEngine)
|
||||
GfLogInfo("Exiting normally from %s.\n", strAppName.c_str());
|
||||
|
|
|
@ -576,6 +576,7 @@ SimUpdate(tSituation *s, double deltaTime)
|
|||
GfOut("RR = %f\n", car->wheel[REAR_RGT].forces.y);
|
||||
GfOut("RL = %f\n", car->wheel[REAR_LFT].forces.y);
|
||||
*/
|
||||
carElt->_steerTq = -1 * (car->wheel[FRNT_RGT].forces.y + car->wheel[FRNT_LFT].forces.y)/2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,6 +706,7 @@ SimUpdateSingleCar(int index, double deltaTime,tSituation *s)
|
|||
carElt->_steerTqAlign = car->wheel[FRNT_RGT].torqueAlign + car->wheel[FRNT_LFT].torqueAlign;
|
||||
=======
|
||||
//carElt->_steerTq = -car->ctrl->steer; /*TODO: torque from Pacejka*/
|
||||
<<<<<<< 564d628f4f76b8521b9e7477c85d532272a6f432
|
||||
carElt->_steerTq = ((-1 * car->wheel[0].forces.y) + (-1 * car->wheel[1].forces.y))/2;
|
||||
|
||||
<<<<<<< 96fdc2d05cab490fcd782ecbda4de7d0b3ef0007
|
||||
|
@ -715,6 +717,10 @@ SimUpdateSingleCar(int index, double deltaTime,tSituation *s)
|
|||
telemetry.log("ZFORCEFL",car->wheel[1].forces.y);
|
||||
telemetry.log("ZFORCERR",car->wheel[2].forces.y);
|
||||
telemetry.log("ZFORCERL",car->wheel[3].forces.y);
|
||||
=======
|
||||
carElt->_steerTq = -1 * (car->wheel[FRNT_RGT].forces.y + car->wheel[FRNT_LFT].forces.y)/2;
|
||||
|
||||
>>>>>>> remove old and unrelated code relative to this specific branch
|
||||
|
||||
>>>>>>> update
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <tgf.h>
|
||||
#include "sim.h"
|
||||
#include <sstream>
|
||||
|
||||
static const char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL};
|
||||
static const char *SuspSect[4] = {SECT_FRNTRGTSUSP, SECT_FRNTLFTSUSP, SECT_REARRGTSUSP, SECT_REARLFTSUSP};
|
||||
|
@ -458,40 +457,6 @@ void SimWheelUpdateForce(tCar *car, int index)
|
|||
car->carElt->_wheelSlipAccel(index) = sx*v;
|
||||
car->carElt->_reaction[index] = reaction_force;
|
||||
car->carElt->_tyreEffMu(index) = mu;
|
||||
//if(index == 1){
|
||||
//GfOut(" (%i) Index - = %i\n", index);
|
||||
//GfOut("#%i", index); //index
|
||||
/*
|
||||
GfOut("#%f", wheel->sa); //SA
|
||||
GfOut("#%f", mu); //MU
|
||||
GfOut("#%f", car->carElt->_wheelSlipNorm(index)); //NORM
|
||||
GfOut("#%f", car->carElt->_wheelSlipOpt(index)); //OPT
|
||||
GfOut("#%f", car->carElt->_wheelSlipNorm(index)/car->carElt->_wheelSlipOpt(index)); //NORM/OPT
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
extern GfTelemetry telemetry;
|
||||
//telemetry.start();//start a new "data row"
|
||||
//telemetry.log("paramName","ParamValue");
|
||||
std::ostringstream paramname;
|
||||
paramname.str("");
|
||||
paramname << "WHEEL SA-" << index;
|
||||
//telemetry.log(paramname.str(),wheel->sa);
|
||||
paramname.str("");
|
||||
paramname << "WHEEL MU-" << index;
|
||||
telemetry.log(paramname.str(),wheel->mu);
|
||||
paramname.str("");
|
||||
paramname << "WHEEL NORM-" << index;
|
||||
//telemetry.log(paramname.str(),car->carElt->_wheelSlipNorm(index));
|
||||
paramname.str("");
|
||||
paramname << "WHEEL OPT-" << index;
|
||||
telemetry.log(paramname.str(),car->carElt->_wheelSlipOpt(index));
|
||||
paramname.str("");
|
||||
paramname << "WHEEL NORM/OPT-" << index;
|
||||
//telemetry.log(paramname.str(),car->carElt->_wheelSlipNorm(index)/car->carElt->_wheelSlipOpt(index));
|
||||
//}
|
||||
*/
|
||||
|
||||
tdble Work = 0.0;
|
||||
/* update tire temperature and degradation */
|
||||
|
|
Loading…
Reference in a new issue