1 #ifndef CONTROL_CONTROLLER_BASE_H 2 #define CONTROL_CONTROLLER_BASE_H 4 #include <Klampt/Modeling/Robot.h> 5 #include <Klampt/Sensing/Sensor.h> 7 #include <KrisLibrary/File.h> 35 virtual const char* Type()
const {
return "RobotController"; }
36 virtual void Update(Real dt) { time+=dt; }
37 virtual void Reset() { time=0; }
38 virtual bool ReadState(File& f);
39 virtual bool WriteState(File& f)
const;
41 virtual map<string,string> Settings()
const {
return map<string,string>(); }
42 virtual bool GetSetting(
const string& name,
string& str)
const {
return false; }
43 virtual bool SetSetting(
const string& name,
const string& str) {
return false; }
45 virtual vector<string> Commands()
const {
return vector<string>(); }
46 virtual bool SendCommand(
const string& name,
const string& str) {
return false; }
49 void SetPIDCommand(
const Config& qdes);
50 void SetPIDCommand(
const Config& qdes,
const Config& dqdes);
51 void SetFeedforwardPIDCommand(
const Config& qdes,
const Config& dqdes,
const Vector&torques);
52 void SetTorqueCommand(
const Vector& torques);
54 bool GetCommandedConfig(Config& q);
55 bool GetCommandedVelocity(Config& dq);
56 bool GetSensedConfig(Config& q);
57 bool GetSensedVelocity(Config& dq);
70 shared_ptr<RobotController> MakeDefaultController(
RobotModel* robot);
83 static void RegisterDefault(
RobotModel& robot);
86 static shared_ptr<RobotController> CreateByName(
const char* name);
87 static shared_ptr<RobotController> CreateByName(
const char* name,
RobotModel& robot);
88 static shared_ptr<RobotController> Load(
const char* fn,
RobotModel& robot);
90 static shared_ptr<RobotController> Load(TiXmlElement* in,
RobotModel& robot);
93 static std::map<std::string,shared_ptr<RobotController> > controllers;
97 #define FILL_CONTROLLER_SETTING(res,membername) \ 101 res[#membername] = ss.str(); \ 103 #define READ_CONTROLLER_SETTING(membername) \ 104 if(name == #membername) { \ 110 #define WRITE_CONTROLLER_SETTING(membername) \ 111 if(name == #membername) { \ 112 stringstream ss(str); \ A set of sensors for the robot.
Definition: Sensor.h:111
A class to simplify the loading of different controllers at run time.
Definition: Controller.h:80
RobotSensors * sensors
sensor input (filled in by simulator)
Definition: Controller.h:63
RobotMotorCommand * command
motor command output (output to simulator)
Definition: Controller.h:64
A collection of basic motor types.
Definition: Command.h:45
A base class for a robot controller. The base class does nothing.
Definition: Controller.h:29
The main robot type used in RobotSim.
Definition: Robot.h:83
Real nominalTimeStep
a "desired" time step, by default 0, which acts as a hint to the simulator. Note that it doesn't have...
Definition: Controller.h:61
Definition: ContactDistance.h:6