Choreonoid  1.8
ControllerItem.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_PLUGIN_CONTROLLER_ITEM_H
7 #define CNOID_BODY_PLUGIN_CONTROLLER_ITEM_H
8 
9 #include "SimulatorItem.h"
10 #include <cnoid/ControllerIO>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class ControllerIO;
16 class ControllerLogItem;
17 
18 class Body;
19 
20 class CNOID_EXPORT ControllerItem : public Item
21 {
22 public:
23  static void initializeClass(ExtensionManager* ext);
24 
25  // for the backward compatibility
27 
29  ControllerItem(const ControllerItem& org);
30  virtual ~ControllerItem();
31 
32  bool isActive() const;
33  bool isNoDelayMode() const { return isNoDelayMode_; }
34  virtual void setNoDelayMode(bool on);
35 
36  const std::string& optionString() const { return optionString_; }
37  void setOptions(const std::string& options) { optionString_ = options; }
38 
39  virtual double timeStep() const;
40 
49  virtual bool initialize(ControllerIO* io);
50 
51  virtual ControllerLogItem* createLogItem();
52 
56  virtual bool start();
57 
61  virtual void input();
62 
63  /*
64  @return false to request stopping
65  @note The body oject given in the initalized function() must not be accessed
66  in this function. The access should be done in input() and output().
67  @note This function is called from the simulation thread.
68  */
69  virtual bool control();
70 
71  virtual void log();
72 
76  virtual void output();
77 
81  virtual void stop();
82 
84  bool isImmediateMode() const { return isNoDelayMode(); }
86  void setImmediateMode(bool on) { setNoDelayMode(on); }
87 
88 protected:
89  virtual void onOptionsChanged();
90 
91  virtual void doPutProperties(PutPropertyFunction& putProperty) override;
92  virtual bool store(Archive& archive) override;
93  virtual bool restore(const Archive& archive) override;
94 
95 private:
96  SimulatorItemPtr simulatorItem_;
97  bool isNoDelayMode_;
98  std::string optionString_;
99 
100  friend class SimulatorItem;
101  void setSimulatorItem(SimulatorItem* item);
102 };
103 
105 
106 }
107 
108 #endif
cnoid::ControllerItem::setImmediateMode
void setImmediateMode(bool on)
Definition: ControllerItem.h:86
cnoid::ControllerItemPtr
ref_ptr< ControllerItem > ControllerItemPtr
Definition: ControllerItem.h:104
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::PutPropertyFunction
Definition: PutPropertyFunction.h:51
cnoid::ControllerItem::isImmediateMode
bool isImmediateMode() const
Definition: ControllerItem.h:84
cnoid::ControllerItem::isNoDelayMode
bool isNoDelayMode() const
Definition: ControllerItem.h:33
cnoid::Archive
Definition: Archive.h:22
cnoid::ControllerIO
Definition: ControllerIO.h:16
cnoid::ControllerItem
Definition: ControllerItem.h:20
cnoid::ref_ptr< SimulatorItem >
cnoid::ControllerItem::setOptions
void setOptions(const std::string &options)
Definition: ControllerItem.h:37
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
cnoid::ControllerItem::Target
ControllerIO Target
Definition: ControllerItem.h:26
SimulatorItem.h
cnoid::ControllerItem::optionString
const std::string & optionString() const
Definition: ControllerItem.h:36
cnoid::ControllerLogItem
Definition: ControllerLogItem.h:9
cnoid::SimulatorItem
Definition: SimulatorItem.h:81