|
| 1 | +/********************************************************************* |
| 2 | +* Software License Agreement (BSD License) |
| 3 | +* |
| 4 | +* Copyright (c) 2016, CITEC, Bielefeld University |
| 5 | +* All rights reserved. |
| 6 | +* |
| 7 | +* Redistribution and use in source and binary forms, with or without |
| 8 | +* modification, are permitted provided that the following conditions |
| 9 | +* are met: |
| 10 | +* |
| 11 | +* * Redistributions of source code must retain the above copyright |
| 12 | +* notice, this list of conditions and the following disclaimer. |
| 13 | +* * Redistributions in binary form must reproduce the above |
| 14 | +* copyright notice, this list of conditions and the following |
| 15 | +* disclaimer in the documentation and/or other materials provided |
| 16 | +* with the distribution. |
| 17 | +* * Neither the name of the copyright holder nor the names of its |
| 18 | +* contributors may be used to endorse or promote products derived |
| 19 | +* from this software without specific prior written permission. |
| 20 | +* |
| 21 | +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 | +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 23 | +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 24 | +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 25 | +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 26 | +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 27 | +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 28 | +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 29 | +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 | +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 31 | +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 32 | +* POSSIBILITY OF SUCH DAMAGE. |
| 33 | +*********************************************************************/ |
| 34 | + |
| 35 | +/* Author: Guillaume Walck */ |
| 36 | + |
| 37 | +#ifndef URDF_SENSOR_TACTILE_H |
| 38 | +#define URDF_SENSOR_TACTILE_H |
| 39 | + |
| 40 | +#include "urdf_model/pose.h" |
| 41 | +#include "urdf_model/link.h" |
| 42 | +#include <string> |
| 43 | +#include <vector> |
| 44 | + |
| 45 | +namespace urdf { |
| 46 | + |
| 47 | +template <typename T> |
| 48 | +class Vector2 |
| 49 | +{ |
| 50 | +public: |
| 51 | + Vector2(T _x, T _y) {this->x=_x; this->y=_y;} |
| 52 | + Vector2() {this->clear();} |
| 53 | + T x; |
| 54 | + T y; |
| 55 | + |
| 56 | + void clear() {this->x = this->y = 0;} |
| 57 | + |
| 58 | + Vector2<T> operator+(const Vector2<T> &vec) |
| 59 | + { |
| 60 | + return Vector2(this->x+vec.x, this->y+vec.y); |
| 61 | + } |
| 62 | +}; |
| 63 | + |
| 64 | + |
| 65 | +/** A taxel describes the location (origin), geometry, |
| 66 | + and vector index in the TactileState message. |
| 67 | +*/ |
| 68 | +class TactileTaxel |
| 69 | +{ |
| 70 | +public: |
| 71 | + TactileTaxel() { this->clear(); } |
| 72 | + |
| 73 | + unsigned int idx; /// index into TactileState |
| 74 | + Pose origin; /// location of taxel w.r.t. sensor frame |
| 75 | + GeometrySharedPtr geometry; /// geometry of taxel |
| 76 | + |
| 77 | + void clear() |
| 78 | + { |
| 79 | + this->idx = 0; |
| 80 | + this->origin.clear(); |
| 81 | + this->geometry.reset(); |
| 82 | + } |
| 83 | +}; |
| 84 | + |
| 85 | +/** A tactile array is a rectangular layout of taxels of size row x col. |
| 86 | + The order specifies the ordering of taxels in the TactileState msg. |
| 87 | +*/ |
| 88 | +class TactileArray |
| 89 | +{ |
| 90 | +public: |
| 91 | + TactileArray() { this->clear(); } |
| 92 | + |
| 93 | + enum DataOrder {ROWMAJOR, COLUMNMAJOR}; |
| 94 | + |
| 95 | + unsigned int rows; |
| 96 | + unsigned int cols; |
| 97 | + DataOrder order; |
| 98 | + Vector2<double> size; |
| 99 | + Vector2<double> spacing; |
| 100 | + Vector2<double> offset; |
| 101 | + |
| 102 | + void clear() |
| 103 | + { |
| 104 | + this->rows = 0; |
| 105 | + this->cols = 0; |
| 106 | + this->order = ROWMAJOR; |
| 107 | + this->size.clear(); |
| 108 | + this->spacing.clear(); |
| 109 | + this->offset.clear(); |
| 110 | + } |
| 111 | +}; |
| 112 | + |
| 113 | +typedef boost::shared_ptr<TactileTaxel> TactileTaxelSharedPtr; |
| 114 | +typedef boost::shared_ptr<TactileArray> TactileArraySharedPtr; |
| 115 | + |
| 116 | +class TactileSensor: public SensorBase |
| 117 | +{ |
| 118 | +public: |
| 119 | + TactileSensor() { this->clear(); } |
| 120 | + std::vector<TactileTaxelSharedPtr> taxels_; |
| 121 | + TactileArraySharedPtr array_; |
| 122 | + |
| 123 | + void clear() |
| 124 | + { |
| 125 | + taxels_.clear(); |
| 126 | + array_.reset(); |
| 127 | + } |
| 128 | +}; |
| 129 | + |
| 130 | +} |
| 131 | + |
| 132 | +#endif |
0 commit comments