Skip to content
Snippets Groups Projects
Commit 01b6ffe3 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Move code to cpp

parent d96df73f
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,16 @@
using namespace armarx;
IMUSimulationPropertyDefinitions::IMUSimulationPropertyDefinitions(std::string prefix):
InertialMeasurementUnitPropertyDefinitions(prefix)
{
defineOptionalProperty<std::string>("nodeName", "HeadIMU", "");
defineOptionalProperty<std::string>("SimulatorName", "Simulator", "Name of the simulator component that should be used");
defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the robot state component that should be used");
}
void IMUSimulation::onInitIMU()
{
usingProxy(getProperty<std::string>("RobotStateComponentName").getValue());
......@@ -39,6 +49,7 @@ void IMUSimulation::onInitIMU()
usingProxy(getProperty<std::string>("SimulatorName").getValue());
}
void IMUSimulation::onStartIMU()
{
robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(getProperty<std::string>("RobotStateComponentName").getValue());
......@@ -50,16 +61,12 @@ void IMUSimulation::onStartIMU()
sensorTask->start();
}
void IMUSimulation::onExitIMU()
{
sensorTask->stop();
}
armarx::PropertyDefinitionsPtr IMUSimulation::createPropertyDefinitions()
{
return armarx::PropertyDefinitionsPtr(new IMUSimulationPropertyDefinitions(
getConfigIdentifier()));
}
void IMUSimulation::frameAcquisitionTaskLoop()
{
......@@ -87,7 +94,6 @@ void IMUSimulation::frameAcquisitionTaskLoop()
if (timestamp)
{
Eigen::Vector3f acceleration = (currentLinearVelocity - linearVelocity) / deltaTime;
IMUData data;
......@@ -110,7 +116,6 @@ void IMUSimulation::frameAcquisitionTaskLoop()
data.orientationQuaternion.push_back(currentOrientation.z());
IMUTopicPrx->reportSensorValues(getName(), "name", data, now);
}
orientation = currentOrientation;
......@@ -119,3 +124,15 @@ void IMUSimulation::frameAcquisitionTaskLoop()
linearVelocity = currentLinearVelocity;
}
std::string IMUSimulation::getDefaultName() const
{
return "IMUSimulation";
}
armarx::PropertyDefinitionsPtr IMUSimulation::createPropertyDefinitions()
{
return armarx::PropertyDefinitionsPtr(new IMUSimulationPropertyDefinitions(getConfigIdentifier()));
}
......@@ -50,15 +50,10 @@ namespace armarx
public InertialMeasurementUnitPropertyDefinitions
{
public:
IMUSimulationPropertyDefinitions(std::string prefix):
InertialMeasurementUnitPropertyDefinitions(prefix)
{
defineOptionalProperty<std::string>("nodeName", "HeadIMU", "");
defineOptionalProperty<std::string>("SimulatorName", "Simulator", "Name of the simulator component that should be used");
defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the robot state component that should be used");
}
IMUSimulationPropertyDefinitions(std::string prefix);
};
/**
* @defgroup Component-IMUSimulation IMUSimulation
* @ingroup ArmarXSimulation-Components
......@@ -74,37 +69,35 @@ namespace armarx
virtual public InertialMeasurementUnit
{
public:
/**
* @see armarx::ManagedIceObject::getDefaultName()
*/
std::string getDefaultName() const override
{
return "IMUSimulation";
}
/// @see armarx::ManagedIceObject::getDefaultName()
std::string getDefaultName() const override;
protected:
/// @see PropertyUser::createPropertyDefinitions()
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override;
void onInitIMU() override;
void onStartIMU() override;
void onExitIMU() override;
/**
* @see PropertyUser::createPropertyDefinitions()
*/
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override;
private:
void frameAcquisitionTaskLoop();
Eigen::Quaternionf orientation;
private:
PeriodicTask<IMUSimulation>::pointer_type sensorTask;
Eigen::Vector3f position;
Eigen::Quaternionf orientation;
std::string nodeName;
double timestamp;
......@@ -113,7 +106,6 @@ namespace armarx
SimulatorInterfacePrx simulator;
RobotStateComponentInterfacePrx robotStateComponent;
DebugDrawerInterfacePrx debugDrawerTopic;
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment