Trajectory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
8 #include <mc_rtc/gui/elements.h>
9 #include <mc_rtc/gui/types.h>
10 
11 namespace mc_rtc::gui
12 {
13 
14 namespace details
15 {
16 
26 template<typename GetT>
27 struct TrajectoryImpl : public DataElement<GetT>
28 {
29  static constexpr auto type = Elements::Trajectory;
30 
31  TrajectoryImpl(const std::string & name, const LineConfig & config, GetT get_fn)
32  : DataElement<GetT>(name, get_fn), config_(config)
33  {
34  static_assert(details::CheckReturnType<GetT, Eigen::Vector3d, sva::PTransformd, std::vector<Eigen::Vector3d>,
35  std::vector<sva::PTransformd>>::value,
36  "Trajectory element data callback must return either an Eigen::Vector3d, an sva::PTransformd or an "
37  "std::vector of either types");
38  }
39 
42 
43  constexpr static size_t write_size() { return DataElement<GetT>::write_size() + LineConfig::write_size(); }
44 
46  {
47  DataElement<GetT>::write(builder);
48  config_.write(builder);
49  }
50 
51 private:
52  LineConfig config_;
53 };
54 
55 } // namespace details
56 
58 template<typename GetT>
59 auto Trajectory(const std::string & name, GetT get_fn)
60 {
61  return details::TrajectoryImpl(name, {}, get_fn);
62 }
63 
65 template<typename GetT>
66 auto Trajectory(const std::string & name, const LineConfig & config, GetT get_fn)
67 {
68  return details::TrajectoryImpl(name, config, get_fn);
69 }
70 
71 } // namespace mc_rtc::gui
mc_rtc::gui::details::TrajectoryImpl::type
static constexpr auto type
Definition: Trajectory.h:29
mc_rtc::gui::DataElement::write_size
static constexpr size_t write_size()
Definition: elements.h:106
mc_rtc::MessagePackBuilder
Definition: MessagePackBuilder.h:86
mc_rtc::gui::Elements::Trajectory
@ Trajectory
types.h
mc_rtc::gui::details::TrajectoryImpl::TrajectoryImpl
TrajectoryImpl()
Definition: Trajectory.h:41
mc_rtc::gui::LineConfig
Definition: types.h:135
mc_rtc::gui::Trajectory
auto Trajectory(const std::string &name, GetT get_fn)
Definition: Trajectory.h:59
mc_rtc::gui::LineConfig::write
void write(mc_rtc::MessagePackBuilder &out) const
Definition: types.h:179
mc_rtc::gui::details::TrajectoryImpl::write
void write(mc_rtc::MessagePackBuilder &builder)
Definition: Trajectory.h:45
elements.h
mc_rtc::gui::details::TrajectoryImpl::TrajectoryImpl
TrajectoryImpl(const std::string &name, const LineConfig &config, GetT get_fn)
Definition: Trajectory.h:31
mc_rtc::gui::DataElement
Definition: elements.h:104
mc_rtc::gui::details::TrajectoryImpl
Definition: Trajectory.h:27
mc_rtc::gui::details::TrajectoryImpl::write_size
constexpr static size_t write_size()
Definition: Trajectory.h:43
mc_rtc::gui::DataElement::write
void write(mc_rtc::MessagePackBuilder &builder)
Definition: elements.h:108
traits.h
mc_rtc::gui::LineConfig::write_size
static constexpr size_t write_size()
Definition: types.h:177
mc_rtc::gui::details::CheckReturnType
Definition: traits.h:86
mc_rtc::gui
Definition: Observer.h:15
mc_rtc::gui::Element::name
const std::string & name() const
Definition: elements.h:61