Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WORKING COMMIT of tgDataManager and related files, including tgSensor…
…Infos! Currently, tgDataManager will create sensors based on the sensorInfos, and everythign 'should' be handled properly with reset, teardown, setup, and various constructors/destructors. There shouldn't be any memory leaks with this commit, I tried very hard to keep it clean!
- Loading branch information
1 parent
e68955f
commit 6c1a36d
Showing
12 changed files
with
384 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright © 2012, United States Government, as represented by the | ||
* Administrator of the National Aeronautics and Space Administration. | ||
* All rights reserved. | ||
* | ||
* The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed | ||
* under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file tgRodSensorInfo.cpp | ||
* @brief Contains the implementation of concrete class tgRodSensorInfo | ||
* @author Drew Sabelhaus | ||
* $Id$ | ||
*/ | ||
|
||
// This module | ||
#include "tgRodSensorInfo.h" | ||
// Other includes from NTRTsim | ||
#include "tgRodSensor.h" | ||
#include "core/tgRod.h" | ||
#include "core/tgSenseable.h" | ||
#include "core/tgCast.h" | ||
// Other includes from the C++ standard library | ||
#include <stdexcept> | ||
|
||
/** | ||
* Nothing to do in this constructor. A sensor info doesn't have any data. | ||
*/ | ||
tgRodSensorInfo::tgRodSensorInfo() | ||
{ | ||
} | ||
|
||
/** | ||
* Similarly, empty destructor. | ||
*/ | ||
tgRodSensorInfo::~tgRodSensorInfo() | ||
{ | ||
} | ||
|
||
/** | ||
* To check if a tgSenseable is a tgRod, we can use tgCast. | ||
*/ | ||
bool tgRodSensorInfo::isThisMySenseable(tgSenseable* pSenseable) | ||
{ | ||
// The following cast will return 0 if the senseable is not a tgRod. | ||
tgRod* m_pRod = tgCast::cast<tgSenseable, tgRod>(pSenseable); | ||
if( m_pRod == 0 ) | ||
return 0; | ||
else { | ||
return 1; | ||
} | ||
} | ||
|
||
/** | ||
* Create a rod sensor for a tgRod. | ||
*/ | ||
tgSensor* tgRodSensorInfo::createSensor(tgSenseable* pSenseable) | ||
{ | ||
//CHECK: the caller SHOULD HAVE made sure that pSenseable | ||
// was a tgRod pointer. If not, complain!! | ||
if (!isThisMySenseable(pSenseable)) { | ||
throw std::invalid_argument("pSenseable is NOT a tgRod, inside tgRodSensorInfo."); | ||
} | ||
// Then, if the program hasn't quit, make the sensor. | ||
// Note that we cast the pointer here, knowing that it will succeed. | ||
return new tgRodSensor( tgCast::cast<tgSenseable, tgRod>(pSenseable) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright © 2012, United States Government, as represented by the | ||
* Administrator of the National Aeronautics and Space Administration. | ||
* All rights reserved. | ||
* | ||
* The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed | ||
* under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
#ifndef TG_ROD_SENSOR_INFO_H | ||
#define TG_ROD_SENSOR_INFO_H | ||
|
||
/** | ||
* @file tgRodSensorInfo.h | ||
* @brief Definition of concrete class tgRodSensorInfo | ||
* @author Drew Sabelhaus | ||
* @date January 2017 | ||
* $Id$ | ||
*/ | ||
|
||
// This module | ||
#include "tgSensorInfo.h" | ||
// Other includes from NTRTsim | ||
//#include "core/tgRod.h" | ||
// Other includes from the C++ standard library | ||
// ... | ||
|
||
// Forward references | ||
class tgSenseable; | ||
class tgRod; | ||
class tgRodSensor; | ||
class tgSensor; | ||
|
||
/** | ||
* tgRodSensorInfo is a sensor info class that creates tgRodSensors for | ||
* tgRods. | ||
*/ | ||
class tgRodSensorInfo : public tgSensorInfo | ||
{ | ||
public: | ||
|
||
/** | ||
* tgSensorInfo has an empty constructor. It does not contain any data. | ||
*/ | ||
tgRodSensorInfo(); | ||
|
||
/** | ||
* Similarly, its destructor should be empty. | ||
*/ | ||
~tgRodSensorInfo(); | ||
|
||
/** | ||
* From tgSensorInfo, need to implement a check to see if a particular | ||
* tgSenseable is a tgRod. | ||
*/ | ||
virtual bool isThisMySenseable(tgSenseable* pSenseable); | ||
|
||
/** | ||
* Similarly, create a sensor if appropriate. | ||
* See tgSensorInfo for more... info. | ||
*/ | ||
virtual tgSensor* createSensor(tgSenseable* pSenseable); | ||
|
||
}; | ||
|
||
#endif // TG_ROD_SENSOR_INFO_H |
Oops, something went wrong.