Program Listing for File robot_dynamics_applicator.hpp
↰ Return to documentation for file (cosm/tv/robot_dynamics_applicator.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include <boost/optional.hpp>
#include <map>
#include "rcppsw/ds/type_map.hpp"
#include "rcppsw/er/client.hpp"
#include "rcppsw/types/type_uuid.hpp"
#include "cosm/tv/switchable_tv_generator.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace cosm::tv {
namespace config {
struct robot_dynamics_applicator_config;
}
/*******************************************************************************
* Class Definitions
******************************************************************************/
class robot_dynamics_applicator : public rer::client<robot_dynamics_applicator> {
public:
explicit robot_dynamics_applicator(
const config::robot_dynamics_applicator_config* config);
robot_dynamics_applicator(const robot_dynamics_applicator&) = delete;
const robot_dynamics_applicator&
operator=(const robot_dynamics_applicator&) = delete;
virtual void update(void) = 0;
virtual double avg_motion_throttle(void) const = 0;
bool motion_throttling_enabled(void) const {
return (m_motion_throttle_config) ? true : false;
}
bool bc_throttling_enabled(void) const {
return (m_bc_throttle_config) ? true : false;
}
RCPPSW_PURE const ctv::switchable_tv_generator*
motion_throttler(const rtypes::type_uuid& id) const {
return const_cast<robot_dynamics_applicator*>(this)->motion_throttler(id);
}
RCPPSW_PURE const ctv::switchable_tv_generator*
bc_throttler(const rtypes::type_uuid& id) const {
return const_cast<robot_dynamics_applicator*>(this)->bc_throttler(id);
}
void register_controller(const rtypes::type_uuid& id);
void unregister_controller(const rtypes::type_uuid& id);
protected:
RCPPSW_PURE ctv::switchable_tv_generator*
motion_throttler(const rtypes::type_uuid& id) {
auto it = m_motion_throttlers.find(id);
if (m_motion_throttlers.end() == it) {
return nullptr;
}
return &it->second;
}
RCPPSW_PURE ctv::switchable_tv_generator*
bc_throttler(const rtypes::type_uuid& id) {
auto it = m_bc_throttlers.find(id);
if (m_bc_throttlers.end() == it) {
return nullptr;
}
return &it->second;
}
private:
/* clang-format off */
boost::optional<rct::config::waveform_config> m_motion_throttle_config{};
boost::optional<rct::config::waveform_config> m_bc_throttle_config{};
std::map<rtypes::type_uuid,
ctv::switchable_tv_generator> m_motion_throttlers{};
std::map<rtypes::type_uuid,
ctv::switchable_tv_generator> m_bc_throttlers{};
/* clang-format on */
};
} /* namespace cosm::tv */