MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
|
00001 #include "rangeSensorData.h" 00002 #include <string.h> 00003 #include <stdio.h> 00004 #include <assert.h> 00005 #include "matFuns.h" 00006 00007 rangeSensorData::rangeSensorData(): 00008 numSensors(0), 00009 devError(0), 00010 gammamax(0), 00011 aperture(0), 00012 maxDist(0), 00013 minDist(0), 00014 data(0), 00015 sensorPos(0) 00016 { 00017 00018 } 00019 00020 rangeSensorData::rangeSensorData(int ns, float de, float gmax, float ap, float Maxd, float mind): 00021 numSensors(ns), 00022 devError(de), 00023 gammamax(gmax), 00024 aperture(ap), 00025 maxDist(Maxd), 00026 minDist(mind), 00027 data(new float[numSensors]), 00028 sensorPos(new pose[numSensors]()) 00029 { 00030 for (int j=0; j<numSensors; j++){ 00031 data[j]=0.0f; 00032 sensorPos[j].x = 0.0f; 00033 sensorPos[j].y = 0.0f; 00034 sensorPos[j].th = j*2*gammamax/(numSensors-1)-gammamax; 00035 } 00036 } 00037 00038 void rangeSensorData::initialize(int ns, float de, float gmax, float ap, float Maxd, float mind){ 00039 00040 numSensors = ns; 00041 devError = de; 00042 gammamax = gmax; 00043 aperture = ap; 00044 maxDist=Maxd; 00045 minDist=mind; 00046 if (data) delete[] data; 00047 data = new float[numSensors]; 00048 if (sensorPos) delete[] sensorPos; 00049 sensorPos = new pose[numSensors](); 00050 00051 for (int j=0; j<numSensors; j++){ 00052 data[j]=0.0f; 00053 sensorPos[j].x = 0.0f; 00054 sensorPos[j].y = 0.0f; 00055 sensorPos[j].th = j*2*gammamax/(numSensors-1)-gammamax; 00056 } 00057 } 00058 00059 00060 rangeSensorData::rangeSensorData(const rangeSensorData& rsd): 00061 numSensors(rsd.numSensors), 00062 devError(rsd.devError), 00063 gammamax(rsd.gammamax), 00064 aperture(rsd.aperture), 00065 maxDist(rsd.maxDist), 00066 minDist(rsd.minDist), 00067 data(new float[numSensors]), 00068 sensorPos(new pose[numSensors]()) 00069 { 00070 memcpy(data,rsd.data,numSensors*sizeof(float)); 00071 memcpy(sensorPos,rsd.sensorPos,numSensors*sizeof(pose)); 00072 } 00073 00074 rangeSensorData::~rangeSensorData(){ 00075 if (data) delete[] data; 00076 if (sensorPos) delete[] sensorPos; 00077 } 00078 00079 rangeSensorData& rangeSensorData::operator= (const rangeSensorData &rsd){ 00080 if (numSensors != rsd.numSensors){ 00081 if (data) delete[] data; 00082 data = new float[rsd.numSensors]; 00083 if (sensorPos) delete[] sensorPos; 00084 sensorPos = new pose[rsd.numSensors](); 00085 } 00086 numSensors = rsd.numSensors; 00087 devError = rsd.devError; 00088 gammamax = rsd.gammamax; 00089 aperture = rsd.aperture; 00090 maxDist = rsd.maxDist; 00091 minDist = rsd.minDist; 00092 memcpy(data,rsd.data,numSensors*sizeof(float)); 00093 memcpy(sensorPos,rsd.sensorPos,numSensors*sizeof(pose)); 00094 00095 // return the existing object 00096 return *this; 00097 } 00098 00099 00100