28 #include <selforg/types.h>
29 #include <selforg/stl_adds.h>
30 #include <selforg/matrix.h>
68 virtual std::list<sensor>
getList()
const = 0;
89 virtual int get(
sensor* sensors,
int length)
const {
90 const std::list<sensor>& l =
getList();
91 assert(length>=(
int)l.size());
103 std::list<sensor> result(s,s+num);
111 for(
int i=0; i<3; i++){
119 for(
int i=0; i<3; i++){
120 if(( 1 << i) & dimensions)
129 for(
unsigned int i=0; i<strlen(str); i++){
132 case 'x': val|=
X;
break;
134 case 'y': val|=
Y;
break;
136 case 'z': val|=
Z;
break;
140 fprintf(stderr,
"parseSensorDimension:Sensor must have at least one dimension");
149 if((dimensions &
X) != 0) s+=
"X";
150 if((dimensions &
Y) != 0) s+=
"Y";
151 if((dimensions &
Z) != 0) s+=
"Z";
Matrix type.
Definition: matrix.h:65
static Dimensions parseSensorDimension(char *str)
Definition: sensor.h:127
std::list< D > convertToList() const
Definition: matrix.cpp:169
virtual int getSensorNumber() const =0
returns the number of sensors values produced by this sensor
Matrix row(I index) const
Definition: matrix.cpp:110
#define FOREACHC(colltype, coll, it)
Definition: stl_adds.h:21
virtual std::list< SensorMotorInfo > getSensorInfos() const
returns a list of sensor infos (
Definition: sensor.h:72
double sensor
Definition: types.h:29
virtual void init(Primitive *own, Joint *joint=0)=0
initialises sensor with a body of robot and optionally with a joint.
virtual void update()
to update any visual appearance
Definition: sensor.h:79
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
int convertToBuffer(D *buffer, I len) const
stores the content of the matrix (row-wise) in the given buffer
Definition: matrix.cpp:160
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
Data structure holding all essential global information.
Definition: globaldata.h:57
virtual std::list< sensor > getList() const =0
returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded...
virtual bool sense(const GlobalData &globaldata)=0
performs sense action
static std::list< sensor > selectrows(const matrix::Matrix &m, short dimensions)
selects the rows specified by dimensions (X->0, Y->1, Z->2)
Definition: sensor.h:109
static int selectrows(sensor *sensors, int length, const matrix::Matrix &m, short dimensions)
selects the rows specified by dimensions (X->0, Y->1, Z->2)
Definition: sensor.h:117
Abstract class for giving names to sensors and motors.
Definition: sensormotorinfoable.h:37
Sensor()
Definition: sensor.h:48
std::list< SensorMotorInfo > getInfos(int number) const
get all infos.
Definition: sensormotorinfoable.h:81
Dimensions
defines which dimensions should be sensed. The meaning is sensor specific.
Definition: sensor.h:46
std::list< sensor > getListOfArray() const
helper function for performance implementation of list<> get() based on array-get ...
Definition: sensor.h:99
static std::string dimensions2String(short dimensions)
Definition: sensor.h:147
virtual ~Sensor()
Definition: sensor.h:49