Skip to content
Snippets Groups Projects
Commit b045828d authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Modernize code (nested namespace)

parent 1749c7f8
No related branches found
No related tags found
No related merge requests found
Showing
with 5349 additions and 5402 deletions
...@@ -31,23 +31,22 @@ ...@@ -31,23 +31,22 @@
#include "../ControlModes.h" #include "../ControlModes.h"
#include "../JointControllers/JointController.h" #include "../JointControllers/JointController.h"
namespace armarx namespace armarx::RobotUnitModule
{ {
namespace RobotUnitModule TYPEDEF_PTRS_HANDLE(Devices);
{ }
TYPEDEF_PTRS_HANDLE(Devices);
}
TYPEDEF_PTRS_SHARED(ControlDevice);
namespace ControlDeviceTags namespace armarx::ControlDeviceTags
{ {
using namespace DeviceTags; using namespace DeviceTags;
const static std::string PeriodicPosition = "ControlDeviceTag_PeriodicPosition"; const static std::string PeriodicPosition = "ControlDeviceTag_PeriodicPosition";
const static std::string CreateNoDefaultController = "ControlDeviceTag_CreateNoDefaultController"; const static std::string CreateNoDefaultController = "ControlDeviceTag_CreateNoDefaultController";
const static std::string ForcePositionThroughVelocity = "ControlDeviceTag_ForcePositionThroughVelocity"; const static std::string ForcePositionThroughVelocity = "ControlDeviceTag_ForcePositionThroughVelocity";
} }
namespace armarx
{
TYPEDEF_PTRS_SHARED(ControlDevice);
/** /**
* @brief The ControlDevice class represents a logical unit accepting commands via its JointControllers. * @brief The ControlDevice class represents a logical unit accepting commands via its JointControllers.
* *
......
...@@ -25,12 +25,13 @@ ...@@ -25,12 +25,13 @@
#include"SensorDevice.h" #include"SensorDevice.h"
#include "../SensorValues/SensorValueRTThreadTimings.h" #include "../SensorValues/SensorValueRTThreadTimings.h"
namespace armarx::RobotUnitModule
{
TYPEDEF_PTRS_HANDLE(ControlThread);
}
namespace armarx namespace armarx
{ {
namespace RobotUnitModule
{
TYPEDEF_PTRS_HANDLE(ControlThread);
}
TYPEDEF_PTRS_SHARED(RTThreadTimingsSensorDevice); TYPEDEF_PTRS_SHARED(RTThreadTimingsSensorDevice);
class RTThreadTimingsSensorDevice: virtual public SensorDevice class RTThreadTimingsSensorDevice: virtual public SensorDevice
......
...@@ -27,19 +27,19 @@ ...@@ -27,19 +27,19 @@
#include "../util.h" #include "../util.h"
#include <IceUtil/Time.h> #include <IceUtil/Time.h>
namespace armarx namespace armarx::RobotUnitModule
{ {
namespace RobotUnitModule TYPEDEF_PTRS_HANDLE(Devices);
{ }
TYPEDEF_PTRS_HANDLE(Devices);
}
TYPEDEF_PTRS_SHARED(SensorDevice);
namespace SensorDeviceTags namespace armarx::SensorDeviceTags
{ {
using namespace DeviceTags; using namespace DeviceTags;
} }
namespace armarx
{
TYPEDEF_PTRS_SHARED(SensorDevice);
/** /**
* @brief This class represents some part of the robot providing sensor values. * @brief This class represents some part of the robot providing sensor values.
* *
......
...@@ -29,37 +29,35 @@ ...@@ -29,37 +29,35 @@
#include <atomic> #include <atomic>
namespace armarx namespace armarx::RobotUnitModule
{ {
namespace RobotUnitModule
{
/** /**
* \brief This class allows minimal access to private members of \ref armarx::RobotUnitModule::Devices in a sane fashion for \ref armarx::NJointControllerBase. * \brief This class allows minimal access to private members of \ref armarx::RobotUnitModule::Devices in a sane fashion for \ref armarx::NJointControllerBase.
* \warning !! DO NOT ADD ANYTHING IF YOU DO NOT KNOW WAHT YOU ARE DOING! IF YOU DO SOMETHING WRONG YOU WILL CAUSE UNDEFINED BEHAVIOUR !! * \warning !! DO NOT ADD ANYTHING IF YOU DO NOT KNOW WAHT YOU ARE DOING! IF YOU DO SOMETHING WRONG YOU WILL CAUSE UNDEFINED BEHAVIOUR !!
*/ */
class DevicesAttorneyForNJointController class DevicesAttorneyForNJointController
{
friend class ::armarx::NJointControllerBase;
static JointController* GetJointController(Devices& d, const std::string& deviceName, const std::string& controlMode)
{ {
friend class ::armarx::NJointControllerBase; if (d.controlDevices.has(deviceName))
static JointController* GetJointController(Devices& d, const std::string& deviceName, const std::string& controlMode)
{ {
if (d.controlDevices.has(deviceName)) auto& dev = d.controlDevices.at(deviceName);
if (dev->hasJointController(controlMode))
{ {
auto& dev = d.controlDevices.at(deviceName); ARMARX_CHECK_NOT_NULL(dev->getJointController(controlMode));
if (dev->hasJointController(controlMode)) ARMARX_CHECK_NOT_NULL(dev->getJointController(controlMode)->getControlTarget());
{ return dev->getJointController(controlMode);
ARMARX_CHECK_NOT_NULL(dev->getJointController(controlMode));
ARMARX_CHECK_NOT_NULL(dev->getJointController(controlMode)->getControlTarget());
return dev->getJointController(controlMode);
}
} }
return nullptr;
} }
}; return nullptr;
} }
};
} }
thread_local bool armarx::NJointControllerRegistryEntry::ConstructorIsRunning_ = false; thread_local bool armarx::NJointControllerRegistryEntry::ConstructorIsRunning_ = false;
namespace armarx namespace armarx
......
...@@ -24,13 +24,10 @@ ...@@ -24,13 +24,10 @@
#include "RobotUnitModuleBase.h" #include "RobotUnitModuleBase.h"
namespace armarx namespace armarx::RobotUnitModule
{
namespace RobotUnitModule
{ {
inline RobotUnitState ModuleBase::getRobotUnitState() const inline RobotUnitState ModuleBase::getRobotUnitState() const
{ {
return state; return state;
} }
} }
}
...@@ -25,36 +25,33 @@ ...@@ -25,36 +25,33 @@
#include "RobotUnitModuleManagement.h" #include "RobotUnitModuleManagement.h"
#include <ArmarXCore/core/time/TimeUtil.h> #include <ArmarXCore/core/time/TimeUtil.h>
namespace armarx namespace armarx::RobotUnitModule
{ {
namespace RobotUnitModule void Management::_preOnInitRobotUnit()
{ {
void Management::_preOnInitRobotUnit() throwIfInControlThread(BOOST_CURRENT_FUNCTION);
{ additionalObjectSchedulerCount = getProperty<std::uint64_t>("AdditionalObjectSchedulerCount").getValue();
throwIfInControlThread(BOOST_CURRENT_FUNCTION); heartbeatRequired = getProperty<bool>("HeartbeatRequired").getValue();
additionalObjectSchedulerCount = getProperty<std::uint64_t>("AdditionalObjectSchedulerCount").getValue(); heartbeatMaxCycleMS = getProperty<long>("HeartbeatMaxCycleMS").getValue();
heartbeatRequired = getProperty<bool>("HeartbeatRequired").getValue(); heartbeatStartupMarginMS = getProperty<long>("HeartbeatStartupMarginMS").getValue();
heartbeatMaxCycleMS = getProperty<long>("HeartbeatMaxCycleMS").getValue(); getArmarXManager()->increaseSchedulers(static_cast<int>(additionalObjectSchedulerCount));
heartbeatStartupMarginMS = getProperty<long>("HeartbeatStartupMarginMS").getValue();
getArmarXManager()->increaseSchedulers(static_cast<int>(additionalObjectSchedulerCount)); usingTopic(getProperty<std::string>("AggregatedRobotHealthTopicName").getValue());
}
usingTopic(getProperty<std::string>("AggregatedRobotHealthTopicName").getValue());
}
void Management::_postFinishControlThreadInitialization() void Management::_postFinishControlThreadInitialization()
{ {
controlLoopStartTime = TimeUtil::GetTime(true).toMilliSeconds(); controlLoopStartTime = TimeUtil::GetTime(true).toMilliSeconds();
} }
void Management::aggregatedHeartbeat(RobotHealthState overallHealthState, const Ice::Current&) void Management::aggregatedHeartbeat(RobotHealthState overallHealthState, const Ice::Current&)
{
heartbeatRequired = true;
if (overallHealthState == RobotHealthState::HealthOK || overallHealthState == RobotHealthState::HealthWarning)
{ {
heartbeatRequired = true; lastHeartbeat = TimeUtil::GetTime(true).toMilliSeconds();
if (overallHealthState == RobotHealthState::HealthOK || overallHealthState == RobotHealthState::HealthWarning)
{
lastHeartbeat = TimeUtil::GetTime(true).toMilliSeconds();
}
} }
} }
} }
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