From e21a648aa413cd2638741c939e8a3a3dd2c6a60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 22 Dec 2019 18:54:55 +0100 Subject: [PATCH 1/6] Clean code --- programs/dumpCanBus/CMakeLists.txt | 26 +++++----- programs/dumpCanBus/DumpCanBus.cpp | 82 +++++++++--------------------- programs/dumpCanBus/DumpCanBus.hpp | 52 ++++++------------- programs/dumpCanBus/ThreadImpl.cpp | 43 ++++++++-------- programs/dumpCanBus/main.cpp | 8 +-- 5 files changed, 77 insertions(+), 134 deletions(-) diff --git a/programs/dumpCanBus/CMakeLists.txt b/programs/dumpCanBus/CMakeLists.txt index de4ca183f..5bba833b4 100644 --- a/programs/dumpCanBus/CMakeLists.txt +++ b/programs/dumpCanBus/CMakeLists.txt @@ -1,19 +1,21 @@ -option(ENABLE_dumpCanBus "Enable/disable dumpCanBus program" ON) +cmake_dependent_option(ENABLE_dumpCanBus "Enable/disable dumpCanBus program" ON + ENABLE_CanBusSharerLib OFF) if(ENABLE_dumpCanBus) -add_executable(dumpCanBus main.cpp - DumpCanBus.cpp - DumpCanBus.hpp - ThreadImpl.cpp) + add_executable(dumpCanBus main.cpp + DumpCanBus.cpp + DumpCanBus.hpp + ThreadImpl.cpp) -target_link_libraries(dumpCanBus YARP::YARP_OS - YARP::YARP_init - YARP::YARP_dev - ROBOTICSLAB::ColorDebug - YarpDevicesInterfaces) + target_link_libraries(dumpCanBus YARP::YARP_OS + YARP::YARP_init + YARP::YARP_dev + CanBusSharerLib + ROBOTICSLAB::ColorDebug + YarpDevicesInterfaces) -install(TARGETS dumpCanBus - DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS dumpCanBus + DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/programs/dumpCanBus/DumpCanBus.cpp b/programs/dumpCanBus/DumpCanBus.cpp index 210687189..7750b251d 100644 --- a/programs/dumpCanBus/DumpCanBus.cpp +++ b/programs/dumpCanBus/DumpCanBus.cpp @@ -3,89 +3,53 @@ #include "DumpCanBus.hpp" #include -#include -#include -#include +#include #include -namespace roboticslab -{ +using namespace roboticslab; -/************************************************************************/ -DumpCanBus::DumpCanBus() { } +DumpCanBus::DumpCanBus() + : iCanBus(nullptr), + iCanBufferFactory(nullptr) +{ } -/************************************************************************/ -bool DumpCanBus::configure(yarp::os::ResourceFinder &rf) +bool DumpCanBus::configure(yarp::os::ResourceFinder & rf) { + CD_DEBUG("%s\n", rf.toString().c_str()); - if(rf.check("help")) + if (rf.check("help")) { std::printf("DumpCanBus options:\n"); std::printf("\t--help (this help)\t--from [file.ini]\t--context [path]\n"); - CD_DEBUG_NO_HEADER("%s\n",rf.toString().c_str()); + CD_DEBUG_NO_HEADER("%s\n", rf.toString().c_str()); return false; } - CD_DEBUG("%s\n",rf.toString().c_str()); - deviceDevCan0.open(rf); - if (!deviceDevCan0.isValid()) + yarp::os::Property canBusOptions; + canBusOptions.fromString(rf.toString()); + canBusOptions.put("blockingMode", false); // enforce non-blocking mode + canBusOptions.put("allowPermissive", false); // always check usage requirements + + if (!canDevice.open(canBusOptions)) { - CD_ERROR("deviceDevCan0 instantiation not worked.\n"); + CD_ERROR("CAN device instantiation failed.\n"); return false; } - deviceDevCan0.view(iCanBus); - deviceDevCan0.view(iCanBufferFactory); - - canInputBuffer = iCanBufferFactory->createBuffer(1); - - lastNow = yarp::os::Time::now(); - return this->start(); -} + canDevice.view(iCanBus); + canDevice.view(iCanBufferFactory); -/************************************************************************/ + canInputBuffer = iCanBufferFactory->createBuffer(1); -bool DumpCanBus::updateModule() -{ - //printf("DumpCanBus alive...\n"); - return true; + return yarp::os::Thread::start() || close(); } -/************************************************************************/ - bool DumpCanBus::close() { - this->stop(); - + yarp::os::Thread::stop(); iCanBufferFactory->destroyBuffer(canInputBuffer); - deviceDevCan0.close(); - + canDevice.close(); return true; } - -/************************************************************************/ - -std::string DumpCanBus::msgToStr(yarp::dev::CanMessage* message) -{ - std::stringstream tmp; - for(int i=0; i < message->getLen()-1; i++) - { - tmp << std::hex << static_cast(message->getData()[i]) << " "; - } - tmp << std::hex << static_cast(message->getData()[message->getLen()-1]); - tmp << ". canId("; - tmp << std::dec << (message->getId() & 0x7F); - tmp << ") via("; - tmp << std::hex << (message->getId() & 0xFF80); - tmp << "), t:" << yarp::os::Time::now() - lastNow << "[s]."; - - lastNow = yarp::os::Time::now(); - - return tmp.str(); -} - -/************************************************************************/ - -} // namespace roboticslab diff --git a/programs/dumpCanBus/DumpCanBus.hpp b/programs/dumpCanBus/DumpCanBus.hpp index 7673ebc2e..87128b365 100644 --- a/programs/dumpCanBus/DumpCanBus.hpp +++ b/programs/dumpCanBus/DumpCanBus.hpp @@ -17,53 +17,31 @@ namespace roboticslab /** * @ingroup dumpCanBus - * * @brief Launches one CAN bus driver, dumps output. - * */ -class DumpCanBus : public yarp::os::RFModule, public yarp::os::Thread +class DumpCanBus : public yarp::os::RFModule, + public yarp::os::Thread { public: - DumpCanBus(); - bool configure(yarp::os::ResourceFinder &rf); - -protected: - yarp::dev::PolyDriver deviceDevCan0; - yarp::dev::ICanBus* iCanBus; - yarp::dev::ICanBufferFactory* iCanBufferFactory; - yarp::dev::CanBuffer canInputBuffer; - - /** A helper function to display CAN messages. */ - std::string msgToStr(yarp::dev::CanMessage* message); - double lastNow; + DumpCanBus(); - virtual double getPeriod() - { - return 3.0; - } - virtual bool updateModule(); + virtual bool configure(yarp::os::ResourceFinder & rf); + virtual bool updateModule() + { return true; } virtual bool close(); -// virtual bool interruptModule(); -// virtual int period; // -------- Thread declarations. Implementation in ThreadImpl.cpp -------- - - /** - * Main body of the new thread. - * Override this method to do what you want. - * After Thread::start is called, this - * method will start running in a separate thread. - * It is important that this method either keeps checking - * Thread::isStopping to see if it should stop, or - * you override the Thread::onStop method to interact - * with it in some way to shut the new thread down. - * There is no really reliable, portable way to stop - * a thread cleanly unless that thread cooperates. - */ virtual void run(); + +private: + + yarp::dev::PolyDriver canDevice; + yarp::dev::ICanBus * iCanBus; + yarp::dev::ICanBufferFactory * iCanBufferFactory; + yarp::dev::CanBuffer canInputBuffer; }; -} // namespace roboticslab +} // namespace roboticslab -#endif // __DUMP_CAN_BUS__ +#endif // __DUMP_CAN_BUS__ diff --git a/programs/dumpCanBus/ThreadImpl.cpp b/programs/dumpCanBus/ThreadImpl.cpp index 9caffa65b..3a049c306 100644 --- a/programs/dumpCanBus/ThreadImpl.cpp +++ b/programs/dumpCanBus/ThreadImpl.cpp @@ -2,44 +2,41 @@ #include "DumpCanBus.hpp" +#include + +#include + #include +#include "CanUtils.hpp" + +using namespace roboticslab; + // ------------------ Thread Related ----------------------------------------- -void roboticslab::DumpCanBus::run() +void DumpCanBus::run() { CD_INFO("Started DumpCanBus reading thread run.\n"); - while ( ! this->RFModule::isStopping() ) + while (!yarp::os::RFModule::isStopping()) { + //-- Lend CPU time to write threads. + // https://github.com/roboticslab-uc3m/yarp-devices/issues/191 + yarp::os::Time::delay(std::numeric_limits::min()); + unsigned int read; - //-- Blocks with timeout until one message arrives, returns false on errors. - bool ok = iCanBus->canRead(canInputBuffer, 1, &read, true); + //-- Return immediately if there is nothing to be read (non-blocking call), return false on errors. + bool ok = iCanBus->canRead(canInputBuffer, 1, &read); //-- All debugging messages should be contained in canRead, so just loop again. - if( !ok || read == 0 ) continue; + if (!ok || read == 0) continue; - yarp::dev::CanMessage &msg = canInputBuffer[0]; - int canId = msg.getId() & 0x7F; - - //-- Commenting next line as way too verbose, happens all the time. - //CD_DEBUG("Read ok. %s\n", msgToStr(&buffer).c_str()); - - //-- Intercept 700h 0 msg that just indicates presence. - if( (msg.getId()-canId) == 0x700 ) - { - CD_SUCCESS("Device indicating presence. %s\n",msgToStr(&msg).c_str()); - continue; - } - - CD_SUCCESS("Read CAN message: %s\n", msgToStr(&msg).c_str()); - - } //-- ends: while ( ! this->isStopping() ). + const yarp::dev::CanMessage & msg = canInputBuffer[0]; + CD_INFO("Read CAN message: %s\n", CanUtils::msgToStr(msg.getId(), msg.getLen(), msg.getData()).c_str()); + } CD_INFO("Stopping DumpCanBus reading thread run.\n"); - - return; } // ----------------------------------------------------------------------------- diff --git a/programs/dumpCanBus/main.cpp b/programs/dumpCanBus/main.cpp index 3510b6f56..d55cbde55 100644 --- a/programs/dumpCanBus/main.cpp +++ b/programs/dumpCanBus/main.cpp @@ -53,14 +53,16 @@ int main(int argc, char *argv[]) rf.setDefaultConfigFile("dumpCanBus.ini"); rf.configure(argc, argv); - CD_INFO("Checking for yarp network...\n"); yarp::os::Network yarp; + CD_INFO_NO_HEADER("Checking for yarp network... "); + if (!yarp.checkNetwork()) { - CD_ERROR("Found no yarp network (try running \"yarpserver &\"), bye!\n"); + CD_ERROR("[fail]\n"); return 1; } - CD_SUCCESS("Found yarp network.\n"); + + CD_SUCCESS_NO_HEADER("[ok]\n"); roboticslab::DumpCanBus mod; return mod.runModule(rf); From d00870e59d49ab47fa928ae52347be1643f57e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 22 Dec 2019 19:11:40 +0100 Subject: [PATCH 2/6] Nuke checkCanBus app We can easily detect presence of iPOS drives via pcanview app, and CuiAbsolute nodes have learned to acknowledge poll queries. Furthermore, there is little point in having a dedicate app for the NMT reset node command as pressing the emergency button achieves the same result. Also, the ongoing CAN rework will make such operations possible in an online manner. --- programs/CMakeLists.txt | 1 - programs/checkCanBus/CMakeLists.txt | 19 -- programs/checkCanBus/CheckCanBus.cpp | 262 ------------------ programs/checkCanBus/CheckCanBus.hpp | 103 ------- programs/checkCanBus/ThreadImpl.cpp | 72 ----- programs/checkCanBus/main.cpp | 79 ------ share/CMakeLists.txt | 4 - share/contexts/checkCanBus/checkCanBus.ini | 5 - .../checkCanBus/checkLocomotionCan0.ini | 6 - .../checkCanBus/checkLocomotionCan1.ini | 6 - .../checkCanBus/checkManipulationCan2.ini | 6 - .../checkCanBus/checkManipulationCan3.ini | 6 - 12 files changed, 569 deletions(-) delete mode 100644 programs/checkCanBus/CMakeLists.txt delete mode 100644 programs/checkCanBus/CheckCanBus.cpp delete mode 100644 programs/checkCanBus/CheckCanBus.hpp delete mode 100644 programs/checkCanBus/ThreadImpl.cpp delete mode 100644 programs/checkCanBus/main.cpp delete mode 100644 share/contexts/checkCanBus/checkCanBus.ini delete mode 100644 share/contexts/checkCanBus/checkLocomotionCan0.ini delete mode 100644 share/contexts/checkCanBus/checkLocomotionCan1.ini delete mode 100644 share/contexts/checkCanBus/checkManipulationCan2.ini delete mode 100644 share/contexts/checkCanBus/checkManipulationCan3.ini diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 4c8070825..2e6b0b28e 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright: Universidad Carlos III de Madrid (C) 2013-2014 # Authors: Juan G. Victores & Raúl de Santos Rico -#add_subdirectory(checkCanBus) add_subdirectory(dumpCanBus) add_subdirectory(grabberControls2Gui) add_subdirectory(launchCanBus) diff --git a/programs/checkCanBus/CMakeLists.txt b/programs/checkCanBus/CMakeLists.txt deleted file mode 100644 index a6bbd120f..000000000 --- a/programs/checkCanBus/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -option(ENABLE_checkCanBus "Enable/disable checkCanBus program" ON) - -if(ENABLE_checkCanBus) - -add_executable(checkCanBus main.cpp - CheckCanBus.cpp - CheckCanBus.hpp - ThreadImpl.cpp) - -target_link_libraries(checkCanBus YARP::YARP_OS - YARP::YARP_init - YARP::YARP_dev - ROBOTICSLAB::ColorDebug - YarpDevicesInterfaces) - -install(TARGETS checkCanBus - DESTINATION ${CMAKE_INSTALL_BINDIR}) - -endif() diff --git a/programs/checkCanBus/CheckCanBus.cpp b/programs/checkCanBus/CheckCanBus.cpp deleted file mode 100644 index 1b1cea9bc..000000000 --- a/programs/checkCanBus/CheckCanBus.cpp +++ /dev/null @@ -1,262 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -#include "CheckCanBus.hpp" - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace roboticslab -{ - -/************************************************************************/ -CheckCanBus::CheckCanBus() {} - - - -/************************************************************************/ -// -- Función principal: Se llama en mod.runModule(rf) desde el main.cpp -bool CheckCanBus::configure(yarp::os::ResourceFinder &rf) -{ - - timeOut = 2; // -- Por defecto 2 [s] el parámetro --timeOut - firstTime = 0; // -- inicializo el tiempo a 0 [s] la primera vez que arranca el programa - cleaningTime = 1; // -- Por defecto 1 [s] el parámetro --cleaningTime - bool flag; // -- flag de return - - // -- Antes de configurar los periféricos, check a parámetro --help - if(rf.check("help")) - { - std::printf("CheckCanBus options:\n"); - std::printf("\t--help (this help)\t --ids [\"(id)\"] \t\t --from [file.ini]\t --canDevice [path]*\n\t--timeOut [s]\t\t --resetAll (for all nodes)\t --resetNode [node]\t --cleaningTime [s]\n"); - std::printf("\n"); - std::printf("*can0: \t--canDevice /dev/can0\t\t can1: --canDevice /dev/can1\n"); - std::printf(" .ini:\t checkLocomotionCan0.ini\t checkLocomotionCan1.ini\t checkManipulationCan0.ini\t checkManipulationCan1.ini\n\n"); - std::printf("Example of uses:\n"); - std::printf("* Reset driver ID [23] and check it:\t\t\t\t checkCanBus --canDevice /dev/can1 --ids 23 --resetNode 23\n"); - std::printf("* Reset drivers IDs [23,24] and check them:\t\t\t checkCanBus --canDevice /dev/can1 --ids \"(23 24)\" --resetAll\n"); - std::printf("* Reset all drivers of manipulation Can0 and check devices:\t checkCanBus --canDevice /dev/can0 --from checkManipulationCan0.ini --resetAll\n"); - - - CD_DEBUG_NO_HEADER("%s\n",rf.toString().c_str()); - std::exit(1); - return false; - } - - // -- Continuación del código que CONFIGURA LA HICO-CAN y LOS DRIVERS - CD_DEBUG("%s\n",rf.toString().c_str()); // -- nos muestra el contenido del objeto resource finder - deviceDevCan0.open(rf); // -- Abre el dispositivo HicoCan (tarjeta) y le pasa el ResourceFinder - if (!deviceDevCan0.isValid()) - { - CD_ERROR("deviceDevCan0 instantiation not worked.\n"); - return false; - } - deviceDevCan0.view(iCanBus); // -- conecta el dispositivo (hicocan) - deviceDevCan0.view(iCanBufferFactory); - - canInputBuffer = iCanBufferFactory->createBuffer(1); - - // -- adding configuration of TechnosoftIpos (se trata de la configuración mínima que necesita el driver) - yarp::os::Property TechnosoftIposConf("(device TechnosoftIpos) (canId 24) (min -100) (max 10) (tr 160) (refAcceleration 0.575) (refSpeed 5.0) (encoderPulses 1024)"); // -- frontal left elbow (codo) - - yarp::os::Value v(&iCanBufferFactory, sizeof(iCanBufferFactory)); - TechnosoftIposConf.put("canBufferFactory", v); - - bool ok = true; - ok &= canNodeDevice.open( TechnosoftIposConf ); // -- we introduce the configuration properties defined ........ - ok &= canNodeDevice.view( iControlLimitsRaw ); - ok &= canNodeDevice.view( iControlModeRaw ); - ok &= canNodeDevice.view( iEncodersTimedRaw ); - ok &= canNodeDevice.view( iPositionControlRaw ); - ok &= canNodeDevice.view( iPositionDirectRaw ); - ok &= canNodeDevice.view( iTorqueControlRaw ); - ok &= canNodeDevice.view( iVelocityControlRaw ); - ok &= canNodeDevice.view( iCanBusSharer ); - ok &= canNodeDevice.view( technosoftIpos ); // -- conecta el dispositivo (drivers) - - // --Checking - if(ok) - { - CD_SUCCESS("Configuration of TechnosoftIpos sucessfully :)\n"); - } - else - { - CD_ERROR("Bad Configuration of TechnosoftIpos :(\n"); - std::exit(1); - } - - //-- Pass CAN bus (HicoCAN) pointer to CAN node (TechnosoftIpos). - iCanBusSharer->setCanBusPtr( iCanBus ); - - flag = this->start(); // arranca el hilo - - // -- Parametro: --timeout [s] - if(rf.check("timeOut")) - { - timeOut = rf.find("timeOut").asInt32(); - CD_INFO_NO_HEADER("[INFO] Timeout: %.2f [s]\n", timeOut); - } - - - // -- Parametro: --resetAll - if(rf.check("resetAll")) - { - CD_INFO_NO_HEADER("[INFO] Reseting all nodes\n"); - // -- doing reset of node after delay - yarp::os::Time::delay(1); - technosoftIpos->resetNodes(); - } - - // -- Parametro: --resetNode - if(rf.check("resetNode")) - { - nodeForReset = rf.find("resetNode").asInt32(); - CD_INFO_NO_HEADER("[INFO] Reseting node number: %i\n", nodeForReset ); - // -- doing reset of node after delay - yarp::os::Time::delay(1); - technosoftIpos->resetNode(nodeForReset); - } - - - // -- Parametro: --cleaningTime [s] - if(rf.check("cleaningTime")) - { - cleaningTime = rf.find("cleaningTime").asInt32(); - CD_INFO_NO_HEADER("[INFO] Cleaning Time: %.2f [s]\n", cleaningTime); - } - - - // -- Parametro: --ids (introduce los IDs en una cola) - if(rf.check("ids")) - { - yarp::os::Bottle jointsCan0 = rf.findGroup("ids"); // -- Introduce en un objeto bottle el parámetro ids - std::string strIds = jointsCan0.get(1).toString(); // -- strIds almacena los Ids que queremos comprobar - std::stringstream streamIds(strIds); // -- tratamos el string de IDs como un stream llamado streamIds - CD_INFO_NO_HEADER("[INFO] It will proceed to detect IDs: "); - int n; - while(streamIds>>n) // -- recorre el stream y va introduciendo cada ID en la cola - { - std::printf("%i ",n); - queueIds.push(n); // -- introduce en la cola los IDs - } - std::printf("\n"); - } - - - /* -- Parametro: --from (con este parámetro indicamos el lugar del .ini donde especificamos la configuración - * de la HicoCan y las ids que queremos comprobar) - */ - else - { - yarp::os::Bottle fileIds = rf.findGroup("ids"); - std::string strIds = fileIds.get(1).toString(); // -- strIds almacena los Ids que queremos comprobar - std::stringstream streamIds(strIds); // -- tratamos el string de IDs como un stream llamado streamIds - CD_INFO_NO_HEADER("[INFO] It will proceed to detect IDs: "); - int n; - while(streamIds>>n) // -- recorre el stream y va introduciendo cada ID en la cola - { - std::printf("%i ",n); - queueIds.push(n); // -- introduce en la cola los IDs - } - std::printf("\n"); - } - - lastNow = yarp::os::Time::now(); // -- tiempo actual - - return flag; -} - -/************************************************************************/ -bool CheckCanBus::updateModule() -{ - //printf("CheckCanBus alive...\n"); - return true; -} - -/************************************************************************/ -// -- Para el hilo y para el dispositivo PolyDriver -bool CheckCanBus::close() -{ - this->stop(); - - iCanBufferFactory->destroyBuffer(canInputBuffer); - deviceDevCan0.close(); - - return true; -} - -/************************************************************************/ -// -- Función que lee los mensajes que le llegan del CAN-BUS -std::string CheckCanBus::msgToStr(yarp::dev::CanMessage* message) -{ - - std::stringstream tmp; // -- nos permite insertar cualquier tipo de dato dentro del flujo - for(int i=0; i < message->getLen()-1; i++) - { - tmp << std::hex << static_cast(message->getData()[i]) << " "; - } - tmp << std::hex << static_cast(message->getData()[message->getLen()-1]); - tmp << ". canId("; - tmp << std::dec << (message->getId() & 0x7F); // -- muestra en decimal el ID - tmp << ") via("; - tmp << std::hex << (message->getId() & 0xFF80); // -- ??? - tmp << "), t:" << yarp::os::Time::now() - lastNow << "[s]."; // -- diferencia entre el tiempo actual y el del último mensaje - - lastNow = yarp::os::Time::now(); // -- tiempo actual (aleatorio) - - return tmp.str(); // -- devuelve el string (mensaje) -} - -/*************************************************************************/ - -// -- Función que comprueba los mensajes que recibe del CAN utilizando una cola de IDs -void CheckCanBus::checkIds(yarp::dev::CanMessage* message) -{ - // -- Almacenamos el contenido del mensaje en un stream - std::stringstream tmp; // -- stream que almacenará el mensaje recibido - for(int i=0; i < message->getLen()-1; i++) - tmp << std::hex << static_cast(message->getData()[i]) << " "; // -- inserta los bytes del mensaje menos el último - tmp << std::hex << static_cast(message->getData()[message->getLen()-1]); // -- inserta último byte - - // -- Recorremos la cola en busca del ID que ha lanzado el CAN - for(int i=0; igetId() & 0x7F)) // -- si el ID coincide, lo saco de la cola - { - CD_SUCCESS_NO_HEADER("Detected ID: %i\n", queueIds.front()); - if(!tmp.str().compare("80 85 1 0 0 0 0 0")) CD_WARNING_NO_HEADER("[WARNING] Detected possible cleaning of driver settings: %i\n ", queueIds.front()); - queueIds.pop(); // -- saca de la cola el elemento - } - else // -- En caso de que no coincida el ID - { - int res = queueIds.front(); // -- residuo que volveriamos a introducir en la cola - queueIds.pop(); // -- saca de la cola el primer elemento - queueIds.push(res); // -- lo vuelve a introducir al final - } - } -} - -// -- Función que imprime por pantalla los IDs no detectados (IDs residuales en cola) -void CheckCanBus::printWronglIds() -{ - for(int i=0; i -#include - -#include -#include -#include - -#include -#include -#include - -#include "ICanBusSharer.h" -#include "ITechnosoftIpos.h" - -namespace roboticslab -{ - -/** - * @ingroup dumpCanBus //-- MODIFICAR - * - * @brief Launches one CAN bus driver, dumps output. - * - */ - -class CheckCanBus : public yarp::os::RFModule, public yarp::os::Thread -{ -public: - CheckCanBus(); - bool configure(yarp::os::ResourceFinder &rf); - - // -- Nuevas variables: - double timeOut; // -- tiempo de espera para comprobar el ID (s) - double firstTime; // -- tiempo en el arranque (valor de tiempo aleatorio) - double cleaningTime; // -- tiempo de espera para que no lleguen mensajes "basura" de encoders absolutos - int nodeForReset; // -- nodo que queremos resetear - std::queue queueIds; // -- cola que almacenará los IDs - -protected: - - /** CAN BUS device. */ - yarp::dev::PolyDriver deviceDevCan0; // -- Dispositivo (HicoCan) que se crea. - yarp::dev::ICanBus* iCanBus; - yarp::dev::ICanBufferFactory* iCanBufferFactory; - yarp::dev::CanBuffer canInputBuffer; - - /** CAN node object. */ - yarp::dev::PolyDriver canNodeDevice; - yarp::dev::IControlLimitsRaw* iControlLimitsRaw; - yarp::dev::IControlModeRaw* iControlModeRaw; - yarp::dev::IEncodersTimedRaw* iEncodersTimedRaw; - yarp::dev::IPositionControlRaw* iPositionControlRaw; - yarp::dev::IPositionDirectRaw* iPositionDirectRaw; - yarp::dev::ITorqueControlRaw* iTorqueControlRaw; - yarp::dev::IVelocityControlRaw* iVelocityControlRaw; - ICanBusSharer* iCanBusSharer; // -- ?? - ITechnosoftIpos* technosoftIpos; //-- ok practice? - - /** A helper function to display CAN messages. */ - std::string msgToStr(yarp::dev::CanMessage* message); // -- Muestra los mensajes que vienen del CAN - - // -- Funcion que se encargará de chekear los IDs introducidos e imprimir los detectados - void checkIds(yarp::dev::CanMessage* message); // --Declara función que encontraremos en el .hpp - - // -- Funcion que se encargará de imprimir los IDs no detectados - void printWronglIds(); - - double lastNow; // -- Muestra el tiempo actual - - virtual double getPeriod() - { - return 3.0; // Periodicidad de llamada a updateModule en [s] - } - virtual bool updateModule(); - virtual bool close(); - -// virtual bool interruptModule(); -// virtual int period; - - // -------- Thread declarations. Implementation in ThreadImpl.cpp -------- - - /** - * Main body of the new thread. - * Override this method to do what you want. - * After Thread::start is called, this - * method will start running in a separate thread. - * It is important that this method either keeps checking - * Thread::isStopping to see if it should stop, or - * you override the Thread::onStop method to interact - * with it in some way to shut the new thread down. - * There is no really reliable, portable way to stop - * a thread cleanly unless that thread cooperates. - */ - virtual void run(); -}; - -} // namespace roboticslab - -#endif // __CHECK_CAN_BUS__ diff --git a/programs/checkCanBus/ThreadImpl.cpp b/programs/checkCanBus/ThreadImpl.cpp deleted file mode 100644 index b0909404f..000000000 --- a/programs/checkCanBus/ThreadImpl.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -#include "CheckCanBus.hpp" - -#include - -#include - -// ------------------ Thread Related ----------------------------------------- - -void roboticslab::CheckCanBus::run() -{ - CD_INFO("Started CheckCanBus reading thread run.\n"); - - double threadInitTime = yarp::os::Time::now(); - //double cleaningTime = 2.0; // -- Convertir en argumento de programa - - while ( ! this->RFModule::isStopping()) // -- Mientras no se pare el RFModule - { - unsigned int read; - - //-- Blocks with timeout until one message arrives, returns false on errors. - bool ok = iCanBus->canRead(canInputBuffer, 1, &read, true); - - /* Nota para la siguiente linea: si el tiempo que tarda el usuario en encender los brazos - * es inferior al cleaningTime, puede dar lugar a pérdida de mensajes que no sean detectados por la - * aplicación */ - if((yarp::os::Time::now()-threadInitTime) < cleaningTime) continue; //-- hasta que no llegue al cleaningTime, no revisará lo siguiente - - //-- All debugging messages should be contained in canRead, so just loop again. - if( !ok || read == 0 ) continue; // -- continue para omitir secciones de código e iniciar la siguiente iteración de un bucle - // -- de esta forma se saltaría el código siguiente hasta que read > 0 - - yarp::dev::CanMessage &msg = canInputBuffer[0]; - int canId = msg.getId() & 0x7F; // -- limpia basura del CAN - - //-- Intercept 700h 0 msg that just indicates presence. - if( (msg.getId()-canId) == 0x700 ) // -- Filtra mensajes por presencia - { - if(firstTime == 0) firstTime = yarp::os::Time::now(); // -- toma el firsTime al detectar la primera presencia - - //CD_SUCCESS("Device indicating presence. %s\n",msgToStr(&buffer).c_str()); - checkIds(&msg); // -- Comprueba los IDs e imprime por pantalla los detectados - continue; // -- Mientras esté detectando presencia, las instrucciones de abajo no las ejecuta - } - - //----------------- Comprueba IDs de encoders (mensajes con otra cabecera) ----------------- - else // -- En caso de que NO sean mensajes de presencia - { - checkIds(&msg); // -- muestra en pantalla los IDs de los encoders detectados - // -- Transcurridos los segundos indicados, imprime por pantalla los IDs no detectados - if(int(yarp::os::Time::now()-firstTime)==timeOut+1) - printWronglIds(); // -- Imprime los IDs que no se han utilizado - // -- 2 segundos después, para el Modulo - if(int(yarp::os::Time::now()-firstTime)==timeOut+3) - { - CD_SUCCESS_NO_HEADER("Happy end :)\n"); - this->stopModule(); - } - } - //CD_SUCCESS_NO_HEADER("Read CAN message: %s\n", msgToStr(&buffer).c_str()); // -- lee lo que le llega del can bus - - - } //-- ends: while ( ! this->isStopping() ). - - CD_INFO("Stopping CheckCanBus reading thread run.\n"); - - return; -} - -// ----------------------------------------------------------------------------- - diff --git a/programs/checkCanBus/main.cpp b/programs/checkCanBus/main.cpp deleted file mode 100644 index 772f9e52a..000000000 --- a/programs/checkCanBus/main.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -/** - * - * @ingroup yarp_devices_programs - * \defgroup checkCanBus checkCanBus - * - * @brief Creates an instance of roboticslab::CheckCanBus. - * - * @section checkCanBus_legal Legal - * - * Copyright: 2016 (C) Universidad Carlos III de Madrid - * - * Author: Raul de Santos Rico - * - * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see license/LGPL.TXT - * - * @section checkCanBus_install Installation - * - * The module is compiled when ENABLE_checkCanBus is activated (default: ON). For further - * installation steps refer to your own system installation guidelines. - * - * @section checkCanBus_running Running (assuming correct installation) - * - * First we must run a YARP name server if it is not running in our current namespace: -\verbatim -[on terminal 1] yarp server -\endverbatim - * And then launch the actual module: -\verbatim -[on terminal 2] checkCanBus -Parameters: - --help (this help) --ids ["(id)"] --from [file.ini] --canDevice [path]* - --timeOut [s] --resetAll (for all nodes) --resetNode [node] --cleaningTime [s] - -*can0: --canDevice /dev/can0 can1: --canDevice /dev/can1 - .ini: checkLocomotionCan0.ini checkLocomotionCan1.ini checkManipulationCan0.ini checkManipulationCan1.ini - -Example of uses: -* Reset driver ID [23] and check it: checkCanBus --canDevice /dev/can1 --ids 23 --resetNode 23 -* Reset drivers IDs [23,24] and check them: checkCanBus --canDevice /dev/can1 --ids "(23 24)" --resetAll -* Reset all drivers of manipulation Can0 and check devices: checkCanBus --canDevice /dev/can0 --from checkManipulationCan0.ini --resetAll - -\endverbatim - * - * @section checkCanBus_modify Modify - * - * This file can be edited at - * programs/checkCanBus/main.cpp - * - */ - -#include -#include - -#include - -#include "CheckCanBus.hpp" - -int main(int argc, char *argv[]) -{ - yarp::os::ResourceFinder rf; - rf.setVerbose(true); // -- Imprimir en pantalla la ubicación de los recursos a TRUE - rf.setDefaultContext("checkCanBus"); // -- Con esta función busca el directorio "checkCanBus" dentro de build/share/ - rf.setDefaultConfigFile("checkCanBus.ini"); // -- Nombre del fichero de configuración - rf.configure(argc, argv); - - CD_INFO("Checking for yarp network...\n"); - yarp::os::Network yarp; // -- Red Yarp - if (!yarp.checkNetwork()) // -- Comprobación de la red Yarp (yarp server) - { - CD_ERROR("Found no yarp network (try running \"yarpserver &\"), bye!\n"); - return 1; - } - CD_SUCCESS("Found yarp network.\n"); - - roboticslab::CheckCanBus mod; // -- Clase que hereda de RFModule y de Thread - return mod.runModule(rf); // -- runModule llama a la función configure() de CheckCanBus.hpp -} diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 49a9795ce..de554d57e 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -5,10 +5,6 @@ set(applications) set(contexts) -if(ENABLE_checkCanBus) - list(APPEND contexts contexts/checkCanBus) -endif() - if(ENABLE_dumpCanBus) list(APPEND contexts contexts/dumpCanBus) endif() diff --git a/share/contexts/checkCanBus/checkCanBus.ini b/share/contexts/checkCanBus/checkCanBus.ini deleted file mode 100644 index 93ffde06e..000000000 --- a/share/contexts/checkCanBus/checkCanBus.ini +++ /dev/null @@ -1,5 +0,0 @@ -/// checkCanBus.ini /// - -device CanBusPeak -canDevice /dev/pcan0 -canBitrate 1000000 diff --git a/share/contexts/checkCanBus/checkLocomotionCan0.ini b/share/contexts/checkCanBus/checkLocomotionCan0.ini deleted file mode 100644 index 6d3640c64..000000000 --- a/share/contexts/checkCanBus/checkLocomotionCan0.ini +++ /dev/null @@ -1,6 +0,0 @@ -/// checkLocomotionCan0.ini /// - -device CanBuspeak -canDevice /dev/pcan0 -canBitrate 1000000 -ids (1 2 3 4 5 6 14 101 102 103 104 105 106 114) diff --git a/share/contexts/checkCanBus/checkLocomotionCan1.ini b/share/contexts/checkCanBus/checkLocomotionCan1.ini deleted file mode 100644 index 6827c7058..000000000 --- a/share/contexts/checkCanBus/checkLocomotionCan1.ini +++ /dev/null @@ -1,6 +0,0 @@ -/// checkLocomotionCan1.ini /// - -device CanBusPeak -canDevice /dev/pcan1 -canBitrate 1000000 -ids (7 8 9 10 11 12 13 107 108 109 110 111 112 113) diff --git a/share/contexts/checkCanBus/checkManipulationCan2.ini b/share/contexts/checkCanBus/checkManipulationCan2.ini deleted file mode 100644 index 52b327756..000000000 --- a/share/contexts/checkCanBus/checkManipulationCan2.ini +++ /dev/null @@ -1,6 +0,0 @@ -/// checkManipulationCan2.ini /// - -device CanBusPeak -canDevice /dev/pcan2 -canBitrate 1000000 -ids (15 16 17 18 19 20 28 115 116 117 118 119 120) diff --git a/share/contexts/checkCanBus/checkManipulationCan3.ini b/share/contexts/checkCanBus/checkManipulationCan3.ini deleted file mode 100644 index ffb57aa5f..000000000 --- a/share/contexts/checkCanBus/checkManipulationCan3.ini +++ /dev/null @@ -1,6 +0,0 @@ -/// checkManipulationCan3.ini /// - -device CanBusPeak -canDevice /dev/pcan3 -canBitrate 1000000 -ids (21 22 23 24 25 26 27 121 122 123 124 125 126) From 1d6bbf39705131e7803a3d5ff40de9557c1d251f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 22 Dec 2019 19:18:05 +0100 Subject: [PATCH 3/6] Nuke exampleCanBusControlboard and exampleTechnosoftIpos Superseded by launchCanBus, just prepare an .ini that fits your needs. --- .travis.yml | 6 - .../exampleCanBusControlboard/CMakeLists.txt | 20 -- .../ExampleCanBusControlboard.cpp | 39 ---- .../ExampleCanBusControlboard.hpp | 42 ---- .../cpp/exampleCanBusControlboard/main.cpp | 119 ----------- .../cpp/exampleTechnosoftIpos/CMakeLists.txt | 18 -- .../exampleTechnosoftIpos.cpp | 195 ------------------ 7 files changed, 439 deletions(-) delete mode 100644 examples/cpp/exampleCanBusControlboard/CMakeLists.txt delete mode 100644 examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.cpp delete mode 100644 examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.hpp delete mode 100644 examples/cpp/exampleCanBusControlboard/main.cpp delete mode 100644 examples/cpp/exampleTechnosoftIpos/CMakeLists.txt delete mode 100644 examples/cpp/exampleTechnosoftIpos/exampleTechnosoftIpos.cpp diff --git a/.travis.yml b/.travis.yml index d7fb68c3d..8efccc70c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -138,9 +138,6 @@ before_script: - export YARP_DATA_DIRS=$PWD/install/share/roboticslab-yarp-devices:$YARP_DATA_DIRS - export CMAKE_PREFIX_PATH="$PWD/install/lib/cmake/ROBOTICSLAB_YARP_DEVICES:$CMAKE_PREFIX_PATH" - - mkdir -p "$TRAVIS_BUILD_DIR/build/exampleCanBusControlboard" && cd "$_" - - cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleCanBusControlboard" && make - - mkdir -p "$TRAVIS_BUILD_DIR/build/exampleJr3" && cd "$_" - cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleJr3" && make @@ -156,9 +153,6 @@ before_script: - mkdir -p "$TRAVIS_BUILD_DIR/build/exampleRemoteJr3" && cd "$_" - cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleRemoteJr3" && make - #- mkdir -p "$TRAVIS_BUILD_DIR/build/exampleTechnosoftIpos" && cd "$_" - #- cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleTechnosoftIpos" && make - script: - cd "$TRAVIS_BUILD_DIR/build/tests" && ctest -V diff --git a/examples/cpp/exampleCanBusControlboard/CMakeLists.txt b/examples/cpp/exampleCanBusControlboard/CMakeLists.txt deleted file mode 100644 index 469c5d1eb..000000000 --- a/examples/cpp/exampleCanBusControlboard/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) - -project(exampleCanBusControlboard LANGUAGES CXX) - -find_package(YARP 3.2 REQUIRED COMPONENTS OS dev) -find_package(COLOR_DEBUG REQUIRED) - -add_executable(exampleCanBusControlboard main.cpp - ExampleCanBusControlboard.cpp - ExampleCanBusControlboard.hpp) - -target_link_libraries(exampleCanBusControlboard YARP::YARP_OS - YARP::YARP_init - YARP::YARP_dev - ROBOTICSLAB::ColorDebug) - -include(GNUInstallDirs) - -install(TARGETS exampleCanBusControlboard - DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.cpp b/examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.cpp deleted file mode 100644 index e670e29be..000000000 --- a/examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -#include "ExampleCanBusControlboard.hpp" - -#include - -#include - -/************************************************************************/ -roboticslab::ExampleCanBusControlboard::ExampleCanBusControlboard() { } - -/************************************************************************/ -bool roboticslab::ExampleCanBusControlboard::configure(yarp::os::ResourceFinder &rf) -{ - yarp::os::Property options; - options.fromString(rf.toString()); //-- Allow options like stream_state=0. - options.put("device","controlboardwrapper2"); - options.put("subdevice","CanBusControlboard"); - - robotDevice.open(options); - - if (!robotDevice.isValid()) - { - CD_ERROR("Class instantiation not worked.\n"); - CD_ERROR("Be sure CMake \"ENABLE_YarpPlugins_CanBusControlboard\" variable is set \"ON\"\n"); - CD_ERROR("\"SKIP_CanBusControlboard is set\" --> should be --> \"ENABLE_CanBusControlboard is set\"\n"); - // robotDevice.close(); // un-needed? - return false; - } - - return true; -} - -/************************************************************************/ -bool roboticslab::ExampleCanBusControlboard::updateModule() -{ - //printf("ExampleCanBusControlboard alive...\n"); - return true; -} diff --git a/examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.hpp b/examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.hpp deleted file mode 100644 index b82d41f4e..000000000 --- a/examples/cpp/exampleCanBusControlboard/ExampleCanBusControlboard.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -#ifndef __EXAMPLE_CAN_BUS_CONTROLBOARD__ -#define __EXAMPLE_CAN_BUS_CONTROLBOARD__ - -#include -#include -#include - -namespace roboticslab -{ - -/** - * @ingroup exampleCanBusControlboard - * - * @brief Launches 1 left arm DoF + left hand wrapped by controlboardwrapper2. - * A controlboardwrapper2 may be used through a YARP remote_controlboard or directly through low-level YARP - * controlboardwrapper2 RPC commands. - * - */ -class ExampleCanBusControlboard : public yarp::os::RFModule -{ - -protected: - yarp::dev::PolyDriver robotDevice; - - double getPeriod() - { - return 3.0; - } - bool updateModule(); -// bool interruptModule(); -// int period; - -public: - ExampleCanBusControlboard(); - bool configure(yarp::os::ResourceFinder &rf); -}; - -} // namespace roboticslab - -#endif // __EXAMPLE_CAN_BUS_CONTROLBOARD__ diff --git a/examples/cpp/exampleCanBusControlboard/main.cpp b/examples/cpp/exampleCanBusControlboard/main.cpp deleted file mode 100644 index 5aa55a26e..000000000 --- a/examples/cpp/exampleCanBusControlboard/main.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -/** - * - * @ingroup yarp_devices_examples_cpp - * \defgroup exampleCanBusControlboard exampleCanBusControlboard - * - * @brief Creates an instance of roboticslab::ExampleCanBusControlboard. - * - * @section exampleCanBusControlboard_legal Legal - * - * Copyright: 2013 (C) Universidad Carlos III de Madrid - * - * Author: Juan G. Victores - * - * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see license/LGPL.TXT - * - * @section exampleCanBusControlboard_install Installation - * - * The module is compiled when ENABLE_exampleCanBusControlboard is activated (default: ON). For further - * installation steps refer to your own system installation guidelines. - * - * @section exampleCanBusControlboard_running Running (assuming correct installation) - * - * First we must make sure a YARP name server is running, -\verbatim -[yarp-devices, terminal 1] yarp detect --write -\endverbatim - * - * And run it if it is not running in our current namespace: -\verbatim -[kinematics-dynamics, terminal 1] yarp server -\endverbatim - * - * And then launch the actual and specify different options, as in "exampleCanBusControlboard \--option1 value1a value1b \--option2 value2". Specifically, the following options are checked by the CanBusControlboard device (\ref CanBusControlboard class): - -\verbatim -device=CanBusControlboard -mode [position] - position/velocity mode -canDevice [/dev/can0] - CAN device path -canBitrate [1000000] - CAN bitrate -ptModeMs [50] - PT mode miliseconds -ids -trs -maxs -mins -refAccelerations -refSpeeds -types -\endverbatim - * Say you have a motoripos device with id 15 and reduction 120, and a motorlacquey device with id 64, both on /dev/can0. The command that enables them and exposes YARP controlboard device ports is: -\verbatim -[yarp-devices, terminal 1] exampleCanBusControlboard --canDevice /dev/can0 --ids 15 64 --types motoripos motorlacquey --trs 120 -\endverbatim - * - * @section exampleCanBusControlboard_interfacing Interfacing with the exampleCanBusControlboard module - * - * The \ref exampleCanBusControlboard module acts as the server part of a network wrapper of the CanBusControlboard class. - * The implementation maps certain YARP rpc's to CanBusControlboard function calls. Therefore, we can interface - * with the class from the command-line by typing: -\verbatim -[kinematics-dynamics, terminal 2] yarp rpc /exampleCanBusControlboard/rpc:i -\endverbatim - * We can send an absolute position joint space movement (say, 5 degrees) to the motoripos such as: -\verbatim -[kinematics-dynamics, terminal 2] set pos 0 5 -\endverbatim - * And should get some kind of feedback, such as: -\verbatim -Response: [ok] -\endverbatim - * We can send an absolute position movement (say, a position corresponding to a 2000 us PWM) to the motorlacquey such as: -\verbatim -[kinematics-dynamics, terminal 2] set pos 1 2000 -\endverbatim - * And should get some kind of feedback, such as: -\verbatim -Response: [ok] -\endverbatim - * When finished, Control-C closes programs cleanly. Start by Control-C on kinematics-dynamics' rpc (it's the client part), and then Control-C on yarp-devices' exampleCanBusControlboard (it shuts down the motors correctly). - * - * @section exampleCanBusControlboard_modify Modify - * - * This file can be edited at - * yarp-devices/src/modules/exampleCanBusControlboard/main.cpp - * - */ - -#include -#include - -#include - -#include "ExampleCanBusControlboard.hpp" - -int main(int argc, char *argv[]) -{ - yarp::os::ResourceFinder rf; - rf.setVerbose(true); - rf.setDefaultContext("exampleCanBusControlboard"); - rf.setDefaultConfigFile("exampleCanBusControlboard.ini"); - rf.configure(argc, argv); - - CD_INFO("Checking for yarp network...\n"); - yarp::os::Network yarp; - if (!yarp.checkNetwork()) - { - CD_ERROR("Found no yarp network (try running \"yarpserver &\"), bye!\n"); - return 1; - } - CD_SUCCESS("Found yarp network.\n"); - - roboticslab::ExampleCanBusControlboard mod; - return mod.runModule(rf); -} diff --git a/examples/cpp/exampleTechnosoftIpos/CMakeLists.txt b/examples/cpp/exampleTechnosoftIpos/CMakeLists.txt deleted file mode 100644 index a56a22365..000000000 --- a/examples/cpp/exampleTechnosoftIpos/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) - -project(exampleTechnosoftIpos LANGUAGES CXX) - -find_package(YARP 3.2 REQUIRED COMPONENTS OS dev) -find_package(ROBOTICSLAB_YARP_DEVICES REQUIRED) - -add_executable(exampleTechnosoftIpos exampleTechnosoftIpos.cpp) - -target_link_libraries(exampleTechnosoftIpos YARP::YARP_OS - YARP::YARP_init - YARP::YARP_dev - ROBOTICSLAB::YarpDevicesInterfaces) - -include(GNUInstallDirs) - -install(TARGETS exampleTechnosoftIpos - DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/cpp/exampleTechnosoftIpos/exampleTechnosoftIpos.cpp b/examples/cpp/exampleTechnosoftIpos/exampleTechnosoftIpos.cpp deleted file mode 100644 index 0c5d14d86..000000000 --- a/examples/cpp/exampleTechnosoftIpos/exampleTechnosoftIpos.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- - -/** - * @ingroup yarp_devices_examples_cpp - * \defgroup exampleTechnosoftIpos exampleTechnosoftIpos - * - * @brief This example. - * - * Legal - * - * Copyright: (C) 2010 Universidad Carlos III de Madrid; - * (C) 2010 RobotCub Consortium - * - * Author: Juan G Victores - * - * Contribs: Paul Fitzpatrick and Giacomo Spigler (YARP dev/motortest.cpp example) - * - * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see license/LGPL.TXT - * - * Building -\verbatim -cd example/cpp -mkdir build; cd build; cmake .. -make -j3 -\endverbatim - * - * Running -\verbatim -./exampleTechnosoftIpos -\endverbatim - * - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -int main(int argc, char *argv[]) -{ - yarp::os::Network yarp; - - if (!yarp::os::Network::checkNetwork()) - { - std::printf("Please start a yarp name server first\n"); - return 1; - } - - yarp::dev::PolyDriver canBusDevice; - yarp::dev::ICanBus* iCanBus; - yarp::dev::ICanBufferFactory* iCanBufferFactory; - - yarp::os::Property canBusOptions; - canBusOptions.put("device", "CanBusHico"); - canBusOptions.put("canDevice", "/dev/can1"); - canBusOptions.put("canBitrate", 1000000); - canBusDevice.open(canBusOptions); - - if (!canBusDevice.isValid()) - { - std::printf("canBusDevice instantiation not worked.\n"); - return 1; - } - - canBusDevice.view(iCanBus); - canBusDevice.view(iCanBufferFactory); - - yarp::os::Property options; - options.put("device", "TechnosoftIpos"); - options.put("canId", 23); - options.put("tr", 120); - options.put("min", -60); - options.put("max", 60); - options.put("refAcceleration", 0.575437); - options.put("refSpeed", 737.2798); - - yarp::os::Value v(&iCanBufferFactory, sizeof(iCanBufferFactory)); - options.put("canBufferFactory", v); - - yarp::dev::PolyDriver dd(options); - - if (!dd.isValid()) - { - std::printf("TechnosoftIpos device not available.\n"); - return 1; - } - - //-- View TechnosoftIpos interfaces. - roboticslab::ICanBusSharer *iCanBusSharer; - bool ok = dd.view(iCanBusSharer); - - if (!ok) - { - std::printf("[error] Problems viewing ICanBusSharer.\n"); - return 1; - } - else std::printf("[success] Viewing ICanBusSharer.\n"); - - yarp::dev::IPositionControlRaw *pos; - ok = dd.view(pos); - - if (!ok) - { - std::printf("[error] Problems viewing IPositionControlRaw.\n"); - return 1; - } - else std::printf("[success] Viewing IPositionControlRaw.\n"); - - yarp::dev::IEncodersRaw *enc; - ok = dd.view(enc); - - if (!ok) - { - std::printf("[error] Problems viewing IEncodersRaw.\n"); - return 1; - } - else std::printf("[success] Viewing IEncodersRaw.\n"); - - yarp::dev::IVelocityControlRaw *vel; - ok = dd.view(vel); - - if (!ok) - { - std::printf("[error] Problems viewing IVelocityControlRaw.\n"); - return 1; - } - else std::printf("[success] Viewing IVelocityControlRaw.\n"); - - yarp::dev::IControlModeRaw *mode; - ok = dd.view(mode); - - if (!ok) - { - std::printf("[error] Problems viewing IControlModeRaw.\n"); - return 1; - } - else std::printf("[success] Viewing IControlModeRaw.\n"); - - //-- Pass before sending commands. - iCanBusSharer->setCanBusPtr(iCanBus); - - iCanBusSharer->start(); - - yarp::os::Time::delay(0.1); - iCanBusSharer->readyToSwitchOn(); - - yarp::os::Time::delay(0.1); - iCanBusSharer->switchOn(); - - yarp::os::Time::delay(2); - iCanBusSharer->enable(); - - //-- Commands on TechnosoftIpos. - ok = mode->setControlModeRaw(0, VOCAB_CM_POSITION); - - if (!ok) - { - std::printf("[error] Problems in setPositionModeRaw.\n"); - return 1; - } - else std::printf("[success] setPositionModeRaw.\n"); - - std::printf("test positionMove(0,-25)\n"); - ok = pos->positionMoveRaw(0, -25); - - if (!ok) - { - std::printf("[error] Problems in positionMove.\n"); - return 1; - } - else std::printf("[success] positionMove.\n"); - - std::printf("Delaying 5 seconds...\n"); - yarp::os::Time::delay(5); - - /*vel->setVelocityModeRaw(); - printf("test velocityMove(0,10)\n"); - vel->velocityMoveRaw(0,10); - - printf("Delaying 5 seconds...\n"); - yarp::os::Time::delay(5);*/ - - dd.close(); - - return 0; -} From ac295b8552a04550a4730bd0d624aa13be966d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 22 Dec 2019 19:29:46 +0100 Subject: [PATCH 4/6] Nuke testCuiAbsolute and testTechnosoftIpos This interfaces do no longer exist, use launchCanBus or pcanview (we recently tested new Cui firmware with the latter). Besides, most of testTechnosoftIpos code is commented out and I don't remember ever using any of these test apps. New CanBusControlboard device will handle online CAN configuration of launched nodes. --- share/CMakeLists.txt | 4 - .../testCuiAbsolute/testCuiAbsolute.ini | 5 - tests/CMakeLists.txt | 5 - tests/testCuiAbsolute/CMakeLists.txt | 8 - tests/testCuiAbsolute/testCuiAbsolute.cpp | 299 ----- tests/testTechnosoftIpos/CMakeLists.txt | 8 - .../testTechnosoftIpos/testTechnosoftIpos.cpp | 1132 ----------------- 7 files changed, 1461 deletions(-) delete mode 100644 share/contexts/testCuiAbsolute/testCuiAbsolute.ini delete mode 100644 tests/testCuiAbsolute/CMakeLists.txt delete mode 100644 tests/testCuiAbsolute/testCuiAbsolute.cpp delete mode 100644 tests/testTechnosoftIpos/CMakeLists.txt delete mode 100644 tests/testTechnosoftIpos/testTechnosoftIpos.cpp diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index de554d57e..879b95938 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -17,10 +17,6 @@ if(ENABLE_SpaceNavigator) list(APPEND applications applications/yarpmanager/spaceNavigator) endif() -if(ENABLE_tests) - list(APPEND contexts contexts/testCuiAbsolute) -endif() - yarp_install(FILES applications/yarpmanager/ymanager.ini DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}/yarpmanager) diff --git a/share/contexts/testCuiAbsolute/testCuiAbsolute.ini b/share/contexts/testCuiAbsolute/testCuiAbsolute.ini deleted file mode 100644 index bbb2e21ca..000000000 --- a/share/contexts/testCuiAbsolute/testCuiAbsolute.ini +++ /dev/null @@ -1,5 +0,0 @@ -/// testCuiAbsolute.ini /// - -device CanBusPeak -canDevice /dev/pcan0 -canBitrate 1000000 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 954e70766..d750c2f24 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,9 +7,7 @@ cmake_dependent_option(ENABLE_tests "Enable/disable unit tests" ON if(ENABLE_tests) enable_testing() - add_subdirectory(${GTestSources_SOURCE_DIR} ${CMAKE_BINARY_DIR}/gtest) - include_directories(${GTestSources_INCLUDE_DIR}) # testCanBusSharerLib @@ -27,9 +25,6 @@ if(ENABLE_tests) target_link_libraries(testDeviceMapperLib DeviceMapperLib YARP::YARP_dev gtest_main) gtest_add_tests(testDeviceMapperLib "" AUTO) endif() - - #add_subdirectory(testTechnosoftIpos) - #add_subdirectory(testCuiAbsolute) else() set(ENABLE_tests OFF CACHE BOOL "Enable/disable unit tests" FORCE) endif() diff --git a/tests/testCuiAbsolute/CMakeLists.txt b/tests/testCuiAbsolute/CMakeLists.txt deleted file mode 100644 index 380cee9bb..000000000 --- a/tests/testCuiAbsolute/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_executable(testCuiAbsolute testCuiAbsolute.cpp) - -target_link_libraries(testCuiAbsolute YARP::YARP_OS - YARP::YARP_dev - ROBOTICSLAB::ColorDebug - YarpDevicesInterfaces - gtest - gtest_main) diff --git a/tests/testCuiAbsolute/testCuiAbsolute.cpp b/tests/testCuiAbsolute/testCuiAbsolute.cpp deleted file mode 100644 index 23e1b5e83..000000000 --- a/tests/testCuiAbsolute/testCuiAbsolute.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "gtest/gtest.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include "ICanBusSharer.h" -#include "ICuiAbsolute.h" - -#define CAN_ID 124 // ID of Cui Absolute encoder that you want to check... - -namespace roboticslab -{ - -/** - * @ingroup yarp_devices_tests - * @brief Tests \ref CuiAbsolute on a single CAN node. - */ -class CuiAbsoluteTest : public testing::Test // -- inherit the Test class (gtest.h) -{ - -public: - - virtual void SetUp() - { - // -- code here will execute just before the test ensues - - yarp::os::Property canDeviceConf("(device CanBusPeak) (canDevice /dev/pcan3) (canBitrate 1000000)"); - bool ok = true; - ok &= canBusDevice.open(canDeviceConf); // -- we introduce the configuration properties defined in property object (p) and them, we stard the device (CanBusPeak) - ok &= canBusDevice.view(iCanBus); - ok &= canBusDevice.view(iCanBufferFactory); - - if(ok) - { - CD_SUCCESS("Configuration of CAN device sucessfully :)\n"); - } - else - { - CD_ERROR("Bad Configuration of CAN device :(\n"); - std::exit(1); - } - - // -- adding configuration of Cui Absolute Encoders (minimal configuration that CuiAbsolute need to run correctly) - std::stringstream strconf; - strconf << "(device CuiAbsolute) (canId " << CAN_ID << ") (min 0) (max 0) (tr 1) (refAcceleration 0.0) (refSpeed 0.0)"; - CD_DEBUG("%s\n",strconf.str().c_str()); - - yarp::os::Property cuiAbsoluteConf (strconf.str().c_str()); - yarp::os::Value v(&iCanBufferFactory, sizeof(iCanBufferFactory)); - cuiAbsoluteConf.put("canBufferFactory", v); - ok &= canNodeDevice.open( cuiAbsoluteConf ); // -- we introduce the configuration properties defined ........ - if ( ! canNodeDevice.isValid() ) - { - CD_ERROR("Bad device of CuiAbsolute :(\n"); - std::exit(1); - } - ok &= canNodeDevice.view( iControlLimitsRaw ); - ok &= canNodeDevice.view( iControlModeRaw ); - ok &= canNodeDevice.view( iEncodersTimedRaw ); - ok &= canNodeDevice.view( iPositionControlRaw ); - ok &= canNodeDevice.view( iPositionDirectRaw ); - ok &= canNodeDevice.view( iTorqueControlRaw ); - ok &= canNodeDevice.view( iVelocityControlRaw ); - ok &= canNodeDevice.view( iCanBusSharer ); - ok &= canNodeDevice.view( cuiAbsolute ); - - if(ok) - { - CD_SUCCESS("Configuration of CuiAbsolute sucessfully :)\n"); - } - else - { - CD_ERROR("Bad Configuration of CuiAbsolute :(\n"); - std::exit(1); - } - - //-- Pass CAN bus pointer to CAN node. - iCanBusSharer->setCanBusPtr( iCanBus ); - - canInputBuffer = iCanBufferFactory->createBuffer(1); - } - - virtual void TearDown() - { - // -- code here will be called just after the test completes - // -- ok to through exceptions from here if need be - iCanBufferFactory->destroyBuffer(canInputBuffer); - - canNodeDevice.close(); - canBusDevice.close(); - } - -protected: - - /** CAN BUS device. */ - yarp::dev::PolyDriver canBusDevice; - yarp::dev::ICanBus* iCanBus; - yarp::dev::ICanBufferFactory* iCanBufferFactory; - yarp::dev::CanBuffer canInputBuffer; - - /** CAN node object. */ - yarp::dev::PolyDriver canNodeDevice; - yarp::dev::IControlLimitsRaw* iControlLimitsRaw; - yarp::dev::IControlModeRaw* iControlModeRaw; - yarp::dev::IEncodersTimedRaw* iEncodersTimedRaw; - yarp::dev::IPositionControlRaw* iPositionControlRaw; - yarp::dev::IPositionDirectRaw* iPositionDirectRaw; - yarp::dev::ITorqueControlRaw* iTorqueControlRaw; - yarp::dev::IVelocityControlRaw* iVelocityControlRaw; - ICanBusSharer* iCanBusSharer; - ICuiAbsolute* cuiAbsolute; - - /** Function definitions **/ - std::string msgToStr(const yarp::dev::CanMessage& message) - { - std::stringstream tmp; - for(int i=0; i < message.getLen()-1; i++) - { - tmp << std::hex << static_cast(message.getData()[i]) << " "; - } - tmp << std::hex << static_cast(message.getData()[message.getLen()-1]); - tmp << ". canId("; - tmp << std::dec << (message.getId() & 0x7F); - tmp << ") via("; - tmp << std::hex << (message.getId() & 0xFF80); - tmp << ")."; - return tmp.str(); - } -}; - - -TEST_F( CuiAbsoluteTest, CuiAbsoluteSendingMessageInPullMode ) -{ - - int canId = 0; - double timeOut = 2; - double timeStamp = 0.0; - bool timePassed = false; - double cleaningTime = 0.5; // time to empty the buffer - std::map< int, int > idxFromCanId; - - bool startSending = cuiAbsolute->getCurrentPosition(); - timeStamp = yarp::os::Time::now(); - - yarp::dev::CanMessage &msg = canInputBuffer[0]; - - //-- Blocking read until we get a message from the expected canId - while ( (canId != CAN_ID) && !timePassed ) // -- it will check the ID (poner condición nAn) - { - // -- timer - if(int(yarp::os::Time::now()-timeStamp)==timeOut) - { - CD_ERROR("Time out exceeded\n"); - timePassed = true; - //continue; - } - - unsigned int read; - bool ok = iCanBus->canRead(canInputBuffer, 1, &read, true); - - // This line is needed to clear the buffer (old messages that has been received) - // if((yarp::os::Time::now()-timeStamp) < cleaningTime) continue; - - if( !ok || read == 0 ) continue; // -- is waiting for recive message - canId = msg.getId() & 0x7F; // -- if it recive the message, it will get ID - - - if (canId == CAN_ID) { - // -- Reading Cui Absolute Encoder Value - iCanBusSharer->interpretMessage(msg); // necessary for read CuiAbsolute - double value; - while( ! iEncodersTimedRaw->getEncoderRaw(0,&value) ){ - CD_ERROR("Wrong value of Cui \n"); - } - CD_DEBUG("Reading in pull mode from CuiAbsolute %d (Value: %f)\n", canId, value); - } - } - - ASSERT_TRUE(startSending); // -- testing startPullPublishing function - ASSERT_FALSE(timePassed); // -- testing the time (it have to be less than 2 sec (timeOut) ) - ASSERT_EQ(canId , CAN_ID); // -- testing if ID of the CUI is the same that it has received -} - - -TEST_F( CuiAbsoluteTest, CuiAbsoluteSendingMessageInContinuousMode ) -{ - bool startSending = cuiAbsolute->startPushPublishing(1); - - yarp::dev::CanMessage &msg = canInputBuffer[0]; - - // -- In continuous mode, we are goint to do three test to ensure that we are receiving multiple messages - for(int i=1; i<4 ; i++) - { - - int canId = 0; - double timeOut = 5; // -- 2 seconds - double timeStamp = 0.0; - double cleaningTime = 0.5; // time to empty the buffer - bool timePassed = false; - - timeStamp = yarp::os::Time::now(); - - //-- Blocking read until we get a message from the expected canId - - while ( (canId != CAN_ID) && !timePassed ) // -- it will check the ID - { - // -- if it exceeds the timeout...NOT PASS the test - if(int(yarp::os::Time::now()-timeStamp)==timeOut) - { - CD_ERROR("Time out exceeded\n"); - timePassed = true; - } - - unsigned int read; - bool ok = iCanBus->canRead(canInputBuffer, 1, &read, true); - - // This line is needed to clear the buffer (old messages that has been received) - if((yarp::os::Time::now()-timeStamp) < cleaningTime) continue; - - if( !ok || read == 0 ) continue; // -- is waiting for recive message - canId = msg.getId() & 0x7F; // -- if it recive the message, it will get ID - if (canId == CAN_ID) - { - // -- Reading Cui Absolute Encoder Value - iCanBusSharer->interpretMessage(msg); // necessary for read CuiAbsolute - double value = 0; - while( ! iEncodersTimedRaw->getEncoderRaw(0,&value) ){ - CD_ERROR("Wrong value of Cui \n"); - } - CD_DEBUG("Reading in continuous mode from CuiAbsolute %d (Value: %f) [check %d]\n", canId, value, i); - } - } - - ASSERT_TRUE(startSending); // -- testing startPushPublishing function - ASSERT_FALSE(timePassed); // -- testing the time (it have to be less than 2 sec) - ASSERT_EQ(canId , CAN_ID); // -- testing if the CAN ID of CUI is the same that it has received (3 tests) - yarp::os::Time::delay(1); - } -} - - -TEST_F( CuiAbsoluteTest, CuiAbsoluteStopSendingMessage ) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - double timeOut = 1; - double timeStamp = 0.0; - double cleaningTime = 0.5; // time to empty the buffer - bool timePassed = false; - - bool stopSending = cuiAbsolute->stopPushPublishing(); - yarp::os::Time::delay(1); // -- one second delay to empty the buffer - - timeStamp = yarp::os::Time::now(); - - yarp::dev::CanMessage &msg = canInputBuffer[0]; - - //-- Blocking read until we get a message from the expected canId - while ( (canId != CAN_ID) && !timePassed ) // -- it will check the ID - { - //printf("timeOut: %d\n", int(yarp::os::Time::now()-timeStamp)); - - // -- if it exceeds the timeout (1 secod) ...PASS the test - if(int(yarp::os::Time::now()-timeStamp)==timeOut) - { - CD_INFO("Time out passed and CuiAbsolute stopped successfully\n"); - timePassed = true; - } - - unsigned int read; - bool ok = iCanBus->canRead(canInputBuffer, 1, &read, true); - - // This line is needed to clear the buffer (old messages that has been received) - if((yarp::os::Time::now()-timeStamp) < cleaningTime) continue; - - if( !ok || read == 0 ) continue; // -- is waiting for recive message - canId = msg.getId() & 0x7F; // -- if it recive the message, it will get ID - CD_DEBUG("Read a message from CuiAbsolute %d\n", canId); - - } - - ASSERT_TRUE(stopSending); // -- testing stopPublishingMessages function - ASSERT_TRUE(timePassed); // -- testing the time (if it exceeds the timeout (1 secod) ...it will PASS the test) - ASSERT_NE(canId , CAN_ID); // -- testing if the CAN ID of CUI is NOT the same that it has received - -} - -} diff --git a/tests/testTechnosoftIpos/CMakeLists.txt b/tests/testTechnosoftIpos/CMakeLists.txt deleted file mode 100644 index 914a1883d..000000000 --- a/tests/testTechnosoftIpos/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_executable(testTechnosoftIpos testTechnosoftIpos.cpp) - -target_link_libraries(testTechnosoftIpos YARP::YARP_OS - YARP::YARP_dev - ROBOTICSLAB::ColorDebug - YarpDevicesInterfaces - gtest - gtest_main) diff --git a/tests/testTechnosoftIpos/testTechnosoftIpos.cpp b/tests/testTechnosoftIpos/testTechnosoftIpos.cpp deleted file mode 100644 index 544030082..000000000 --- a/tests/testTechnosoftIpos/testTechnosoftIpos.cpp +++ /dev/null @@ -1,1132 +0,0 @@ -#include "gtest/gtest.h" - -#include - -#include -#include - -#include -#include -#include - -#include - -#include "ICanBusSharer.h" -#include "ITechnosoftIpos.h" - -#define CAN_ID 124 - -namespace roboticslab -{ - -/** - * @ingroup yarp_devices_tests - * @brief Tests \ref TechnosoftIpos on a single CAN node. - */ -class TechnosoftIposTest : public testing::Test // -- inherit the Test class (gtest.h) -{ - -public: - - virtual void SetUp() - { - // -- code here will execute just before the test ensues - - yarp::os::Property canDeviceConf("(device CanBusHico) (canDevice /dev/can1) (canBitrate 1000000)"); // -- truco para agregar directamente un conjunto de propiedades sin tener que llamar a la función "put" - bool ok = true; - ok &= canBusDevice.open(canDeviceConf); // -- we introduce the configuration properties defined in property object (p) and them, we stard the device (HicoCAN) - ok &= canBusDevice.view(iCanBus); - ok &= canBusDevice.view(iCanBufferFactory); - - if(ok) - { - CD_SUCCESS("Configuration of CAN device sucessfully :)\n"); - } - else - { - CD_ERROR("Bad Configuration of CAN device :(\n"); - std::exit(1); - } - - //yarp::os::Property TechnosoftIposConf("(device TechnosoftIpos) (canId 15) (min -45) (max 70) (tr 160) (refAcceleration 0.575) (refSpeed 5.0)"); // -- frontal right arm - //yarp::os::Property TechnosoftIposConf("(device TechnosoftIpos) (canId 6) (min -90) (max 90) (tr 400) (refAcceleration 0.575) (refSpeed 5.0)"); // -- axial right leg - //yarp::os::Property TechnosoftIposConf("(device TechnosoftIpos) (canId 2) (min -25) (max 25) (tr 270.4) (refAcceleration 0.575) (refSpeed 5.0)"); // -- frontal right ankle (tobillo) - yarp::os::Property TechnosoftIposConf("(device TechnosoftIpos) (canId 124) (min -100) (max 10) (tr 160) (refAcceleration 0.575) (refSpeed 5.0)"); // -- frontal left elbow (codo) - - bool ok2 = true; - ok2 &= canNodeDevice.open( TechnosoftIposConf ); // -- we introduce the configuration properties defined ........ - ok2 &= canNodeDevice.view( iControlLimitsRaw ); - ok2 &= canNodeDevice.view( iControlModeRaw ); - ok2 &= canNodeDevice.view( iEncodersTimedRaw ); - ok2 &= canNodeDevice.view( iPositionControlRaw ); - ok2 &= canNodeDevice.view( iPositionDirectRaw ); - ok2 &= canNodeDevice.view( iTorqueControlRaw ); - ok2 &= canNodeDevice.view( iVelocityControlRaw ); - ok2 &= canNodeDevice.view( iCanBusSharer ); - ok2 &= canNodeDevice.view( technosoftIpos ); //-- ok practice? - if(ok2) - { - CD_SUCCESS("Configuration of TechnosoftIpos sucessfully :)\n"); - } - else - { - CD_ERROR("Bad Configuration of TechnosoftIpos :(\n"); - std::exit(1); - } - - //-- Pass CAN bus pointer to CAN node (TechnosoftIpos). - iCanBusSharer->setCanBusPtr( iCanBus ); - - canInputBuffer = iCanBufferFactory->createBuffer(1); - } - - virtual void TearDown() - { - // -- code here will be called just after the test completes - // -- ok to through exceptions from here if need be - iCanBufferFactory->destroyBuffer(canInputBuffer); - - canNodeDevice.close(); - canBusDevice.close(); - } - -protected: - - /** CAN BUS device. */ - yarp::dev::PolyDriver canBusDevice; // - yarp::dev::ICanBus* iCanBus; - yarp::dev::ICanBufferFactory* iCanBufferFactory; - yarp::dev::CanBuffer canInputBuffer; - - /** CAN node object. */ - yarp::dev::PolyDriver canNodeDevice; - yarp::dev::IControlLimitsRaw* iControlLimitsRaw; - yarp::dev::IControlModeRaw* iControlModeRaw; - yarp::dev::IEncodersTimedRaw* iEncodersTimedRaw; - yarp::dev::IPositionControlRaw* iPositionControlRaw; - yarp::dev::IPositionDirectRaw* iPositionDirectRaw; - yarp::dev::ITorqueControlRaw* iTorqueControlRaw; - yarp::dev::IVelocityControlRaw* iVelocityControlRaw; - ICanBusSharer* iCanBusSharer; // -- ?? - ITechnosoftIpos* technosoftIpos; - - /** Function definitions **/ - std::string msgToStr(const yarp::dev::CanMessage & message) - { - std::stringstream tmp; - for(int i=0; i < message.getLen()-1; i++) - { - tmp << std::hex << static_cast(message.getData()[i]) << " "; - } - tmp << std::hex << static_cast(message.getData()[message.getLen()-1]); - tmp << ". canId("; - tmp << std::dec << (message.getId() & 0x7F); - tmp << ") via("; - tmp << std::hex << (message.getId() & 0xFF80); - tmp << ")."; - return tmp.str(); - } -}; - -/* -TEST_F( TechnosoftIposTest, TechnosoftIposGetPresencewithReset) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - int ret = 0; - - // -- doing reset of node after delay - yarp::os::Time::delay(1); - technosoftIpos->resetNode(canId); - - - //-- Blocking read until we get a message from the expected canId - CD_INFO("Blocking read until we get a message from the expected canId...\n"); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ){ - //technosoftIpos->resetCommunication(); - //yarp::os::Time::delay(0.3); - - //technosoftIpos->resetNode(); - //yarp::os::Time::delay(10); - continue; - } - // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - //CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - } - //-- Assert the message is of "indicating presence" type. - ASSERT_EQ(buffer.id-canId , 0x700); -} -*/ - -/* -TEST_F( TechnosoftIposTest, TechnosoftIposGetPresence) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - int ret = 0; - //-- Blocking read until we get a message from the expected canId - CD_INFO("Blocking read until we get a message from the expected canId...\n"); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - //CD_DEBUG("Read ok from %d\n", canId); - } - //-- Assert the message is of "indicating presence" type. - ASSERT_EQ(buffer.id-canId , 0x700); -} -*/ -/************************************************************************************ - ************** Test of seting initial parameters on physical motor drivers ********* - ************************************************************************************/ -// -- Set Ref Aceleration Raw -// idea: getControlMode (Juan) - -TEST_F( TechnosoftIposTest, TechnosoftIposSetRefAccelerationRaw ) -{ - int canId = 0; - int ret = 0; - - yarp::os::Time::delay(1); - //-- Set initial parameter on physical motor driver. - // --( implemented in Technosoftipos->IPositionControlRawImpl.cpp) - bool ok = iPositionControlRaw->setRefAccelerationRaw( 0, 0.575 ); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - yarp::dev::CanMessage &msg = canInputBuffer[0]; - - while ( canId != CAN_ID ) // -- it will check the ID - { - unsigned int read; - bool ok = iCanBus->canRead(canInputBuffer, 1, &read, true); - if( !ok || read == 0 ) continue; // -- is waiting for recive message - canId = msg.getId() & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(msg).c_str()); - - //-- Print interpretation of message - iCanBusSharer->interpretMessage(msg); // without ASSERT (we don't need assert interpretMessage function) - - // Manual 8.2.3. 6083h: Profile acceleration (SDO ack \"posmode_acc\" from driver) - ASSERT_EQ(msg.getData()[0] , 0x60); //-- ?? - ASSERT_EQ(msg.getData()[1] , 0x83); //-- 83 - ASSERT_EQ(msg.getData()[2] , 0x60); //-- 60 - - -} - -/* - - -// -- Set Ref Speed Raw - -TEST_F( TechnosoftIposTest, TechnosoftIposSetRefSpeedRaw ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = iPositionControlRaw->setRefSpeedRaw( 0, 5.0 ); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - // Manual 8.2.2. 6083h: Profile velocity (SDO ack \"posmode_acc\" from driver) - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x81); //-- 81 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) -} - -// -- Set Minimum Limits Raw -TEST_F( TechnosoftIposTest, TechnosoftIposSetMinLimitsRaw ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->setMinLimitRaw(-45); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - // Manual 8.2.2. 6083h: Profile (SDO ack \"posmode_acc\" from driver) - // Index: 607D - // Subindex: (0)-Number of entries - // (1)-Minimal position limit - // (2)-Maximal position limit - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x7d); //-- 76 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 - ASSERT_EQ(buffer.data[3] , 0x01); //-- 01 -> min - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) -} - -// -- Set Maximum Limits Raw -TEST_F( TechnosoftIposTest, TechnosoftIposSetMaxLimitsRaw ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->setMaxLimitRaw(70); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - // Manual 8.2.2. 6083h: Profile (SDO ack \"posmode_acc\" from driver) - // Index: 607D - // Subindex: (0)-Number of entries - // (1)-Minimal position limit - // (2)-Maximal position limit - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x7d); //-- 76 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 - ASSERT_EQ(buffer.data[3] , 0x02); //-- 02 -> max - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) -} -*/ - -/************************************************************************************ - **************** Test of seting all motor drivers to differents mode *************** - ************************************************************************************/ -/* -//-- Set Velocity Mode - -TEST_F( TechnosoftIposTest, TechnosoftIposSetVelocityMode ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = iControlModeRaw->setVelocityModeRaw(0); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - // -- Manual 5.2.5. Object 6060h/6061h: Modes of Operation Display (SDO ack \"modes of operation display\" from driver) - // The object reflects the actual mode of operation set with object Modes of Operation (index 6060 h ) - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) - -} - -// -- Set Torque Mode -TEST_F( TechnosoftIposTest, TechnosoftIposSetTorqueMode ) -{ - int canId = 0; - int ret = 0; - bool ok = true; - - //-- Segment (1) of setTorqueMode - ok &= technosoftIpos->setTorqueModeRaw1(); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - // Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) - // ASSERTS of message 1 - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x1d); //-- 1d - ASSERT_EQ(buffer.data[2] , 0x20); //-- 20 - - //-- Segment (2) of setTorqueMode - ok &= technosoftIpos->setTorqueModeRaw2(); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - // Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) - // ASSERTS of message 2 - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x1d); //-- 1d - ASSERT_EQ(buffer.data[2] , 0x20); //-- 20 - - //-- Segment (3) of setTorqueMode - ok &= technosoftIpos->setTorqueModeRaw3(); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) - - // -- Manual 11.2.6. Object 201Dh: External Reference Type - // This object is used to set the type of external reference for use with electronic gearing position, - // electronic camming position, position external, speed external and torque external modes. - // ASSERTS of message 3 - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x1d); //-- 1d - ASSERT_EQ(buffer.data[2] , 0x20); //-- 20 -} - -// -- Set Position Mode -TEST_F( TechnosoftIposTest, TechnosoftIposSetPositionMode ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = iControlModeRaw->setPositionModeRaw(0); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); // without ASSERT (we don't need assert interpretMessage function) - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} -*/ -/************************************************************************************* - ****************************** Get Controls Mode Raw ******************************** - ************************************************************************************/ -/* -// -- get control mode raw [1] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_1_1 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw1() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - - -// -- get control mode raw [2] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_1_2 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw2() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - ASSERT_EQ(buffer.data[0] , 0x4f); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x61); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [3] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_1_3 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw3() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [4] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_1_4 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw4() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} -*/ -/************************************************************************************* - **************************** Initialization test drivers **************************** - ************************************************************************************/ - -//-- Check the status of each driver. -//std::vector tmp( nodes.size() ); // -- creating a "tmp"vector with "nodes" vector size -//this->getControlModes( tmp.data() ); - -//-- Test of: START REMOTE NODE -/* -TEST_F( TechnosoftIposTest, TechnosoftIposStart) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - int ret = 0; - - bool ok = iCanBusSharer->start(); // -- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_INFO_NO_HEADER("\n~~~~~~~~~~~~~~~~~~ TechnosoftIposStart ~~~~~~~~~~~~~~~~~~~~ \n\n"); - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Got PDO1 that it is observed as TRANSITION performed upon \"start\" - //ASSERT_EQ(buffer.data[0] , 0x40); - //ASSERT_EQ(buffer.data[1] , 0x02); -} -*/ -/************************************************************************************* - ****************************** Get Controls Mode Raw ******************************** - ************************************************************************************/ -/* -// -- get control mode raw [1] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_2_1 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw1() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [2] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_2_2 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw2() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - ASSERT_EQ(buffer.data[0] , 0x4f); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x61); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [3] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_2_3 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw3() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [4] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_2_4 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw4() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - - -//-- Test of READY TO SWITCH ON REMOTE NODE (with delay 0.1) - -TEST_F( TechnosoftIposTest, TechnosoftIposReadyToSwitchOn) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - int ret = 0; - - yarp::os::Time::delay(0.1); // -- delay 100 [ms] - bool ok = iCanBusSharer->readyToSwitchOn(); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_INFO_NO_HEADER("\n~~~~~~~~~~~~~~~~~~ TechnosoftIposReadyToSwitchOn ~~~~~~~~~~~~~~~~~~~~ \n\n"); - - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- - //ASSERT_EQ(buffer.data[0] , 0x40); - //ASSERT_EQ(buffer.data[1] , 0x02); -} -*/ -/************************************************************************************* - ****************************** Get Controls Mode Raw ******************************** - ************************************************************************************/ -/* -// -- get control mode raw [1] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_3_1 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw1() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [2] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_3_2 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw2() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - ASSERT_EQ(buffer.data[0] , 0x4f); //-- ?? - ASSERT_EQ(buffer.data[1] , 0x61); //-- 60 - ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [3] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_3_3 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw3() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [4] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_3_4 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw4() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -//-- Test of SWITCH ON REMOTE NODE (with delay 0.1) -TEST_F( TechnosoftIposTest, TechnosoftIposSwitchOn) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - int ret = 0; - - yarp::os::Time::delay(0.1); // -- delay 100 [ms] - bool ok = iCanBusSharer->switchOn(); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_INFO_NO_HEADER("\n~~~~~~~~~~~~~~~~~~ TechnosoftIposSwitchOn ~~~~~~~~~~~~~~~~~~~~ \n\n"); - - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- - //ASSERT_EQ(buffer.data[0] , 0x40); - //ASSERT_EQ(buffer.data[1] , 0x02); -} -*/ -/************************************************************************************* - ****************************** Get Controls Mode Raw ******************************** - ************************************************************************************/ -/* -// -- get control mode raw [1] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_4_1 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw1() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [2] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_4_2 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw2() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x4f); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x61); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [3] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_4_3 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw3() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [4] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_4_4 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw4() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - - -//-- Test of ENABLE REMOTE NODE (with delay 0.2) -TEST_F( TechnosoftIposTest, TechnosoftIposEnable) // -- we call the class that we want to do the test and we assign it a name -{ - int canId = 0; - int ret = 0; - - yarp::os::Time::delay(0.2); // -- delay 200 [ms] - bool ok = iCanBusSharer->enable(); //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_INFO_NO_HEADER("\n~~~~~~~~~~~~~~~~~~ TechnosoftIposiposEnable ~~~~~~~~~~~~~~~~~~~~ \n\n"); - - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- - //ASSERT_EQ(buffer.data[0] , 0x40); - //ASSERT_EQ(buffer.data[1] , 0x02); -} -*/ - -/************************************************************************************* - ****************************** Get Controls Mode Raw ******************************** - ************************************************************************************/ -/* -// -- get control mode raw [1] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_5_1 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw1() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [2] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_5_2 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw2() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x4f); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x61); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [3] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_5_3 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw3() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual ?? - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} - -// -- get control mode raw [4] -TEST_F( TechnosoftIposTest, TechnosoftIposGetControlModeRaw_5_4 ) -{ - int canId = 0; - int ret = 0; - - //-- Set initial parameter on physical motor driver. - bool ok = technosoftIpos->getControlModeRaw4() ; //-- ok corresponds to send (not read) - ASSERT_TRUE( ok ); - - while ( canId != CAN_ID ) // -- it will check the ID - { - ret = iCanBus->read_timeout(&buffer,1); // -- return value of message with timeout of 1 [ms] - if( ret <= 0 ) continue; // -- is waiting for recive message - canId = buffer.id & 0x7F; // -- if it recive the message, it will get ID - } - CD_DEBUG("Read: %s\n", msgToStr(&buffer).c_str()); - - //-- Print interpretation of message - technosoftIpos->interpretMessage(&buffer); - - // -- Manual 5.2.4. Object 6060h: Modes of Operation (SDO ack \"posmode_acc\" from driver) - //ASSERT_EQ(buffer.data[0] , 0x60); //-- ?? - //ASSERT_EQ(buffer.data[1] , 0x60); //-- 60 - //ASSERT_EQ(buffer.data[2] , 0x60); //-- 60 -} -*/ -} // namespace roboticslab From e5602f43e9b7585c040a20dd220c697c500c592c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 22 Dec 2019 19:31:39 +0100 Subject: [PATCH 5/6] Don't attempt to pass empty variables to yarp_install --- share/CMakeLists.txt | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 879b95938..6f711ce4f 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -2,26 +2,20 @@ # Author: Juan G Victores and Raul de Santos Rico # CopyPolicy: Released under the terms of the GNU GPL v2.0 -set(applications) -set(contexts) - if(ENABLE_dumpCanBus) - list(APPEND contexts contexts/dumpCanBus) + yarp_install(DIRECTORY contexts/dumpCanBus + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) endif() if(ENABLE_launchCanBus) - list(APPEND contexts contexts/launchCanBus) + yarp_install(DIRECTORY contexts/launchCanBus + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) endif() if(ENABLE_SpaceNavigator) - list(APPEND applications applications/yarpmanager/spaceNavigator) + yarp_install(DIRECTORY applications/yarpmanager/spaceNavigator + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}/yarpmanager) endif() yarp_install(FILES applications/yarpmanager/ymanager.ini DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}/yarpmanager) - -yarp_install(DIRECTORY ${applications} - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}/yarpmanager) - -yarp_install(DIRECTORY ${contexts} - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) From 2a6b4557d986d365796689f9fad0d17d3c8de895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 22 Dec 2019 20:10:38 +0100 Subject: [PATCH 6/6] Delete launchCanBus template/stub .ini files This app depends on a robot-specific config.ini. Users should take a look at available launcher .inis within a -configuration-files repository of their choice and adapt them to their needs, then reuse or add additional descriptor files to the robots/ tree loaded by config.ini. --- share/CMakeLists.txt | 5 -- .../oneCanBusOneWrapper-CuiAbsolute.ini | 23 -------- .../oneCanBusOneWrapper-left-arm.ini | 24 -------- .../oneCanBusOneWrapper-right-arm.ini | 24 -------- .../launchCanBus/oneCanBusOneWrapper.ini | 23 -------- .../launchCanBus/twoCanBusThreeWrappers.ini | 56 ------------------- 6 files changed, 155 deletions(-) delete mode 100644 share/contexts/launchCanBus/oneCanBusOneWrapper-CuiAbsolute.ini delete mode 100644 share/contexts/launchCanBus/oneCanBusOneWrapper-left-arm.ini delete mode 100644 share/contexts/launchCanBus/oneCanBusOneWrapper-right-arm.ini delete mode 100644 share/contexts/launchCanBus/oneCanBusOneWrapper.ini delete mode 100644 share/contexts/launchCanBus/twoCanBusThreeWrappers.ini diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 6f711ce4f..0b97823b1 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -7,11 +7,6 @@ if(ENABLE_dumpCanBus) DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) endif() -if(ENABLE_launchCanBus) - yarp_install(DIRECTORY contexts/launchCanBus - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) -endif() - if(ENABLE_SpaceNavigator) yarp_install(DIRECTORY applications/yarpmanager/spaceNavigator DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}/yarpmanager) diff --git a/share/contexts/launchCanBus/oneCanBusOneWrapper-CuiAbsolute.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper-CuiAbsolute.ini deleted file mode 100644 index dd8a0fc9e..000000000 --- a/share/contexts/launchCanBus/oneCanBusOneWrapper-CuiAbsolute.ini +++ /dev/null @@ -1,23 +0,0 @@ -/// oneCanBusOneWrapper-CuiAbsolute.ini /// - -[devCan0] -device CanBusControlboard -canDevice /dev/pcan3 -canBusType CanBusPeak -canBitrate 1000000 -types TechnosoftIpos CuiAbsolute -ids 24 124 -maxs 100 0 -mins -10 0 -trs 160 0 -refAccelerations 0.575437 0.0 -refSpeeds 5.0 0.0 -encoderPulsess 4096 4096 - -[wrapper0] -device controlboardwrapper2 -name /wrapper0 -period 60 -joints 1 -networks (devCan0) -devCan0 0 0 0 0 diff --git a/share/contexts/launchCanBus/oneCanBusOneWrapper-left-arm.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper-left-arm.ini deleted file mode 100644 index ea3cdb237..000000000 --- a/share/contexts/launchCanBus/oneCanBusOneWrapper-left-arm.ini +++ /dev/null @@ -1,24 +0,0 @@ -/// launchManipulation.ini /// - -[devCan0] -device CanBusControlboard -canDevice /dev/pcan3 -canBusType CanBusPeak -types TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos LacqueyFetch CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute -ids 27 21 22 23 24 25 26 64 121 122 123 124 125 126 -maxs 60 87.6 74.5 54.7 14.1 101.3 59.8 1200 0 0 0 0 0 0 -mins -60 -93.5 -29.2 -82.5 -101.1 -76.4 -103.9 -1200 0 0 0 0 0 0 -maxVels 10 10 10 10 10 10 10 1000 0 0 0 0 0 0 -trs 100 160 160 100 160 100 100 0 1 1 1 1 1 1 -ks 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0 0 0 0 0 0 0 -refAccelerations 10.0 10.0 10.0 10.0 10.0 10.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -refSpeeds 10.0 10.0 10.0 10.0 10.0 10.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -encoderPulsess 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 - -[wrapper0] -device controlboardwrapper2 -name /teo/leftArm -period 60 -joints 7 -networks (devCan0) -devCan0 0 6 1 7 diff --git a/share/contexts/launchCanBus/oneCanBusOneWrapper-right-arm.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper-right-arm.ini deleted file mode 100644 index c01713e06..000000000 --- a/share/contexts/launchCanBus/oneCanBusOneWrapper-right-arm.ini +++ /dev/null @@ -1,24 +0,0 @@ -/// launchManipulation.ini /// - -[devCan0] -device CanBusControlboard -canDevice /dev/pcan2 -canBusType CanBusPeak -types TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos LacqueyFetch CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute -ids 28 15 16 17 18 19 20 65 115 116 117 118 119 120 -maxs 10 98.1 29.6 80.1 83.5 76.8 107.5 1200 0 0 0 0 0 0 -mins -10 -88.5 -75.5 -57.0 -32.9 -99.6 -56.9 -1200 0 0 0 0 0 0 -maxVels 10 10 10 10 10 10 10 1000 0 0 0 0 0 0 -trs 100 160 160 100 160 100 100 0 1 1 1 1 1 1 -ks 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0 0 0 0 0 0 0 -refAccelerations 10.0 10.0 10.0 10.0 10.0 10.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -refSpeeds 10.0 10.0 10.0 10.0 10.0 10.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -encoderPulsess 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 - -[wrapper0] -device controlboardwrapper2 -name /teo/rightArm -period 60 -joints 7 -networks (devCan0) -devCan0 0 6 1 7 diff --git a/share/contexts/launchCanBus/oneCanBusOneWrapper.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper.ini deleted file mode 100644 index 760d66591..000000000 --- a/share/contexts/launchCanBus/oneCanBusOneWrapper.ini +++ /dev/null @@ -1,23 +0,0 @@ -/// oneCanBusOneWrapper.ini /// - -[devCan0] -device CanBusControlboard -canDevice /dev/pcan0 -canBusType CanBusPeak -canBitrate 1000000 -types TechnosoftIpos -ids 1 -maxs 90 -mins -90 -trs 100 -refAccelerations 0.575437 -refSpeeds 5.0 -encoderPulsess 4096 - -[wrapper0] -device controlboardwrapper2 -name /wrapper0 -period 60 -joints 1 -networks (devCan0) -devCan0 0 0 0 0 diff --git a/share/contexts/launchCanBus/twoCanBusThreeWrappers.ini b/share/contexts/launchCanBus/twoCanBusThreeWrappers.ini deleted file mode 100644 index 1a42af431..000000000 --- a/share/contexts/launchCanBus/twoCanBusThreeWrappers.ini +++ /dev/null @@ -1,56 +0,0 @@ -/// twoCanBusThreeWrappers.ini /// - -[devCan0] -device CanBusControlboard -canDevice /dev/pcan2 -canBusType CanBusPeak -types TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos LacqueyFetch CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute -ids 28 15 16 17 18 19 20 65 115 116 117 118 119 120 -maxs 10 106.0 22.4 57.0 98.4 99.6 44.7 1200 0 0 0 0 0 0 -mins -10 -98.1 -75.5 -80.1 -99.6 -80.4 -115.1 -1200 0 0 0 0 0 0 -maxVels 50 50 50 50 50 50 50 1000 0 0 0 0 0 0 -trs 100 -160 160 -100 -160 -100 -100 0 -1 1 -1 -1 -1 -1 -ks 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0 0 0 0 0 0 0 -refAccelerations 10 10 10 10 10 10 10 0 0 0 0 0 0 0 -refSpeeds 10 10 10 10 10 10 10 0 0 0 0 0 0 0 -encoderPulsess 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 - -[devCan1] -device CanBusControlboard -canDevice /dev/pcan3 -canBusType CanBusPeak -types TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos TechnosoftIpos LacqueyFetch CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute CuiAbsolute -ids 27 21 22 23 24 25 26 64 121 122 123 124 125 126 -maxs 60 113.2 76.5 84.1 96.8 76.4 61.3 1200 0 0 0 0 0 0 -mins -60 -96.8 -23.9 -51.6 -101.1 -101.3 -113.3 -1200 0 0 0 0 0 0 -maxVels 50 50 50 50 50 50 50 1000 0 0 0 0 0 0 -trs 100 160 160 -100 160 -100 100 0 1 1 -1 1 -1 1 -ks 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0.0706 0 0 0 0 0 0 0 -refAccelerations 10 10 10 10 10 10 10 0 0 0 0 0 0 0 -refSpeeds 10 10 10 10 10 10 10 0 0 0 0 0 0 0 -encoderPulsess 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 - -[wrapper0] -device controlboardwrapper2 -name /teo/rightArm -period 60 -joints 7 -networks (devCan0) -devCan0 0 6 1 7 - -[wrapper1] -device controlboardwrapper2 -name /teo/leftArm -period 60 -joints 7 -networks (devCan1) -devCan1 0 6 1 7 - -[wrapper2] -device controlboardwrapper2 -name /teo/head -period 60 -joints 2 -networks (devCan1 devCan0) -devCan1 0 0 0 0 -devCan0 1 1 0 0