RobotUnitModuleManagement.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::RobotUnit
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
27 
29 {
30  void
31  Management::_preOnInitRobotUnit()
32  {
33  throwIfInControlThread(BOOST_CURRENT_FUNCTION);
34  additionalObjectSchedulerCount =
35  getProperty<std::uint64_t>("AdditionalObjectSchedulerCount").getValue();
36  heartbeatRequired = getProperty<bool>("HeartbeatRequired").getValue();
37  heartbeatMaxCycleMS = getProperty<long>("HeartbeatMaxCycleMS").getValue();
38  heartbeatStartupMarginMS = getProperty<long>("HeartbeatStartupMarginMS").getValue();
39  getArmarXManager()->increaseSchedulers(static_cast<int>(additionalObjectSchedulerCount));
40 
41  usingTopic(getProperty<std::string>("AggregatedRobotHealthTopicName").getValue());
42  }
43 
44  void
45  Management::_postFinishControlThreadInitialization()
46  {
47  controlLoopStartTime = TimeUtil::GetTime(true).toMilliSeconds();
48  }
49 
50  void
51  Management::aggregatedHeartbeat(RobotHealthState overallHealthState, const Ice::Current&)
52  {
53  heartbeatRequired = true;
54  if (overallHealthState == RobotHealthState::HealthOK ||
55  overallHealthState == RobotHealthState::HealthWarning)
56  {
57  lastHeartbeat = TimeUtil::GetTime(true).toMilliSeconds();
58  }
59  }
60 
61 } // namespace armarx::RobotUnitModule
ArmarXManager.h
armarx::ManagedIceObject::getArmarXManager
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
Definition: ManagedIceObject.cpp:348
armarx::RobotUnitModule::Management::aggregatedHeartbeat
void aggregatedHeartbeat(RobotHealthState overallHealthState, const Ice::Current &) override
Definition: RobotUnitModuleManagement.cpp:51
armarx::TimeUtil::GetTime
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Definition: TimeUtil.cpp:42
armarx::control::common::getValue
T getValue(nlohmann::json &userConfig, nlohmann::json &defaultConfig, const std::string &entryName)
Definition: utils.h:71
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:248
TimeUtil.h
armarx::RobotUnitModule::ModuleBase::throwIfInControlThread
void throwIfInControlThread(const std::string &fnc) const
Throws if the current thread is the ControlThread.
Definition: RobotUnitModuleBase.cpp:416
armarx::RobotUnitModule
Definition: ControlDevice.h:34
RobotUnitModuleManagement.h