mc_rtc  2.12.0
Robot.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2020 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 #include <mc_rbdyn/Robot.h>
12 
13 namespace mc_rtc::gui
14 {
15 
16 namespace details
17 {
18 
27 template<typename GetT>
28 struct RobotImpl : public Element
29 {
30  static constexpr auto type = Elements::Robot;
31 
32  RobotImpl(const std::string & name, GetT get_fn) : Element(name), get_fn_(get_fn)
33  {
34  static_assert(CheckReturnType<GetT, mc_rbdyn::Robot>::value, "Robot element must return an mc_rbdyn::Robot");
35  }
36 
37  static constexpr size_t write_size() { return Element::write_size() + 3; }
38 
40  {
41  const mc_rbdyn::Robot & robot = get_fn_();
42  Element::write(builder);
43  builder.write(robot.module().parameters());
44  builder.write(robot.mbc().q);
45  builder.write(robot.posW());
46  }
47 
48 private:
49  GetT get_fn_;
50 };
51 
52 } // namespace details
53 
55 template<typename GetT>
56 auto Robot(const std::string & name, GetT get_fn)
57 {
58  return details::RobotImpl(name, get_fn);
59 }
60 
61 } // namespace mc_rtc::gui
Definition: Observer.h:16
auto Robot(const std::string &name, GetT get_fn)
Definition: Robot.h:56
const std::vector< std::string > & parameters() const
Definition: RobotModule.h:511
Definition: Robot.h:63
rbd::MultiBodyConfig & mbc()
const RobotModule & module() const
const sva::PTransformd & posW() const
Definition: MessagePackBuilder.h:87
Definition: elements.h:59
const std::string & name() const
Definition: elements.h:61
void write(mc_rtc::MessagePackBuilder &)
Definition: elements.h:83
static constexpr size_t write_size()
Definition: elements.h:76
Definition: Robot.h:29
static constexpr auto type
Definition: Robot.h:30
RobotImpl(const std::string &name, GetT get_fn)
Definition: Robot.h:32
static constexpr size_t write_size()
Definition: Robot.h:37
void write(mc_rtc::MessagePackBuilder &builder)
Definition: Robot.h:39