Parallel.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 
7 #include <mc_control/fsm/State.h>
8 
9 namespace mc_control
10 {
11 
12 namespace fsm
13 {
14 
40 {
41  void start(Controller &) override;
42 
43  bool run(Controller &) override;
44 
45  void stop(Controller &) override;
46 
47  void teardown(Controller &) override;
48 
49  bool read_msg(std::string & msg) override;
50 
51  bool read_write_msg(std::string & msg, std::string & out) override;
52 
53  std::vector<std::string> states() const;
54 
55  std::map<std::string, mc_rtc::Configuration> configs() const;
56 
57 protected:
58  double time_ = 0;
59  struct DelayedState
60  {
61  DelayedState(Controller & ctl, const std::string & name, double delay, mc_rtc::Configuration config);
62  bool run(Controller & ctl, double time);
63  StatePtr & state();
64 
65  const std::string & name() { return name_; };
66 
67  private:
68  StatePtr state_;
69  std::string name_;
70  mc_rtc::Configuration config_;
71  double delay_;
72  void createState(Controller & ctl);
73  };
74  std::vector<DelayedState> states_;
79  std::vector<std::string> outputStates_;
80  bool finished_first_ = false;
81 };
82 
83 } // namespace fsm
84 
85 } // namespace mc_control
mc_rtc::Configuration
Simplify access to values hold within a JSON file.
Definition: Configuration.h:165
mc_control::fsm::ParallelState
Definition: Parallel.h:39
mc_control::fsm::State
Definition: State.h:58
mc_control::fsm::ParallelState::outputStates_
std::vector< std::string > outputStates_
Definition: Parallel.h:79
mc_control::fsm::ParallelState::states_
std::vector< DelayedState > states_
Definition: Parallel.h:74
mc_control::fsm::ParallelState::DelayedState
Definition: Parallel.h:59
mc_control
Definition: CompletionCriteria.h:10
State.h
MC_CONTROL_FSM_STATE_DLLAPI
#define MC_CONTROL_FSM_STATE_DLLAPI
Definition: api.h:50
mc_control::fsm::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:172
mc_control::fsm::Controller
Definition: Controller.h:49
mc_control::fsm::ParallelState::DelayedState::name
const std::string & name()
Definition: Parallel.h:65