Cheetah Software  1.0
ControlParameters.h File Reference

Interface to set gains/control parameters for simulator and robot These are designed to be updated infrequently. For high frequency data, consider using Driver Inputs or adding to the Robot Debug Data instead. More...

#include <map>
#include <mutex>
#include <string>
#include "Utilities/utilities.h"
#include "cTypes.h"
+ Include dependency graph for ControlParameters.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  ControlParameterValuePtr
 
union  ControlParameterValue
 
class  ControlParameterCollection
 
class  ControlParameter
 
class  ControlParameters
 

Macros

#define CONTROL_PARAMETER_MAXIMUM_NAME_LENGTH   64
 
#define INIT_PARAMETER(name)   param_##name(#name, name, collection)
 
#define DECLARE_PARAMETER(type, name)
 

Enumerations

enum  ControlParameterValueKind : u64 {
  ControlParameterValueKind::FLOAT = 0, ControlParameterValueKind::DOUBLE = 1, ControlParameterValueKind::S64 = 2, ControlParameterValueKind::VEC3_DOUBLE = 3,
  ControlParameterValueKind::VEC3_FLOAT = 4
}
 

Functions

ControlParameterValueKind getControlParameterValueKindFromString (const std::string &str)
 
std::string controlParameterValueKindToString (ControlParameterValueKind valueKind)
 
std::string controlParameterValueToString (ControlParameterValue v, ControlParameterValueKind kind)
 

Detailed Description

Interface to set gains/control parameters for simulator and robot These are designed to be updated infrequently. For high frequency data, consider using Driver Inputs or adding to the Robot Debug Data instead.

ControlParameter: a single value, either a double, float, or s64. Each control parameter must have a unique name Control parameters know their type as well as if they've been initialized or not ControlParameters must be initialized, either from reading from a file, reading from LCM, or some other way (TODO consider supporting Vec3's?) All control parameters must go in a ControlParameters (for now, just robot settings and sim settings)

TODO - what should happen when this fails?

See test_ControlParameters for an example of how this works

Definition in file ControlParameters.h.

Macro Definition Documentation

#define CONTROL_PARAMETER_MAXIMUM_NAME_LENGTH   64

Definition at line 27 of file ControlParameters.h.

#define DECLARE_PARAMETER (   type,
  name 
)
Value:
type name; \
ControlParameter param_##name;

Definition at line 30 of file ControlParameters.h.

#define INIT_PARAMETER (   name)    param_##name(#name, name, collection)

Definition at line 29 of file ControlParameters.h.

Enumeration Type Documentation

Enumerator
FLOAT 
DOUBLE 
S64 
VEC3_DOUBLE 
VEC3_FLOAT 

Definition at line 34 of file ControlParameters.h.

Function Documentation

std::string controlParameterValueKindToString ( ControlParameterValueKind  valueKind)

Definition at line 16 of file ControlParameters.cpp.

References DOUBLE, FLOAT, S64, VEC3_DOUBLE, and VEC3_FLOAT.

17  {
18  switch (valueKind) {
20  return "s64";
22  return "double";
24  return "float";
26  return "vec3d";
28  return "vec3f";
29  default:
30  return "unknown-ControlParameterValueKind";
31  }
32 }

+ Here is the caller graph for this function:

std::string controlParameterValueToString ( ControlParameterValue  v,
ControlParameterValueKind  kind 
)

Definition at line 34 of file ControlParameters.cpp.

References ControlParameterValue::d, DOUBLE, ControlParameterValue::f, FLOAT, ControlParameterValue::i, numberToString(), S64, VEC3_DOUBLE, VEC3_FLOAT, ControlParameterValue::vec3d, and ControlParameterValue::vec3f.

35  {
36  std::string result;
37  switch (kind) {
39  result += numberToString(value.d);
40  break;
42  result += numberToString(value.f);
43  break;
45  result += std::to_string(value.i);
46  break;
48  result += "[";
49  result += numberToString(value.vec3f[0]) + ", ";
50  result += numberToString(value.vec3f[1]) + ", ";
51  result += numberToString(value.vec3f[2]) + "]";
52  break;
54  result += "[";
55  result += numberToString(value.vec3d[0]) + ", ";
56  result += numberToString(value.vec3d[1]) + ", ";
57  result += numberToString(value.vec3d[2]) + "]";
58  break;
59  default:
60  result += "<unknown type " + std::to_string((u32)(kind)) +
61  "> (add it yourself in ControlParameterInterface.h!)";
62  break;
63  }
64  return result;
65 }
std::string numberToString(T number)
Definition: utilities.h:130
uint32_t u32
Definition: cTypes.h:18

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ControlParameterValueKind getControlParameterValueKindFromString ( const std::string &  str)

Definition at line 257 of file ControlParameters.cpp.

References DOUBLE, FLOAT, S64, VEC3_DOUBLE, and VEC3_FLOAT.

257  {
258  if(str.find('[') != std::string::npos) {
259  // vec type
260  if(str.find('f') != std::string::npos) {
262  } else {
264  }
265  } else {
266  // scalar type
267  if(str.find('.') != std::string::npos) {
268  if(str.find('f') != std::string::npos) {
270  } else {
272  }
273  } else {
274  // integer
276  }
277  }
278 }

+ Here is the caller graph for this function: