diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3054081e8..1717b152bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,8 +126,7 @@ jobs: -DENABLE_icubmod_embObjIMU:BOOL=ON -DENABLE_icubmod_embObjInertials:BOOL=ON \ -DENABLE_icubmod_embObjMais:BOOL=ON -DENABLE_icubmod_embObjMotionControl:BOOL=ON \ -DENABLE_icubmod_embObjSkin:BOOL=ON -DENABLE_icubmod_embObjStrain:BOOL=ON \ - -DENABLE_icubmod_embObjVirtualAnalogSensor:BOOL=ON -DENABLE_icubmod_parametricCalibrator:BOOL=ON \ - -DENABLE_icubmod_parametricCalibratorEth:BOOL=ON \ + -DENABLE_icubmod_parametricCalibrator:BOOL=ON -DENABLE_icubmod_parametricCalibratorEth:BOOL=ON \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install .. - name: Configure [Ubuntu/macOS] @@ -146,8 +145,7 @@ jobs: -DENABLE_icubmod_embObjIMU:BOOL=ON -DENABLE_icubmod_embObjInertials:BOOL=ON \ -DENABLE_icubmod_embObjMais:BOOL=ON -DENABLE_icubmod_embObjMotionControl:BOOL=ON \ -DENABLE_icubmod_embObjSkin:BOOL=ON -DENABLE_icubmod_embObjStrain:BOOL=ON \ - -DENABLE_icubmod_embObjVirtualAnalogSensor:BOOL=ON -DENABLE_icubmod_parametricCalibrator:BOOL=ON \ - -DENABLE_icubmod_parametricCalibratorEth:BOOL=ON \ + -DENABLE_icubmod_parametricCalibrator:BOOL=ON -DENABLE_icubmod_parametricCalibratorEth:BOOL=ON \ -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install .. - name: Enable python bindings on Ubuntu if: matrix.os == 'ubuntu-latest' diff --git a/src/libraries/icubmod/CMakeLists.txt b/src/libraries/icubmod/CMakeLists.txt index 3007d867bb..e41e5cbeb6 100644 --- a/src/libraries/icubmod/CMakeLists.txt +++ b/src/libraries/icubmod/CMakeLists.txt @@ -50,7 +50,6 @@ yarp_begin_plugin_library(icubmod QUIET) add_subdirectory(embObjMultiEnc) add_subdirectory(embObjInertials) add_subdirectory(embObjIMU) - add_subdirectory(embObjVirtualAnalogSensor) add_subdirectory(imuST_M1) add_subdirectory(imuFilter) add_subdirectory(embObjPSC) diff --git a/src/libraries/icubmod/embObjLib/IethResource.h b/src/libraries/icubmod/embObjLib/IethResource.h index 8af280948f..130c4ae91d 100644 --- a/src/libraries/icubmod/embObjLib/IethResource.h +++ b/src/libraries/icubmod/embObjLib/IethResource.h @@ -32,7 +32,7 @@ // marco.accame on 20 oct 2014. // the objects which use ethResource to communicate with the ethernet boards inside the robot // must be derived from this class IethResource. -// these objects are: embObjMotionControl, embObjSkin, embObjAnalogSensor, embObjVirtualAnalogSensor, and future ones. +// these objects are: embObjMotionControl, embObjSkin, embObjAnalogSensor, and future ones. // these object must implement the virtual functions initialised() and update() so that: // - initialised() must return true only if the object is opened (its method open() has returned). // - update() takes care of filling private data structures with bytes contained in the relevant ROPs coming from remote boards. diff --git a/src/libraries/icubmod/embObjVirtualAnalogSensor/CMakeLists.txt b/src/libraries/icubmod/embObjVirtualAnalogSensor/CMakeLists.txt deleted file mode 100644 index 15b39572f2..0000000000 --- a/src/libraries/icubmod/embObjVirtualAnalogSensor/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright: (C) 2012 RobotCub Consortium -# Authors: Alberto Cardellino -# CopyPolicy: Released under the terms of the GNU GPL v2.0. - -yarp_prepare_plugin(embObjVirtualAnalogSensor CATEGORY device TYPE yarp::dev::embObjVirtualAnalogSensor INCLUDE embObjVirtualAnalogSensor.h EXTRA_CONFIG WRAPPER=virtualAnalogServer) - -IF (NOT SKIP_embObjVirtualAnalogSensor) - - set(ICUB_COMPILE_EMBOBJ_LIBRARY ON CACHE INTERNAL "use the embObjLib lib") - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - - yarp_add_plugin(embObjVirtualAnalogSensor embObjVirtualAnalogSensor.cpp embObjVirtualAnalogSensor.h) - - TARGET_LINK_LIBRARIES(embObjVirtualAnalogSensor ethResources iCubDev) - icub_export_plugin(embObjVirtualAnalogSensor) - - yarp_install(TARGETS embObjVirtualAnalogSensor - COMPONENT Runtime - LIBRARY DESTINATION ${ICUB_DYNAMIC_PLUGINS_INSTALL_DIR} - ARCHIVE DESTINATION ${ICUB_STATIC_PLUGINS_INSTALL_DIR} - YARP_INI DESTINATION ${ICUB_PLUGIN_MANIFESTS_INSTALL_DIR}) - -ENDIF () - diff --git a/src/libraries/icubmod/embObjVirtualAnalogSensor/embObjVirtualAnalogSensor.cpp b/src/libraries/icubmod/embObjVirtualAnalogSensor/embObjVirtualAnalogSensor.cpp deleted file mode 100755 index 3541a72a18..0000000000 --- a/src/libraries/icubmod/embObjVirtualAnalogSensor/embObjVirtualAnalogSensor.cpp +++ /dev/null @@ -1,320 +0,0 @@ - -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -/* -* Copyright (C) 2013 Robotcub Consortium -* Author: Alberto Cardellino -* CopyPolicy: Released under the terms of the GNU GPL v2.0. -* -*/ - -// general purpose stuff. -#include -#include -#include - -// Yarp Includes -#include -#include -#include -#include -#include -#include - - -// specific to this device driver. -#include -#include -#include -#include - -#include -#include - -#include "EoProtocol.h" -#include "EoMotionControl.h" -#include "EoProtocolMC.h" - -#ifdef WIN32 -#pragma warning(once:4355) -#endif - - -using namespace yarp; -using namespace yarp::os; -using namespace yarp::dev; - - -//generic function that check is key1 is present in input bottle and that the result has size elements -// return true/false -static inline bool extractGroup(Bottle &input, Bottle &out, const std::string &key1, const std::string &txt, int size) -{ - size++; // size includes also the name of the parameter - Bottle &tmp=input.findGroup(key1.c_str(), txt.c_str()); - if (tmp.isNull()) - { - yError("%s not found\n", key1.c_str()); - return false; - } - - if(tmp.size()!=size) - { - yError("%s incorrect number of entries\n", key1.c_str()); - return false; - } - - out=tmp; - - return true; -} - -bool embObjVirtualAnalogSensor::fromConfig(yarp::os::Searchable &_config) -{ - Bottle xtmp; - - // Analog Sensor stuff - Bottle config = _config.findGroup("GENERAL"); - - if (!extractGroup(config, xtmp, "Channels","Number of channels of the Analog Sensor", 1)) - { - yError() << "embObjVirtualAnalogSensor: Missing channel number... aborting"; - _channels = 0; - return false; - } - else - { - _channels = xtmp.get(1).asInt(); - } - - // alloc vector for keeping conversion values - _fullscale = allocAndCheck(_channels); - _resolution = allocAndCheck(_channels); - - if (!extractGroup(config, xtmp, "UseCalibration","Calibration parameters are needed", 1)) - { - return false; - } - else - { - _useCalibration = xtmp.get(1).asInt(); - } - - if (!extractGroup(config, xtmp, "MaxValue","full scale value for this measure", _channels)) - { - yError() << "Missing conversion factor!! Aborting..."; - return false; - } - else - { - if(_verbose) - yDebug() << "embObjVirtualAnalogSensor, fullscales from config file: "; - - for (int ch = 1; ch < xtmp.size(); ch++) - { - _fullscale[ch-1] = xtmp.get(ch).asDouble(); - - if(_verbose) - yDebug() << "ch " << ch << ": " << _fullscale[ch-1]; - } - } - - if (!extractGroup(config, xtmp, "Resolution","Number of bytes used for this measure", _channels)) - { - yError() << "Missing resolution!! Aborting..."; - return false; - } - else - { - if(_verbose) - yDebug() << "embObjVirtualAnalogSensor, resolutions from config file: "; - - - for (int ch = 1; ch < xtmp.size(); ch++) - { - _resolution[ch-1] = (double) (1 << (xtmp.get(ch).asInt()-1) ); - if(_verbose) - yDebug() << "ch " << ch << ": " << _resolution[ch-1]; - } - } - return true; -} - - -embObjVirtualAnalogSensor::embObjVirtualAnalogSensor() -{ - _fullscale = NULL; - _resolution = NULL; - _useCalibration = 0; - _channels = 0; - _verbose = false; - _status = yarp::dev::VAS_status::VAS_OK; - opened = false; -} - -embObjVirtualAnalogSensor::~embObjVirtualAnalogSensor() -{ - -} - -bool embObjVirtualAnalogSensor::initialised() -{ - return opened; -} - -bool embObjVirtualAnalogSensor::update(eOprotID32_t id32, double timestamp, void *rxdata) -{ - return true; -} - -eth::iethresType_t embObjVirtualAnalogSensor::type() -{ - return eth::iethres_analogvirtual; -} - - - -bool embObjVirtualAnalogSensor::open(yarp::os::Searchable &config) -{ - // - first thing to do is verify if the eth manager is available. then i parse info about the eth board. - - ethManager = eth::TheEthManager::instance(); - if(NULL == ethManager) - { - yFatal() << "embObjVirtualAnalogSensor::open() fails to instantiate ethManager"; - return false; - } - - - if(false == ethManager->verifyEthBoardInfo(config, ipv4addr, boardIPstring, boardName)) - { - yError() << "embObjVirtualAnalogSensor::open(): object TheEthManager fails in parsing ETH propertiex from xml file"; - return false; - } - // add specific info about this device ... - - - - // - now all other things - - - std::string str; - if(config.findGroup("GENERAL").find("verbose").asBool()) - { - str=config.toString().c_str(); - _verbose = true; - } - else - str=" "; - - yTrace() << str; - - // Read stuff from config file - if(!fromConfig(config)) - { - yError() << "embObjAnalogSensor missing some configuration parameter. Check logs and your config file."; - return false; - } - - - // -- instantiate EthResource etc. - - res = ethManager->requestResource2(this, config); - if(NULL == res) - { - yError() << "embObjVirtualAnalogSensor::open() fails because could not instantiate the ethResource for BOARD w/ IP = " << boardIPstring << " ... unable to continue"; - return false; - } - - // i verify the motion-control because .... in here we use messages of this endpoint ... and we need to verfy in order to send messages. - if(!res->verifyEPprotocol(eoprot_endpoint_motioncontrol)) - { - cleanup(); - return false; - } - - - - yTrace() << "embObjVirtualAnalogSensor::open(): succefully called for BOARD" << res->getProperties().boardnameString << "IP" << res->getProperties().ipv4addrString << "instantiated correctly"; - - opened = true; - return true; -} - -/* - * IVirtualAnalogSensor Interface - * - */ - -yarp::dev::VAS_status embObjVirtualAnalogSensor::getVirtualAnalogSensorStatus(int ch) -{ - return yarp::dev::VAS_status::VAS_OK; -}; - -int embObjVirtualAnalogSensor::getVirtualAnalogSensorChannels() -{ - return _channels; -}; - -bool embObjVirtualAnalogSensor::updateVirtualAnalogSensorMeasure(yarp::sig::Vector &measure) -{ - bool ret = true; - if(measure.size() != _channels) - { - yError() << "Vector of measures has a different size from channel number!! Skipping"; - return false; - } - - for(int ch=0; ch< _channels; ch++) - { - ret &= updateVirtualAnalogSensorMeasure(ch, measure[ch]); - } - return true; -} - -bool embObjVirtualAnalogSensor::updateVirtualAnalogSensorMeasure(int ch, double &measure) -{ - if (measure < ( - _fullscale[ch]) ) - measure = (-_fullscale[ch]); - - if (measure > _fullscale[ch] ) - measure = _fullscale[ch]; - - // Here measure is supposed to be a Torque - eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, ch, eoprot_tag_mc_joint_inputs_externallymeasuredtorque); - // example measure * 32768.0/12.0; - // measure should to saturated to resolution -2.0 to avoid casting problem. - eOmeas_torque_t meas_torque = (eOmeas_torque_t)( measure * ((_resolution[ch]-2.0)/_fullscale[ch])); - - // i write also locally because somebody may read it back later - res->setLocalValue(protid, &meas_torque); - // and i want also to send it to the board - return res->setRemoteValue(protid, &meas_torque); -} - -void embObjVirtualAnalogSensor::cleanup(void) -{ - yTrace() << "embObjVirtualAnalogSensor::cleanup(): called for BOARD" << res->getProperties().boardnameString << "IP" << res->getProperties().ipv4addrString; - - if(_fullscale != NULL) - delete(_fullscale); - - if(ethManager == NULL) return; - - int ret = ethManager->releaseResource2(res, this); - res = NULL; - if(ret == -1) - ethManager->killYourself(); -} - -bool embObjVirtualAnalogSensor::close() -{ - cleanup(); - return true; -} - - - - -// eof - - diff --git a/src/libraries/icubmod/embObjVirtualAnalogSensor/embObjVirtualAnalogSensor.h b/src/libraries/icubmod/embObjVirtualAnalogSensor/embObjVirtualAnalogSensor.h deleted file mode 100644 index 53ab6101b1..0000000000 --- a/src/libraries/icubmod/embObjVirtualAnalogSensor/embObjVirtualAnalogSensor.h +++ /dev/null @@ -1,82 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -#ifndef __analogVirtualSensorEth_h__ -#define __analogVirtualSensorEth_h__ - - -#include -#include - -#include "IethResource.h" -#include -#include - - -#include - - -namespace yarp{ - namespace dev{ - class embObjVirtualAnalogSensor; - } -} - - - -/*! class yarp::dev::embObjVirtualAnalogSensor - * - */ -class yarp::dev::embObjVirtualAnalogSensor: public yarp::dev::IVirtualAnalogSensor, - public yarp::dev::DeviceDriver, - public eth::IethResource -{ -private: - - string boardIPstring; - string boardName; - eOipv4addr_t ipv4addr; - - eth::TheEthManager *ethManager; - eth::AbstractEthResource *res; - - //////////////////// - // parameters - int _channels; - short _useCalibration; - double *_fullscale; /** converts input values to HW fullscale */ - double *_resolution; /** number of bytes of resolution for this measure */ - - bool _verbose; - VAS_status _status; - - bool opened; - - // Read useful data from config and check for correctness - bool fromConfig(yarp::os::Searchable &config); - -public: - - - embObjVirtualAnalogSensor(); - ~embObjVirtualAnalogSensor(); - - // An open function yarp factory compatible - bool open(yarp::os::Searchable &config); - void cleanup(void); - bool close(); - - virtual bool initialised(); - virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata); - virtual eth::iethresType_t type(); - - // IvirtualAnalogSensor interface - virtual yarp::dev::VAS_status getVirtualAnalogSensorStatus(int ch); - virtual int getVirtualAnalogSensorChannels(); - virtual bool updateVirtualAnalogSensorMeasure(yarp::sig::Vector &measure); - virtual bool updateVirtualAnalogSensorMeasure(int ch, double &measure); -}; - - -#endif - -