Go to the documentation of this file.
6 #ifndef CNOID_BODY_EXTRA_BODY_STATE_ACCESSOR_H
7 #define CNOID_BODY_EXTRA_BODY_STATE_ACCESSOR_H
9 #include <cnoid/Referenced>
10 #include <cnoid/Array2D>
11 #include <cnoid/EigenTypes>
12 #include <cnoid/Signal>
13 #include <cnoid/stdx/variant>
15 #include "exportdecl.h"
21 static int elementSizes[];
22 Signal<void()> sigStateChanged_;
29 Angle(
double rad) : angle(rad) { }
30 double value()
const {
return angle; }
39 STRONG_WARNING = WARNING | 1 << 1
42 enum { BOOL, INT, DOUBLE, ANGLE, STRING, VECTOR3,
VECTORX, NONE };
49 stdx::variant<bool, int, double, Angle, std::string, Vector3f, VectorX, None> value;
54 template<
typename T>
Value&
operator=(
const T& rhs) { value = rhs;
return *
this; }
55 bool getBool()
const {
return stdx::get<bool>(value); }
56 int getInt()
const {
return stdx::get<int>(value); }
57 double getDouble()
const {
return stdx::get<double>(value); }
58 double getAngle()
const {
return stdx::get<Angle>(value).value(); }
60 const std::string&
getString()
const {
return stdx::get<std::string>(value); }
61 const Vector3f&
getVector3f()
const {
return stdx::get<Vector3f>(value); }
65 int which()
const {
return stdx::get_variant_index(value); }
75 int n = elementSizes[v.
which()];
82 virtual int getNumStateItems()
const = 0;
83 virtual int getNumJointStateItems()
const = 0;
84 virtual const char* getStateItemName(
int stateIndex)
const = 0;
86 virtual const char* getStateItemLabel(
int stateIndex)
const = 0;
87 virtual const char* getJointStateItemName(
int jointStateIndex)
const = 0;
89 virtual const char* getJointStateItemLabel(
int jointStateIndex)
const = 0;
91 virtual void getState(std::vector<Value>& out_state)
const = 0;
98 virtual bool setState(
const std::vector<Value>& state)
const;
103 virtual void getJointState(
Array2D<Value>& out_jointState)
const = 0;
110 virtual bool setJointState(
const Array2D<Value>& jointState)
const;
116 template<>
inline ExtraBodyStateAccessor::Value&
const std::string & getString() const
Definition: ExtraBodyStateAccessor.h:60
Angle(double rad)
Definition: ExtraBodyStateAccessor.h:29
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
Vector3 getVector3() const
Definition: ExtraBodyStateAccessor.h:62
const VectorX & getVectorX() const
Definition: ExtraBodyStateAccessor.h:63
bool getBool() const
Definition: ExtraBodyStateAccessor.h:55
double value() const
Definition: ExtraBodyStateAccessor.h:30
Definition: ExtraBodyStateAccessor.h:19
void setAngle(double rad)
Definition: ExtraBodyStateAccessor.h:59
double getDouble() const
Definition: ExtraBodyStateAccessor.h:57
void setAttribute(int attribute)
Definition: ExtraBodyStateAccessor.h:66
int getInt() const
Definition: ExtraBodyStateAccessor.h:56
Definition: Referenced.h:103
void notifyStateChange()
Definition: ExtraBodyStateAccessor.h:113
int attribute() const
Definition: ExtraBodyStateAccessor.h:67
@ VECTORX
Definition: ExtraBodyStateAccessor.h:42
Definition: ExtraBodyStateAccessor.h:44
Definition: AbstractSceneLoader.h:11
Attribute
Definition: ExtraBodyStateAccessor.h:36
Definition: ExtraBodyStateAccessor.h:34
Value()
Definition: ExtraBodyStateAccessor.h:52
Definition: ExtraBodyStateAccessor.h:26
Value & operator=(const Value &rhs)
Definition: ExtraBodyStateAccessor.h:53
Definition: Referenced.h:54
const Vector3f & getVector3f() const
Definition: ExtraBodyStateAccessor.h:61
int which() const
Definition: ExtraBodyStateAccessor.h:65
static int getNumValueElements(const Value &v)
Definition: ExtraBodyStateAccessor.h:74
double getAngle() const
Definition: ExtraBodyStateAccessor.h:58
ref_ptr< ExtraBodyStateAccessor > ExtraBodyStateAccessorPtr
Definition: ExtraBodyStateAccessor.h:119
SignalProxy< void()> sigStateChanged()
Definition: ExtraBodyStateAccessor.h:112
Value & operator=(const T &rhs)
Definition: ExtraBodyStateAccessor.h:54
Eigen::VectorXd VectorX
Definition: EigenTypes.h:60