Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 732) +++ CMakeLists.txt (working copy) @@ -17,6 +17,7 @@ rci/dto/JointValues.h rci/dto/JointAngles.h rci/dto/JointVelocities.h + rci/dto/JointAccelerations.h rci/dto/JointTorques.h rci/dto/JointImpedance.h rci/dto/Power.h @@ -52,6 +53,7 @@ rci/dto/JointValues.cpp rci/dto/JointAngles.cpp rci/dto/JointVelocities.cpp + rci/dto/JointAccelerations.cpp rci/dto/JointTorques.cpp rci/dto/JointImpedance.cpp rci/dto/Power.cpp Index: rci/dto/JointAccelerations.cpp =================================================================== --- rci/dto/JointAccelerations.cpp (revision 0) +++ rci/dto/JointAccelerations.cpp (working copy) @@ -0,0 +1,106 @@ +/* ============================================================ + * + * This file is a part of RCI project + * + * Copyright (C) 2015 by Niels Dehio + * + * This file may be licensed under the terms of the + * GNU Lesser General Public License Version 3 (the ``LGPL''), + * or (at your option) any later version. + * + * Software distributed under the License is distributed + * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the LGPL for the specific language + * governing rights and limitations. + * + * You should have received a copy of the LGPL along with this + * program. If not, go to http://www.gnu.org/licenses/lgpl.html + * or write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The development of this software was supported by: + * CoR-Lab, Research Institute for Cognition and Robotics + * Bielefeld University + * + * ============================================================ */ + +#include "JointAccelerations.h" + +using namespace std; +using namespace nemo; +using namespace cca; + +namespace rci { + +JointAccelerations::JointAccelerations() : + JointValues() { +} + +JointAccelerations::JointAccelerations(RealVector values) : + JointValues(values) { +} + +JointAccelerations::JointAccelerations(double value) : + JointValues(value) { +} + +std::string JointAccelerations::print() const { + ostringstream outstream(ostringstream::out); + outstream.precision(3); // Precision when printing double values + outstream << "JointAccelerations<"; + for (unsigned int i = 0; i < this->getDimension(); ++i) { + if (i > 0) { + outstream << ","; + } + outstream << this->asDouble(i); + } + outstream << ">(rad/s^2)" << std::endl; + return outstream.str(); +} + +JointAccelerationsPtr JointAccelerations::fromValue(double value) { + return JointAccelerationsPtr(new JointAccelerations(value)); +} + +JointAccelerationsPtr JointAccelerations::fromValues(RealVector values) { + return JointAccelerationsPtr(new JointAccelerations(values)); +} + +JointAccelerationsPtr JointAccelerations::fromRad_ss(double value) { + return JointAccelerations::fromValue(value); // rad/s^2 is default representation +} + +JointAccelerationsPtr JointAccelerations::fromRad_ss(RealVector values) { + return JointAccelerations::fromValues(values); // rad/s^2 is default representation +} + +nemo::RealVector JointAccelerations::rad_ssVector() { + return this->asDoubleVector(); +} + +double JointAccelerations::rad_ss(unsigned int index) { + return this->asDouble(index); +} + +JointAccelerationsPtr JointAccelerations::fromDeg_ss(double value) { + return JointAccelerations::fromRad_ss(value / 180 * M_PI); +} + +JointAccelerationsPtr JointAccelerations::fromDeg_ss(RealVector values) { + Mapping degToRad = DegToRad::create(); + values.transform(degToRad); + + return JointAccelerations::fromRad_ss(values); +} + +nemo::RealVector JointAccelerations::deg_ssVector() { + Mapping radToDeg = RadToDeg::create(); + + return this->_values.map(radToDeg); +} + +double JointAccelerations::deg_ss(unsigned int index) { + return this->rad_ss(index) / M_PI * 180; +} + +} Index: rci/dto/JointAccelerations.h =================================================================== --- rci/dto/JointAccelerations.h (revision 0) +++ rci/dto/JointAccelerations.h (working copy) @@ -0,0 +1,159 @@ +/* ============================================================ + * + * This file is a part of RCI project + * + * Copyright (C) 2015 by Niels Dehio + * + * This file may be licensed under the terms of the + * GNU Lesser General Public License Version 3 (the ``LGPL''), + * or (at your option) any later version. + * + * Software distributed under the License is distributed + * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the LGPL for the specific language + * governing rights and limitations. + * + * You should have received a copy of the LGPL along with this + * program. If not, go to http://www.gnu.org/licenses/lgpl.html + * or write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The development of this software was supported by: + * CoR-Lab, Research Institute for Cognition and Robotics + * Bielefeld University + * + * ============================================================ */ + +#pragma once + +#include +#include +#include +#include + +#include "rci/dto/JointValues.h" + +namespace rci { + +class JointAccelerations; +typedef boost::shared_ptr JointAccelerationsPtr; + +/** + * Domain object, representing Joint Accelerations. + * Default representation is in radian per second (\f$\frac{rad}{s*s}\f$), + * according to the International System of Units (SI). + * @ingroup DTO + */ +class JointAccelerations: public JointValues { + +public: + JointAccelerations(); + JointAccelerations(nemo::RealVector values); + JointAccelerations(double value); + + /** + * Creates one-dimensional JointAccelerationsPtr from a single double value. + * You should not use this method, unless you exactly know what you are + * doing. Try to rather use a more specific method. + * + * @param value + * Initial value. + * + * @return One-dimensional JointAccelerationsPtr + */ + static JointAccelerationsPtr fromValue(double value); + + /** + * Creates a JointAccelerationsPtr from a vector of double values. + * You should not use this method, unless you exactly know what you are + * doing. Try to rather use a more specific method. + * + * @param values + * Initial acceleration values. + * + * @return JointAccelerationsPtr of the size of the given double vector. + */ + static JointAccelerationsPtr fromValues(nemo::RealVector values); + + /** + * Creates a one-dimensional JointAccelerationsPtr from a single \f$\frac{rad}{s*s}\f value. + * + * @param values + * Initial acceleration value in \f$\frac{rad}{s*s}\f$ + * + * @return One-dimensional JointAccelerationsPtr + */ + static JointAccelerationsPtr fromRad_ss(double value); + + /** + * Creates a JointAccelerationsPtr from a vector of \f$\frac{rad}{s*s}\f values. + * + * @param values + * Initial acceleration values in \f$\frac{rad}{s*s}\f$ + * + * @return JointAccelerationsPtr of the size of the given vector. + */ + static JointAccelerationsPtr fromRad_ss(nemo::RealVector values); + + /** + * Get all acceleration values as double vector (in \f$\frac{rad}{s*s}\f$). + * + * @return Double vector (in \f$\frac{rad}{s*s}\f$) + */ + virtual nemo::RealVector rad_ssVector(); + + /** + * Get single acceleration value in \f$\frac{rad}{s*s}\f. + * + * @param index + * Index of acceleration value + * + * @return Single acceleration value in \f$\frac{rad}{s*s}\f$ + */ + virtual double rad_ss(unsigned int index); + + /** + * Creates a one-dimensional JointAccelerationsPtr from a single + * \f$\frac{deg}{s*s}\f$ value. + * + * @param values + * Initial acceleration value in \f$\frac{deg}{s*s}\f$. + * + * @return One-dimensional JointAccelerationsPtr + */ + static JointAccelerationsPtr fromDeg_ss(double value); + + /** + * Creates a JointAccelerationsPtr from a vector of \f$\frac{rad}{s*s}\f$ values. + * + * @param values + * Initial acceleration values in \f$\frac{rad}{s*s}\f$. + * + * @return JointAccelerationsPtr of the size of the given vector. + */ + static JointAccelerationsPtr fromDeg_ss(nemo::RealVector values); + + /** + * Get all acceleration values as double vector (in \f$\frac{rad}{s*s}\f$). + * + * @return Double vector (in \f$\frac{rad}{s*s}\f$) + */ + virtual nemo::RealVector deg_ssVector(); + + /** + * Get single acceleration value in \f$\frac{rad}{s*s}\f$. + * + * @param index + * Index of acceleration value + * + * @return Single acceleration value in \f$\frac{rad}{s*s}\f$ + */ + + virtual double deg_ss(unsigned int index); + /** + * Print function + */ + virtual std::string print() const; +}; + +}