Choreonoid  1.8
RangeSensor.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_RANGE_SENSOR_H
7 #define CNOID_BODY_RANGE_SENSOR_H
8 
9 #include "Device.h"
10 #include <vector>
11 #include <memory>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16 class Mapping;
17 
18 class CNOID_EXPORT RangeSensor : public Device
19 {
20 public:
21  RangeSensor();
22  RangeSensor(const RangeSensor& org, bool copyStateOnly = false);
23 
24  virtual const char* typeName() const override;
25  void copyStateFrom(const RangeSensor& other);
26  virtual void copyStateFrom(const DeviceState& other) override;
27  virtual DeviceState* cloneState() const override;
28  virtual void forEachActualType(std::function<bool(const std::type_info& type)> func) override;
29  virtual void clearState() override;
30  virtual bool on() const override;
31  virtual void on(bool on) override;
32 
33  double yawRange() const { return yawRange_; }
34  void setYawRange(double theta) { yawRange_ = theta; }
35  double yawStep() const { return yawStep_; }
36  void setYawStep(double s) { yawStep_ = s; }
37  int numYawSamples() const;
38 
39  double pitchRange() const { return pitchRange_; }
40  void setPitchRange(double theta) { pitchRange_ = theta; }
41  double pitchStep() const { return pitchStep_; }
42  void setPitchStep(double s) { pitchStep_ = s; }
43  int numPitchSamples() const;
44 
45  double maxDistance() const { return maxDistance_; }
46  void setMaxDistance(double d) { maxDistance_ = d; }
47  double minDistance() const { return minDistance_; }
48  void setMinDistance(double d) { minDistance_ = d; }
49 
50  double scanRate() const { return scanRate_; }
51  void setScanRate(double r) { scanRate_ = r; }
52 
53  double frameRate() const { return scanRate_; }
54  void setFrameRate(double r) { scanRate_ = r; }
55 
56  typedef std::vector<double> RangeData;
57 
58  void setRangeDataStateClonable(bool on) { isRangeDataStateClonable_ = on; }
59  bool isRangeDataStateClonable() const { return isRangeDataStateClonable_; }
60 
64  const RangeData& rangeData() const { return *rangeData_; }
65  const RangeData& constRangeData() const { return *rangeData_; }
66  RangeData& rangeData();
67  RangeData& newRangeData();
68 
69  std::shared_ptr<RangeData> sharedRangeData() const { return rangeData_; }
70 
76  void setRangeData(std::shared_ptr<RangeData>& rangeData);
77 
78  void clearRangeData();
79 
83  double delay() const { return delay_; }
84  void setDelay(double time) { delay_ = time; }
85 
86  virtual int stateSize() const override;
87  virtual const double* readState(const double* buf) override;
88  virtual double* writeState(double* out_buf) const override;
89 
90  bool readSpecifications(const Mapping* info);
91  bool writeSpecifications(Mapping* info) const;
92 
93 protected:
94  virtual Referenced* doClone(CloneMap* cloneMap) const override;
95 
96 private:
97  bool on_;
98  bool isRangeDataStateClonable_; // Non state variable
99  double yawRange_;
100  double yawStep_;
101  double pitchRange_;
102  double pitchStep_;
103  double minDistance_;
104  double maxDistance_;
105  double scanRate_;
106  double delay_;
107  std::shared_ptr<RangeData> rangeData_;
108 
109  void copyRangeSensorStateFrom(const RangeSensor& other);
110 };
111 
113 
114 }
115 
116 #endif
cnoid::RangeSensor::scanRate
double scanRate() const
Definition: RangeSensor.h:50
cnoid::RangeSensor::setRangeDataStateClonable
void setRangeDataStateClonable(bool on)
Definition: RangeSensor.h:58
cnoid::RangeSensor::constRangeData
const RangeData & constRangeData() const
Definition: RangeSensor.h:65
cnoid::Mapping
Definition: ValueTree.h:253
Device.h
cnoid::RangeSensor::pitchRange
double pitchRange() const
Definition: RangeSensor.h:39
cnoid::RangeSensor::minDistance
double minDistance() const
Definition: RangeSensor.h:47
cnoid::RangeSensor::sharedRangeData
std::shared_ptr< RangeData > sharedRangeData() const
Definition: RangeSensor.h:69
cnoid::RangeSensor::setYawRange
void setYawRange(double theta)
Definition: RangeSensor.h:34
cnoid::RangeSensor::pitchStep
double pitchStep() const
Definition: RangeSensor.h:41
cnoid::RangeSensor::setFrameRate
void setFrameRate(double r)
Definition: RangeSensor.h:54
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid::RangeSensor::delay
double delay() const
Definition: RangeSensor.h:83
cnoid::RangeSensor::setYawStep
void setYawStep(double s)
Definition: RangeSensor.h:36
cnoid::RangeSensor::setMinDistance
void setMinDistance(double d)
Definition: RangeSensor.h:48
cnoid::RangeSensor::yawRange
double yawRange() const
Definition: RangeSensor.h:33
cnoid::RangeSensor::setPitchRange
void setPitchRange(double theta)
Definition: RangeSensor.h:40
cnoid::RangeSensor::setMaxDistance
void setMaxDistance(double d)
Definition: RangeSensor.h:46
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::DeviceState
Definition: Device.h:20
cnoid::RangeSensor::setDelay
void setDelay(double time)
Definition: RangeSensor.h:84
cnoid::RangeSensor::RangeData
std::vector< double > RangeData
Definition: RangeSensor.h:56
cnoid::RangeSensor::frameRate
double frameRate() const
Definition: RangeSensor.h:53
cnoid::Referenced
Definition: Referenced.h:54
cnoid::RangeSensorPtr
ref_ptr< RangeSensor > RangeSensorPtr
Definition: RangeSensor.h:112
cnoid::RangeSensor::setPitchStep
void setPitchStep(double s)
Definition: RangeSensor.h:42
cnoid::Device
Definition: Device.h:53
cnoid::RangeSensor::setScanRate
void setScanRate(double r)
Definition: RangeSensor.h:51
cnoid::RangeSensor
Definition: RangeSensor.h:18
cnoid::RangeSensor::yawStep
double yawStep() const
Definition: RangeSensor.h:35
cnoid::RangeSensor::maxDistance
double maxDistance() const
Definition: RangeSensor.h:45
cnoid::RangeSensor::isRangeDataStateClonable
bool isRangeDataStateClonable() const
Definition: RangeSensor.h:59
cnoid::RangeSensor::rangeData
const RangeData & rangeData() const
Definition: RangeSensor.h:64