Go to the documentation of this file.
6 #ifndef CNOID_BODY_DEVICE_H
7 #define CNOID_BODY_DEVICE_H
9 #include <cnoid/ClonableReferenced>
10 #include <cnoid/EigenTypes>
11 #include <cnoid/Signal>
13 #include "exportdecl.h"
29 virtual const char* typeName()
const = 0;
30 virtual void copyStateFrom(
const DeviceState& other) = 0;
36 virtual int stateSize()
const = 0;
42 virtual const double* readState(
const double* buf) = 0;
48 virtual double* writeState(
double* out_buf)
const = 0;
56 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
62 const Isometry3& const_T_local()
const {
return T_local; }
63 Signal<void()> sigStateChanged;
64 Signal<void(
double time)> sigTimeChanged;
72 void copySpecFrom(
const Device* other);
78 return static_cast<Device*
>(doClone(
nullptr));
81 return static_cast<Device*
>(doClone(&cloneMap));
84 virtual bool copyFrom(
const Device* other);
86 void setIndex(
int index) { ns->index = index; }
87 void setId(
int id) { ns->id = id; }
88 void setName(
const std::string& name) { ns->name = name; }
91 virtual void forEachActualType(std::function<
bool(
const std::type_info& type)> func);
95 int index()
const {
return ns->index; }
96 int id()
const {
return ns->id; }
97 const std::string&
name()
const {
return ns->name; }
102 const Body* body()
const;
108 template<
class Scalar,
int Mode,
int Options>
110 ns->T_local = T.template cast<Isometry3::Scalar>();
113 Isometry3::ConstLinearPart
R_local()
const {
return ns->const_T_local().linear(); }
114 Isometry3::LinearPart
R_local() {
return ns->T_local.linear(); }
115 Isometry3::ConstLinearPart
localRotation()
const {
return ns->const_T_local().linear(); }
116 template<
typename Derived>
119 Isometry3::ConstTranslationPart
p_local()
const {
return ns->const_T_local().translation(); }
120 Isometry3::TranslationPart
p_local() {
return ns->T_local.translation(); }
121 Isometry3::ConstTranslationPart
localTranslation()
const {
return ns->const_T_local().translation(); }
122 template<
typename Derived>
125 virtual void clearState();
127 virtual bool on()
const;
128 virtual void on(
bool on);
131 return ns->sigStateChanged;
135 ns->sigStateChanged();
139 return ns->sigTimeChanged;
143 ns->sigTimeChanged(time);
146 [[deprecated(
"Please use T_local() instead")]]
149 void setLocalAttitude(
const Isometry3& Ta);
151 double cycle()
const {
return 20.0; }
Isometry3::ConstLinearPart R_local() const
Definition: Device.h:113
bool hasStateOnly() const
Definition: Device.h:93
void setLink(Link *link)
Definition: Device.h:89
void setLocalPosition(const Eigen::Transform< Scalar, 3, Mode, Options > &T)
Definition: Device.h:109
const Isometry3 & T_local() const
Definition: Device.h:106
int index() const
Definition: Device.h:95
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
virtual ~DeviceState()
Definition: Device.h:27
Isometry3::ConstTranslationPart localTranslation() const
Definition: Device.h:121
void setLocalRotation(const Eigen::MatrixBase< Derived > &R)
Definition: Device.h:117
Device * clone() const
Definition: Device.h:77
Isometry3::ConstLinearPart localRotation() const
Definition: Device.h:115
void notifyTimeChange(double time)
Definition: Device.h:142
void setName(const std::string &name)
Definition: Device.h:88
ref_ptr< DeviceState > DeviceStatePtr
Definition: Device.h:50
void setId(int id)
Definition: Device.h:87
void setIndex(int index)
Definition: Device.h:86
Isometry3::ConstTranslationPart p_local() const
Definition: Device.h:119
Isometry3::LinearPart R_local()
Definition: Device.h:114
Definition: AbstractSceneLoader.h:11
Definition: ClonableReferenced.h:10
Definition: CloneMap.h:13
const std::string & name() const
Definition: Device.h:97
Device * clone(CloneMap &cloneMap) const
Definition: Device.h:80
Link * link()
Definition: Device.h:100
const Isometry3 & localPosition() const
Definition: Device.h:107
SignalProxy< void(double time)> sigTimeChanged()
Definition: Device.h:138
double cycle() const
Definition: Device.h:151
int id() const
Definition: Device.h:96
DeviceState(const DeviceState &)
Definition: Device.h:24
DeviceState()
Definition: Device.h:23
void setCycle(double msec)
Definition: Device.h:153
void notifyStateChange()
Definition: Device.h:134
SignalProxy< void()> sigStateChanged()
Definition: Device.h:130
Isometry3 & T_local()
Definition: Device.h:105
Isometry3::TranslationPart p_local()
Definition: Device.h:120
void setLocalTranslation(const Eigen::MatrixBase< Derived > &p)
Definition: Device.h:123
ref_ptr< Device > DevicePtr
Definition: Device.h:156
const Isometry3 & T_local_org() const
Definition: Device.h:147
const Link * link() const
Definition: Device.h:99