24 #ifndef __RACEGROUND_H
25 #define __RACEGROUND_H
33 #include <drawstuff/drawstuff.h>
36 using namespace matrix;
47 list<AbstractTrackSection*> SegmentList;
55 AbstractObstacle(odehandle), length(0), width(0), height(0) {
61 AbstractObstacle(odehandle), length(0), width(0), height(0) {
66 AbstractObstacle(odehandle), length(0), width(0), height(0) {
67 setParameters(getTranslationRotationMatrix(pos,angle));
80 numberOfBarcodes=number;
89 double passedLength=0.0f;
90 double segmentNumber=-1.0f;
92 for(list<AbstractTrackSection*>::iterator it = SegmentList.begin();
93 it!= SegmentList.end(); ++it) {
94 if((*it)->isInside(p)){
95 double sectionLength = (*it)->getSectionIdValue(p);
96 width = (*it)->getWidthIdValue(p);
97 if (sectionLength<0.0f ) {
98 printf(
"Weird! We should be in the segment!\n");
100 segmentNumber=numberOfBarcodes*
101 (passedLength+sectionLength)/trackLength;
102 return pair<double, double> (segmentNumber, width);
104 passedLength+=(*it)->getLength();
106 return pair<double, double> (segmentNumber, width);
113 SegmentList+=listToAdd;
120 SegmentList+=Segment;
133 if (!SegmentList.empty()) {
134 Matrix pos = SegmentList.back()->getPoseMatrix();
135 Matrix end = SegmentList.back()->getTransformedEndMatrix();
139 if (name==
"straightline") {
141 SegmentList += segment;
143 }
else if (name.find(
"degree")==0) {
147 char* d = (
char*)malloc(name.length()*
sizeof(char));
148 double angle, radius;
149 if (sscanf(name.c_str(),
"%1000s %6lf %6lf",d,&angle,&radius)!=3)
150 std::cout <<
"parameter parsing invalid!: " << name <<
"\n";
152 std::cout <<
"parameters " << d <<
"," << angle <<
" " << radius <<
"\n";
169 for(list<string>::iterator it = names.begin(); it!=names.end(); ++it) {
179 dsSetTexture (DS_NONE);
180 dsSetColor (color.r, color.g, color.b);
181 for(list<AbstractTrackSection*>::iterator it = SegmentList.begin();
182 it!= SegmentList.end(); ++it) {
190 if (obstacle_exists){
204 virtual void setGeometry(
double length_,
double width_,
double height_){
229 obstacle_exists=
false;
230 setColor(226 / 255.0, 103 / 255.0, 66 / 255.0);
231 numberOfBarcodes=256.0f;
237 raceground_space = space;
243 for(list<AbstractTrackSection*>::iterator it = SegmentList.begin();it!= SegmentList.end(); ++it) {
245 (*it)->create(raceground_space);
251 for(list<AbstractTrackSection*>::iterator it = SegmentList.begin();it!= SegmentList.end(); ++it) {
255 obstacle_exists=
false;
pair< double, double > getPositionOnTrack(const Position &p)
returns the barcode number of the given point returns (length,width) (-1,-1) if point is not on the t...
Definition: raceground.h:87
Matrix type.
Definition: matrix.h:65
Abstract class (interface) for obstacles.
Definition: abstracttracksection.h:37
virtual void setParameters(const Matrix &initpose)
Definition: raceground.h:227
virtual void setGeometry(double length_, double width_, double height_)
Definition: raceground.h:204
virtual void setColor(double r, double g, double b)
Definition: raceground.h:210
RaceGround(const OdeHandle &odehandle)
Definition: raceground.h:54
dSpaceID raceground_space
Definition: raceground.h:225
~RaceGround()
Destructor.
Definition: raceground.h:74
Matrix pose
Definition: raceground.h:222
virtual double getLength()=0
returns the length of the segment, here it is the length of the arc formula is: radius * angle; ...
virtual void destroy()
Definition: raceground.h:250
virtual double getLength()
returns the length of the segment, here it is the length of the arc
Definition: degreesegment.cpp:261
void addSegments(list< AbstractTrackSection * > listToAdd)
adds the segments in the list to the SegmentList
Definition: raceground.h:112
double width
Definition: raceground.h:220
Definition: position.h:30
class for degree segments
Definition: degreesegment.h:32
virtual void setPosition(double x, double y, double z)
Definition: raceground.h:189
void addSegment(AbstractTrackSection *Segment)
adds the segment to the SegmentList
Definition: raceground.h:119
Abstract class (interface) for obstacles.
Definition: straightline.h:32
void addSegments(list< string > names)
adds the named segments in the list to the SegmentList names are: straightline: StraightLine 90degree...
Definition: raceground.h:168
double g(double z)
neuron transfer function
Definition: regularisation.h:35
virtual void draw()
draws all the segments stored in SegmentList
Definition: raceground.h:177
virtual void setRadius(const double &rad)
Definition: degreesegment.cpp:64
virtual void setCurveAngle(const double &alpha)
Definition: degreesegment.cpp:56
Definition: raceground.h:44
virtual void create()
Definition: raceground.h:235
double height
Definition: raceground.h:221
void addSegment(string &name)
adds the named segment to the SegmentList names are: straightline: StraightLine 90degree : DegreeSegm...
Definition: raceground.h:130
RaceGround(const OdeHandle &odehandle, const Position &pos, double angle)
Definition: raceground.h:65
RaceGround(const OdeHandle &odehandle, const Matrix &pose)
Definition: raceground.h:60
void setNumberOfSegments(int number)
you set the number of segments of the track
Definition: raceground.h:79
double trackLength
Definition: raceground.h:219
double numberOfBarcodes
Definition: raceground.h:223
virtual void getPosition(double &x, double &y, double &z)
Definition: raceground.h:196