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
mc_rtc::gui::Element
Definition: elements.h:58
mc_rtc::MessagePackBuilder
Definition: MessagePackBuilder.h:86
types.h
mc_rtc::gui::Element::write
void write(mc_rtc::MessagePackBuilder &)
Definition: elements.h:83
mc_rbdyn::Robot
Definition: Robot.h:62
mc_rtc::gui::details::RobotImpl
Definition: Robot.h:28
mc_rtc::gui::details::RobotImpl::type
static constexpr auto type
Definition: Robot.h:30
mc_rbdyn::RobotModule::parameters
const std::vector< std::string > & parameters() const
Definition: RobotModule.h:511
mc_rbdyn::Robot::module
const RobotModule & module() const
mc_rtc::gui::Elements::Robot
@ Robot
elements.h
mc_rtc::gui::details::RobotImpl::RobotImpl
RobotImpl(const std::string &name, GetT get_fn)
Definition: Robot.h:32
mc_rbdyn::Robot::posW
const sva::PTransformd & posW() const
Robot.h
mc_rtc::MessagePackBuilder::write
void write()
mc_rtc::gui::details::RobotImpl::write_size
static constexpr size_t write_size()
Definition: Robot.h:37
mc_rbdyn::Robot::mbc
rbd::MultiBodyConfig & mbc()
mc_rtc::gui::Element::write_size
static constexpr size_t write_size()
Definition: elements.h:76
mc_rtc::gui::details::RobotImpl::write
void write(mc_rtc::MessagePackBuilder &builder)
Definition: Robot.h:39
mc_rtc::gui::Robot
auto Robot(const std::string &name, GetT get_fn)
Definition: Robot.h:56
traits.h
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