From da49e9edbd5389aa6f62d5a1b3a3b7a7ca547419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 24 Nov 2019 18:53:08 +0100 Subject: [PATCH 01/12] Rework launch .ini parser --- programs/launchCanBus/LaunchCanBus.cpp | 160 +++++++++++-------------- 1 file changed, 69 insertions(+), 91 deletions(-) diff --git a/programs/launchCanBus/LaunchCanBus.cpp b/programs/launchCanBus/LaunchCanBus.cpp index 9d1835bea..2793f9cbf 100644 --- a/programs/launchCanBus/LaunchCanBus.cpp +++ b/programs/launchCanBus/LaunchCanBus.cpp @@ -36,100 +36,67 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) yarp::conf::vocab32_t mode = rf.check("mode", yarp::os::Value(VOCAB_CM_POSITION), "initial mode of operation").asVocab(); bool homing = rf.check("home", yarp::os::Value(false), "perform initial homing procedure").asBool(); - const std::string canDevicePrefix = "devCan"; - int canDeviceId = 0; + yarp::os::Bottle devCan = rf.findGroup("devCan", "CAN controlboard devices").tail(); + yarp::os::Bottle wrapper = rf.findGroup("wrapper", "YARP wrappers devices").tail(); - while (true) + if (devCan.isNull() || devCan.size() == 0) { - std::string canDeviceLabel = canDevicePrefix + std::to_string(canDeviceId); - - yarp::os::Bottle canDeviceGroup = rf.findGroup(canDeviceLabel); - - if (canDeviceGroup.isNull()) - { - break; - } - - CD_DEBUG("%s\n", canDeviceGroup.toString().c_str()); - - yarp::os::Property canDeviceOptions; - canDeviceOptions.fromString(canDeviceGroup.toString()); - canDeviceOptions.put("home", homing); - - yarp::dev::PolyDriver * canDevice = new yarp::dev::PolyDriver(canDeviceOptions); - - if (!canDevice->isValid()) - { - CD_ERROR("CAN device %s instantiation failure.\n", canDeviceLabel.c_str()); - return false; - } - - canDevices.push(canDevice, canDeviceLabel.c_str()); - canDeviceId++; + CD_ERROR("Missing or empty \"devCan\" section collection.\n"); + return false; } - if (canDeviceId == 0) + if (wrapper.isNull() || wrapper.size() == 0) { - CD_ERROR("Empty CAN device list.\n"); + CD_ERROR("Missing or empty \"wrapper\" section collection.\n"); return false; } - const std::string calibratorDevicePrefix = "calibrator"; - int calibratorDeviceId = 0; + // CAN devices - while (true) + for (int i = 0; i < devCan.size(); i++) { - std::string calibratorDeviceLabel = calibratorDevicePrefix + std::to_string(calibratorDeviceId); - yarp::os::Bottle calibratorDeviceGroup = rf.findGroup(calibratorDeviceLabel); - - if (calibratorDeviceGroup.isNull()) - { - break; - } - - CD_DEBUG("%s\n", calibratorDeviceGroup.toString().c_str()); + std::string canDeviceLabel = devCan.get(i).asString(); + const yarp::os::Bottle & canDeviceGroup = rf.findGroup(canDeviceLabel); - yarp::os::Property calibratorDeviceOptions; - calibratorDeviceOptions.fromString(calibratorDeviceGroup.toString()); - - yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver(calibratorDeviceOptions); - - if (!calibratorDevice->isValid()) + if (canDeviceGroup.isNull()) { - CD_ERROR("Calibrator device %s instantiation failure.\n", calibratorDeviceLabel.c_str()); + CD_ERROR("Missing CAN device group %s.\n", canDeviceLabel.c_str()); return false; } - yarp::dev::IRemoteCalibrator * iRemoteCalibrator; + yarp::os::Property canDeviceOptions; + canDeviceOptions.fromString(canDeviceGroup.toString()); + canDeviceOptions.put("home", homing); + + yarp::dev::PolyDriver * canDevice = new yarp::dev::PolyDriver(canDeviceOptions); + canDevices.push(canDevice, canDeviceLabel.c_str()); - if (!calibratorDevice->view(iRemoteCalibrator)) + if (!canDevice->isValid()) { - CD_ERROR("Unable to view IRemoteCalibrator in %s.\n", calibratorDeviceLabel.c_str()); + CD_ERROR("CAN device %s instantiation failure.\n", canDeviceLabel.c_str()); return false; } - - calibratorDevices.push(calibratorDevice, "calibrator"); // key value enforced by CBW2.attachAll() } - const std::string wrapperDevicePrefix = "wrapper"; - int wrapperDeviceId = 0; + // network wrappers - while (true) + for (int i = 0; i < wrapper.size(); i++) { - std::string wrapperDeviceLabel = wrapperDevicePrefix + std::to_string(wrapperDeviceId); - yarp::os::Bottle wrapperDeviceGroup = rf.findGroup(wrapperDeviceLabel); + std::string wrapperDeviceLabel = wrapper.get(i).asString(); + const yarp::os::Bottle & wrapperDeviceGroup = rf.findGroup(wrapperDeviceLabel); if (wrapperDeviceGroup.isNull()) { - break; + CD_ERROR("Missing wrapper device group %s.\n", wrapperDeviceLabel.c_str()); + return false; } - CD_DEBUG("%s\n", wrapperDeviceGroup.toString().c_str()); - yarp::os::Property wrapperDeviceOptions; wrapperDeviceOptions.fromString(wrapperDeviceGroup.toString()); + wrapperDeviceOptions.unput("calibrator"); // custom property added by us yarp::dev::PolyDriver * wrapperDevice = new yarp::dev::PolyDriver(wrapperDeviceOptions); + wrapperDevices.push(wrapperDevice, wrapperDeviceLabel.c_str()); if (!wrapperDevice->isValid()) { @@ -137,8 +104,6 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) return false; } - wrapperDevices.push(wrapperDevice, wrapperDeviceLabel.c_str()); - yarp::dev::IMultipleWrapper * iMultipleWrapper; if (!wrapperDevice->view(iMultipleWrapper)) @@ -150,14 +115,42 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) yarp::dev::PolyDriverList temp; temp = canDevices; - if (calibratorDevices.size() - 1 >= wrapperDeviceId) + std::string calibratorDeviceLabel = wrapperDeviceGroup.find("calibrator").asString(); + + if (!calibratorDeviceLabel.empty()) { - yarp::dev::PolyDriver * calibratorDevice = calibratorDevices[wrapperDeviceId]->poly; + std::string calibratorFilePath = rf.findFileByName("calibrators/" + calibratorDeviceLabel + ".ini"); + yarp::os::Property calibratorDeviceOptions; + + if (!calibratorDeviceOptions.fromConfigFile(calibratorFilePath)) + { + CD_ERROR("File %s does not exist or unsufficient permissions.\n", calibratorFilePath.c_str()); + return false; + } + + yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver(calibratorDeviceOptions); + yarp::dev::PolyDriverDescriptor descriptor(calibratorDevice, "calibrator"); // key name enforced by CBW2::attachAll() + calibratorDevices.push(descriptor); + + if (!calibratorDevice->isValid()) + { + CD_ERROR("Calibrator device %s instantiation failure.\n", calibratorDeviceLabel.c_str()); + return false; + } + + yarp::dev::IRemoteCalibrator * iRemoteCalibrator; + + if (!calibratorDevice->view(iRemoteCalibrator)) + { + CD_ERROR("Unable to view IRemoteCalibrator in calibrator device %s.\n", calibratorDeviceLabel.c_str()); + return false; + } + yarp::dev::IWrapper * iWrapper; if (!calibratorDevice->view(iWrapper)) { - CD_ERROR("Unable to view IWrapper in calibrator device.\n"); + CD_ERROR("Unable to view IWrapper in calibrator device %s.\n", calibratorDeviceLabel.c_str()); return false; } @@ -167,7 +160,7 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) return false; } - temp.push(*calibratorDevices[wrapperDeviceId]); + temp.push(descriptor); } if (!iMultipleWrapper->attachAll(temp)) @@ -175,21 +168,9 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) CD_ERROR("Unable to attach wrapper %s to CAN devices.\n", wrapperDeviceLabel.c_str()); return false; } - - wrapperDeviceId++; } - if (wrapperDeviceId == 0) - { - CD_ERROR("Empty wrapper device list.\n"); - return false; - } - - if (calibratorDeviceId != 0 && wrapperDeviceId != calibratorDeviceId) - { - CD_ERROR("Unbalanced number of wrapper devices (%d) and calibrators (%d).\n", wrapperDeviceId, calibratorDeviceId); - return false; - } + // initial control modes for (int i = 0; i < canDevices.size(); i++) { @@ -227,17 +208,14 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) CD_SUCCESS("Set %s mode in %s.\n", yarp::os::Vocab::decode(mode).c_str(), canDevices[i]->key.c_str()); } + // homing on start + if (homing) { for (int i = 0; i < calibratorDevices.size(); i++) { yarp::dev::IRemoteCalibrator * iRemoteCalibrator; - - if (!calibratorDevices[i]->poly->view(iRemoteCalibrator)) - { - CD_ERROR("Unable to view IRemoteCalibrator in %s.\n", calibratorDevices[i]->key.c_str()); - return false; - } + calibratorDevices[i]->poly->view(iRemoteCalibrator); if (!iRemoteCalibrator->homingWholePart()) { @@ -268,14 +246,14 @@ double LaunchCanBus::getPeriod() bool LaunchCanBus::close() { - for (int i = 0; i < wrapperDevices.size(); i++) + for (int i = 0; i < calibratorDevices.size(); i++) { - delete wrapperDevices[i]->poly; + delete calibratorDevices[i]->poly; } - for (int i = 0; i < calibratorDevices.size(); i++) + for (int i = 0; i < wrapperDevices.size(); i++) { - delete calibratorDevices[i]->poly; + delete wrapperDevices[i]->poly; } for (int i = 0; i < canDevices.size(); i++) From 790818e29f5de779a489dc9bd9552ecde15c39de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Fri, 8 Nov 2019 18:54:08 +0100 Subject: [PATCH 02/12] Upload random stuff, very much WIP --- share/CMakeLists.txt | 7 ++++++- share/drivers/CMakeLists.txt | 4 ++++ share/drivers/ipos-3602-mx.ini | 4 ++++ share/drivers/ipos-3604-mx.ini | 4 ++++ share/drivers/ipos-4808-mx.ini | 4 ++++ share/encoders/CMakeLists.txt | 2 ++ share/encoders/cui-amt-203-v.ini | 4 ++++ share/motors/CMakeLists.txt | 2 ++ share/transmissions/CMakeLists.txt | 3 +++ share/transmissions/hd-100.ini | 4 ++++ share/transmissions/hd-160.ini | 4 ++++ 11 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 share/drivers/CMakeLists.txt create mode 100644 share/drivers/ipos-3602-mx.ini create mode 100644 share/drivers/ipos-3604-mx.ini create mode 100644 share/drivers/ipos-4808-mx.ini create mode 100644 share/encoders/CMakeLists.txt create mode 100644 share/encoders/cui-amt-203-v.ini create mode 100644 share/motors/CMakeLists.txt create mode 100644 share/transmissions/CMakeLists.txt create mode 100644 share/transmissions/hd-100.ini create mode 100644 share/transmissions/hd-160.ini diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index cc2eb7944..3c6f5d91c 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright: 2017 UC3M +# Copyright: 2019 UC3M # Author: Juan G Victores and Raul de Santos Rico # CopyPolicy: Released under the terms of the GNU GPL v2.0. @@ -26,3 +26,8 @@ endif() if(ENABLE_tests) add_subdirectory(testCuiAbsolute) endif() + +add_subdirectory(drivers) +add_subdirectory(encoders) +add_subdirectory(motors) +add_subdirectory(transmissions) diff --git a/share/drivers/CMakeLists.txt b/share/drivers/CMakeLists.txt new file mode 100644 index 000000000..104cb7172 --- /dev/null +++ b/share/drivers/CMakeLists.txt @@ -0,0 +1,4 @@ +yarp_install(FILES ipos-3602-mx.ini + ipos-3604-mx.ini + ipos-4808-mx.ini + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/drivers) diff --git a/share/drivers/ipos-3602-mx.ini b/share/drivers/ipos-3602-mx.ini new file mode 100644 index 000000000..c1eb9c30c --- /dev/null +++ b/share/drivers/ipos-3602-mx.ini @@ -0,0 +1,4 @@ +// ipos-3602-mx.ini +name "ipos-3602-mx" +description "iPOS3602 MX Intelligent Drive (75 W, CANopen / EtherCAT)" +maxCurrent 3.2 diff --git a/share/drivers/ipos-3604-mx.ini b/share/drivers/ipos-3604-mx.ini new file mode 100644 index 000000000..a21a20bdc --- /dev/null +++ b/share/drivers/ipos-3604-mx.ini @@ -0,0 +1,4 @@ +// ipos-3604-mx.ini +name "ipos-3604-mx" +description "iPOS3604 MX Intelligent Drive (144 W, CANopen / EtherCAT)" +maxCurrent 10.0 diff --git a/share/drivers/ipos-4808-mx.ini b/share/drivers/ipos-4808-mx.ini new file mode 100644 index 000000000..405ad41aa --- /dev/null +++ b/share/drivers/ipos-4808-mx.ini @@ -0,0 +1,4 @@ +// ipos-4808-mx.ini +name "ipos-4808-mx" +description "iPOS4808 MX Intelligent Drive (400 W, CANopen / EtherCAT)" +maxCurrent 20.0 diff --git a/share/encoders/CMakeLists.txt b/share/encoders/CMakeLists.txt new file mode 100644 index 000000000..66a360df6 --- /dev/null +++ b/share/encoders/CMakeLists.txt @@ -0,0 +1,2 @@ +yarp_install(FILES cui-amt-203-v.ini + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/encoders) diff --git a/share/encoders/cui-amt-203-v.ini b/share/encoders/cui-amt-203-v.ini new file mode 100644 index 000000000..57807befd --- /dev/null +++ b/share/encoders/cui-amt-203-v.ini @@ -0,0 +1,4 @@ +// cui-amt-203-v.ini +name "cui-amt-203-v" +description "CUI encoder" +encoderPulses 4096 diff --git a/share/motors/CMakeLists.txt b/share/motors/CMakeLists.txt new file mode 100644 index 000000000..b0780367b --- /dev/null +++ b/share/motors/CMakeLists.txt @@ -0,0 +1,2 @@ +yarp_install(FILES "" + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/motors) diff --git a/share/transmissions/CMakeLists.txt b/share/transmissions/CMakeLists.txt new file mode 100644 index 000000000..458afa384 --- /dev/null +++ b/share/transmissions/CMakeLists.txt @@ -0,0 +1,3 @@ +yarp_install(FILES hd-100.ini + hd-160.ini + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/transmissions) diff --git a/share/transmissions/hd-100.ini b/share/transmissions/hd-100.ini new file mode 100644 index 000000000..d6e627525 --- /dev/null +++ b/share/transmissions/hd-100.ini @@ -0,0 +1,4 @@ +// hd-100.ini +name "hd-100" +description "Harmonic Drive 100" +tr 100.0 diff --git a/share/transmissions/hd-160.ini b/share/transmissions/hd-160.ini new file mode 100644 index 000000000..0c6255d73 --- /dev/null +++ b/share/transmissions/hd-160.ini @@ -0,0 +1,4 @@ +// hd-160.ini +name "hd-160" +description "Harmonic Drive 160" +tr 160.0 From 8bf33a2c7d67bc7b6de821302863eadb885124a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Fri, 15 Nov 2019 19:45:22 +0100 Subject: [PATCH 03/12] Add motors --- share/motors/CMakeLists.txt | 6 +++++- share/motors/maxon-251601.ini | 6 ++++++ share/motors/maxon-339282.ini | 6 ++++++ share/motors/maxon-339287.ini | 6 ++++++ share/motors/maxon-402686.ini | 6 ++++++ share/motors/maxon-411815.ini | 6 ++++++ 6 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 share/motors/maxon-251601.ini create mode 100644 share/motors/maxon-339282.ini create mode 100644 share/motors/maxon-339287.ini create mode 100644 share/motors/maxon-402686.ini create mode 100644 share/motors/maxon-411815.ini diff --git a/share/motors/CMakeLists.txt b/share/motors/CMakeLists.txt index b0780367b..82d5ad566 100644 --- a/share/motors/CMakeLists.txt +++ b/share/motors/CMakeLists.txt @@ -1,2 +1,6 @@ -yarp_install(FILES "" +yarp_install(FILES maxon-251601.ini + maxon-339282.ini + maxon-339287.ini + maxon-402686.ini + maxon-411815.ini DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/motors) diff --git a/share/motors/maxon-251601.ini b/share/motors/maxon-251601.ini new file mode 100644 index 000000000..b8a3715d9 --- /dev/null +++ b/share/motors/maxon-251601.ini @@ -0,0 +1,6 @@ +// maxon-251601.ini +name "maxon-251601" +description "EC 45 flat Ø42.8 mm, brushless, 50 Watt, with Hall sensors " +url "https://www.maxongroup.com/maxon/view/product/251601" +k 0.0335 +pulsesPerSample 1000 diff --git a/share/motors/maxon-339282.ini b/share/motors/maxon-339282.ini new file mode 100644 index 000000000..ebad048e8 --- /dev/null +++ b/share/motors/maxon-339282.ini @@ -0,0 +1,6 @@ +// maxon-339282.ini +name "maxon-339282" +description "EC 45 flat Ø42.9 mm, brushless, 30 Watt, with Hall sensors" +url "https://www.maxongroup.com/maxon/view/product/339282" +k 0.0706 +pulsesPerSample 1000 diff --git a/share/motors/maxon-339287.ini b/share/motors/maxon-339287.ini new file mode 100644 index 000000000..799a22771 --- /dev/null +++ b/share/motors/maxon-339287.ini @@ -0,0 +1,6 @@ +// maxon-339287.ini +name "maxon-339287" +description "EC 45 flat Ø42.8 mm, brushless, 50 Watt, with Hall sensors" +url "https://www.maxongroup.com/maxon/view/product/339287" +k 0.101 +pulsesPerSample 1000 diff --git a/share/motors/maxon-402686.ini b/share/motors/maxon-402686.ini new file mode 100644 index 000000000..bb8328282 --- /dev/null +++ b/share/motors/maxon-402686.ini @@ -0,0 +1,6 @@ +// maxon-402686.ini +name "maxon-402686" +description "EC 45 flat Ø42.8 mm, brushless, 70 Watt, with Hall sensors" +url "https://www.maxongroup.com/maxon/view/product/402686" +k 0.0533 +pulsesPerSample 1000 diff --git a/share/motors/maxon-411815.ini b/share/motors/maxon-411815.ini new file mode 100644 index 000000000..834668d3d --- /dev/null +++ b/share/motors/maxon-411815.ini @@ -0,0 +1,6 @@ +// maxon-411815.ini +name "maxon-411815" +description "EC 45 flat Ø45 mm, brushless, 70 W, with Hall sensors, with cable" +url "https://www.maxongroup.com/maxon/view/product/411815" +k 0.0533 +pulsesPerSample 1000 From 42b2ccaec9873d36b38fc12d427cf36a491c9127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Wed, 20 Nov 2019 18:39:15 +0100 Subject: [PATCH 04/12] Nuke unused motor, add 50 W maxon motor with cable --- share/motors/CMakeLists.txt | 4 ++-- share/motors/maxon-251601.ini | 6 ------ share/motors/maxon-400108.ini | 6 ++++++ 3 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 share/motors/maxon-251601.ini create mode 100644 share/motors/maxon-400108.ini diff --git a/share/motors/CMakeLists.txt b/share/motors/CMakeLists.txt index 82d5ad566..618a9bde9 100644 --- a/share/motors/CMakeLists.txt +++ b/share/motors/CMakeLists.txt @@ -1,6 +1,6 @@ -yarp_install(FILES maxon-251601.ini - maxon-339282.ini +yarp_install(FILES maxon-339282.ini maxon-339287.ini + maxon-400108.ini maxon-402686.ini maxon-411815.ini DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/motors) diff --git a/share/motors/maxon-251601.ini b/share/motors/maxon-251601.ini deleted file mode 100644 index b8a3715d9..000000000 --- a/share/motors/maxon-251601.ini +++ /dev/null @@ -1,6 +0,0 @@ -// maxon-251601.ini -name "maxon-251601" -description "EC 45 flat Ø42.8 mm, brushless, 50 Watt, with Hall sensors " -url "https://www.maxongroup.com/maxon/view/product/251601" -k 0.0335 -pulsesPerSample 1000 diff --git a/share/motors/maxon-400108.ini b/share/motors/maxon-400108.ini new file mode 100644 index 000000000..1d37b4179 --- /dev/null +++ b/share/motors/maxon-400108.ini @@ -0,0 +1,6 @@ +// maxon-400108.ini +name "maxon-400108" +description "EC 45 flat Ø45 mm, brushless, 50 W, with Hall sensors, with cable" +url "https://www.maxongroup.com/maxon/view/product/400108" +k 0.101 +pulsesPerSample 1000 From a380c413eda7c47c4bacdb1b652df41db452ec2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Sun, 24 Nov 2019 16:08:31 +0100 Subject: [PATCH 05/12] Install directories instead of explicitly listed files --- share/CMakeLists.txt | 9 +++++---- share/drivers/CMakeLists.txt | 4 ---- share/encoders/CMakeLists.txt | 2 -- share/motors/CMakeLists.txt | 6 ------ share/transmissions/CMakeLists.txt | 3 --- 5 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 share/drivers/CMakeLists.txt delete mode 100644 share/encoders/CMakeLists.txt delete mode 100644 share/motors/CMakeLists.txt delete mode 100644 share/transmissions/CMakeLists.txt diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 3c6f5d91c..eee575ec6 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -27,7 +27,8 @@ if(ENABLE_tests) add_subdirectory(testCuiAbsolute) endif() -add_subdirectory(drivers) -add_subdirectory(encoders) -add_subdirectory(motors) -add_subdirectory(transmissions) +yarp_install(DIRECTORY drivers + encoders + motors + transmissions + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) diff --git a/share/drivers/CMakeLists.txt b/share/drivers/CMakeLists.txt deleted file mode 100644 index 104cb7172..000000000 --- a/share/drivers/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -yarp_install(FILES ipos-3602-mx.ini - ipos-3604-mx.ini - ipos-4808-mx.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/drivers) diff --git a/share/encoders/CMakeLists.txt b/share/encoders/CMakeLists.txt deleted file mode 100644 index 66a360df6..000000000 --- a/share/encoders/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -yarp_install(FILES cui-amt-203-v.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/encoders) diff --git a/share/motors/CMakeLists.txt b/share/motors/CMakeLists.txt deleted file mode 100644 index 618a9bde9..000000000 --- a/share/motors/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -yarp_install(FILES maxon-339282.ini - maxon-339287.ini - maxon-400108.ini - maxon-402686.ini - maxon-411815.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/motors) diff --git a/share/transmissions/CMakeLists.txt b/share/transmissions/CMakeLists.txt deleted file mode 100644 index 458afa384..000000000 --- a/share/transmissions/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -yarp_install(FILES hd-100.ini - hd-160.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/transmissions) From d64de1a019acff92a5a014c3348c839cd01b0934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Tue, 26 Nov 2019 15:37:59 +0100 Subject: [PATCH 06/12] Implement full homing/park procedures, read specs from .ini file --- .../JointCalibrator/DeviceDriverImpl.cpp | 47 ++++- .../JointCalibrator/IRemoteCalibratorImpl.cpp | 198 +++++++++--------- .../JointCalibrator/IWrapperImpl.cpp | 5 +- .../JointCalibrator/JointCalibrator.hpp | 19 ++ programs/launchCanBus/LaunchCanBus.cpp | 1 + 5 files changed, 174 insertions(+), 96 deletions(-) diff --git a/libraries/YarpPlugins/JointCalibrator/DeviceDriverImpl.cpp b/libraries/YarpPlugins/JointCalibrator/DeviceDriverImpl.cpp index 71bb9bfee..652ee14bc 100644 --- a/libraries/YarpPlugins/JointCalibrator/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/JointCalibrator/DeviceDriverImpl.cpp @@ -2,11 +2,56 @@ #include "JointCalibrator.hpp" +#include + using namespace roboticslab; +namespace +{ + bool checkAndSet(int axes, const yarp::os::Searchable & config, std::vector & v, + const std::string & key, const std::string & keys, const std::string & comment) + { + if (config.check(key, "(shared) " + comment)) + { + v.assign(axes, config.find(key).asFloat64()); + } + else if (config.check(keys, comment)) + { + yarp::os::Bottle * parsed = config.find(keys).asList(); + + for (auto i = 0; i < parsed->size(); i++) + { + v.push_back(parsed->get(i).asFloat64()); + } + } + else + { + CD_ERROR("Missing %s/%s key or size mismatch.\n", key.c_str(), keys.c_str()); + return false; + } + + return true; + } +} + bool JointCalibrator::open(yarp::os::Searchable & config) { - return true; + CD_DEBUG("$s\n", config.toString().c_str()); + + axes = config.check("joints", yarp::os::Value(0), "number of controlled axes").asInt32(); + + if (axes == 0) + { + CD_ERROR("Illegal axis count: %d.\n", axes); + return false; + } + + return checkAndSet(axes, config, homeSpecs.pos, "home", "homes", "zero position (degrees)") + && checkAndSet(axes, config, homeSpecs.vel, "homeVel", "homeVels", "zero velocity (degrees/second)") + && checkAndSet(axes, config, homeSpecs.acc, "homeAcc", "homeAccs", "zero acceleration (degrees/second^2)") + && checkAndSet(axes, config, parkSpecs.pos, "park", "parks", "zero position (degrees)") + && checkAndSet(axes, config, parkSpecs.vel, "parkVel", "parkVels", "zero velocity (degrees/second)") + && checkAndSet(axes, config, parkSpecs.acc, "parkAcc", "parkAccs", "zero acceleration (degrees/second^2)"); } bool JointCalibrator::close() diff --git a/libraries/YarpPlugins/JointCalibrator/IRemoteCalibratorImpl.cpp b/libraries/YarpPlugins/JointCalibrator/IRemoteCalibratorImpl.cpp index a456da871..8598ca2df 100644 --- a/libraries/YarpPlugins/JointCalibrator/IRemoteCalibratorImpl.cpp +++ b/libraries/YarpPlugins/JointCalibrator/IRemoteCalibratorImpl.cpp @@ -2,178 +2,188 @@ #include "JointCalibrator.hpp" -#include +#include + +#include #include using namespace roboticslab; -bool JointCalibrator::calibrateSingleJoint(int j) +namespace { - CD_WARNING("Not supported.\n"); - return false; + constexpr double MOTION_CHECK_INTERVAL = 0.1; // seconds + constexpr double POSITION_EPSILON = 1e-3; // degrees } -bool JointCalibrator::calibrateWholePart() +bool JointCalibrator::move(const std::vector & joints, const MovementSpecs & specs) { - CD_WARNING("Not supported.\n"); - return false; -} + for (int joint : joints) + { + if (joint < 0 || joint > axes - 1) + { + CD_ERROR("Invalid joint id: %d.\n", joint); + return false; + } + } -bool JointCalibrator::homingSingleJoint(int j) -{ - if (j < 0 || j > axes - 1) + std::vector encs; + + if (!iEncoders->getEncoders(encs.data())) { - CD_ERROR("Invalid joint id: %d.\n", j); + CD_ERROR("Unable to retrieve initial position.\n"); return false; } - CD_INFO("Starting homing procedure on joint %d.\n", j); + std::vector ids; + + for (int joint : joints) + { + if (std::abs(encs[joint] - specs.pos[joint]) < POSITION_EPSILON) + { + CD_INFO("Joint %d already in target position.\n", joint); + continue; + } - yarp::conf::vocab32_t initialMode; + ids.push_back(joint); + } - if (!iControlMode->getControlMode(j, &initialMode)) + if (ids.empty()) { - CD_ERROR("Unable to retrieve initial control mode.\n"); - return false; + CD_INFO("All joints in target position, not moving.\n"); + return true; } - if (initialMode != VOCAB_CM_POSITION && !iControlMode->setControlMode(j, VOCAB_CM_POSITION)) + std::vector initialRefSpeeds(ids.size()); + + if (!iPositionControl->getRefSpeeds(ids.size(), ids.data(), initialRefSpeeds.data())) { - CD_ERROR("Unable to switch to position mode.\n"); + CD_ERROR("Unable to retrieve initial reference speeds.\n"); return false; } - double enc; + std::vector initialRefAccs(ids.size()); - if (!iEncoders->getEncoder(j, &enc)) + if (!iPositionControl->getRefAccelerations(ids.size(), ids.data(), initialRefAccs.data())) { - CD_ERROR("Unable to retrieve current position.\n"); + CD_ERROR("Unable to retrieve initial reference accelerations.\n"); return false; } - CD_INFO("Current position: %f.\n", enc); + std::vector targetModes(ids.size(), VOCAB_CM_POSITION); - if (!iPositionControl->positionMove(j, 0.0)) + if (!iControlMode->setControlModes(ids.size(), ids.data(), targetModes.data())) { - CD_ERROR("Unable to move motors to zero.\n"); + CD_ERROR("Unable to switch to position mode.\n"); return false; } - bool done; + std::vector targetRefSpeeds; + std::vector targetRefAccs; + std::vector targets; - while (!iPositionControl->checkMotionDone(j, &done)) + for (int id : ids) { - yarp::os::Time::delay(0.1); + targetRefSpeeds.push_back(specs.vel[id]); + targetRefAccs.push_back(specs.acc[id]); + targets.push_back(specs.pos[id]); } - if (initialMode != VOCAB_CM_POSITION && !iControlMode->setControlMode(j, initialMode)) + if (!iPositionControl->setRefSpeeds(ids.size(), ids.data(), targetRefSpeeds.data())) { - CD_ERROR("Unable to restore original control mode.\n"); + CD_ERROR("Unable to set new reference speeds.\n"); return false; } - CD_INFO("Homing procedure on joint %d finished.\n", j); - - return true; -} - -bool JointCalibrator::homingWholePart() -{ - CD_INFO("Starting homing procedure.\n"); - - std::vector initialModes(axes); - - if (!iControlMode->getControlModes(initialModes.data())) + if (!iPositionControl->setRefAccelerations(ids.size(), ids.data(), targetRefAccs.data())) { - CD_ERROR("Unable to retrieve initial control modes.\n"); + CD_ERROR("Unable to set new reference accelerations.\n"); return false; } - std::vector jointIds; - - for (std::size_t i = 0; i < initialModes.size(); i++) + if (!iPositionControl->positionMove(ids.size(), ids.data(), targets.data())) { - if (initialModes[i] != VOCAB_CM_POSITION) - { - jointIds.push_back(i); - } + CD_ERROR("Unable to move motors to new position.\n"); + return false; } - if (!jointIds.empty()) - { - std::vector modes(jointIds.size(), VOCAB_CM_POSITION); + bool done; - if (!iControlMode->setControlModes(jointIds.size(), jointIds.data(), modes.data())) - { - CD_ERROR("Unable to switch to position mode.\n"); - return false; - } + while (!iPositionControl->checkMotionDone(ids.size(), ids.data(), &done)) + { + yarp::os::Time::delay(MOTION_CHECK_INTERVAL); } - std::vector encs(axes); - if (!iEncoders->getEncoders(encs.data())) { - CD_ERROR("Unable to retrieve current position.\n"); + CD_ERROR("Unable to retrieve target position.\n"); return false; } - CD_INFO("Current position:"); - - for (auto enc : encs) + for (int id : ids) { - CD_INFO_NO_HEADER(" %f", enc); + if (std::abs(encs[id] - specs.pos[id]) > POSITION_EPSILON) + { + CD_ERROR("Joint %d has not reached the desired position.\n", id); + return false; + } } - CD_INFO_NO_HEADER("\n"); - - std::vector poss(axes, 0.0); - - if (!iPositionControl->positionMove(poss.data())) + if (!iPositionControl->setRefSpeeds(ids.size(), ids.data(), initialRefSpeeds.data())) { - CD_ERROR("Unable to move motors to zero.\n"); + CD_ERROR("Unable to restore initial reference speeds.\n"); return false; } - bool done; - - while (!iPositionControl->checkMotionDone(&done)) + if (!iPositionControl->setRefAccelerations(ids.size(), ids.data(), initialRefAccs.data())) { - yarp::os::Time::delay(0.1); + CD_ERROR("Unable to restore initial reference accelerations.\n"); + return false; } - if (!jointIds.empty()) - { - std::vector modes; + return true; +} - for (auto jointId : jointIds) - { - modes.push_back(initialModes[jointId]); - } +bool JointCalibrator::calibrateSingleJoint(int j) +{ + CD_WARNING("Not supported.\n"); + return false; +} - if (!iControlMode->setControlModes(jointIds.size(), jointIds.data(), modes.data())) - { - CD_ERROR("Unable to restore original control modes.\n"); - return false; - } - } +bool JointCalibrator::calibrateWholePart() +{ + CD_WARNING("Not supported.\n"); + return false; +} - CD_INFO("Homing procedure finished.\n"); +bool JointCalibrator::homingSingleJoint(int j) +{ + CD_INFO("Performing homing procedure on joint %d.\n", j); + std::vector targets{j}; + return move(targets, homeSpecs); +} - return true; +bool JointCalibrator::homingWholePart() +{ + CD_INFO("Performing homing procedure on whole part.\n"); + std::vector targets(axes); + std::iota(targets.begin(), targets.end(), 0); + return move(targets, homeSpecs); } bool JointCalibrator::parkSingleJoint(int j, bool wait) { - CD_WARNING("Not supported.\n"); - return false; + CD_INFO("Performing park procedure on joint %d.\n", j); + std::vector targets{j}; + return move(targets, parkSpecs); } bool JointCalibrator::parkWholePart() { - CD_WARNING("Not supported.\n"); - return false; + CD_INFO("Performing park procedure on whole part.\n"); + std::vector targets(axes); + std::iota(targets.begin(), targets.end(), 0); + return move(targets, parkSpecs); } bool JointCalibrator::quitCalibrate() diff --git a/libraries/YarpPlugins/JointCalibrator/IWrapperImpl.cpp b/libraries/YarpPlugins/JointCalibrator/IWrapperImpl.cpp index 918533de3..dd76f77ad 100644 --- a/libraries/YarpPlugins/JointCalibrator/IWrapperImpl.cpp +++ b/libraries/YarpPlugins/JointCalibrator/IWrapperImpl.cpp @@ -6,10 +6,13 @@ using namespace roboticslab; bool JointCalibrator::attach(yarp::dev::PolyDriver * poly) { + int localAxes; + return poly->view(iControlMode) && poly->view(iEncoders) && poly->view(iPositionControl) - && iEncoders->getAxes(&axes); + && iEncoders->getAxes(&localAxes) + && localAxes == axes; } bool JointCalibrator::detach() diff --git a/libraries/YarpPlugins/JointCalibrator/JointCalibrator.hpp b/libraries/YarpPlugins/JointCalibrator/JointCalibrator.hpp index 2327264db..30152bd57 100644 --- a/libraries/YarpPlugins/JointCalibrator/JointCalibrator.hpp +++ b/libraries/YarpPlugins/JointCalibrator/JointCalibrator.hpp @@ -3,6 +3,8 @@ #ifndef __JOINT_CALIBRATOR_HPP__ #define __JOINT_CALIBRATOR_HPP__ +#include + #include #include #include @@ -19,6 +21,17 @@ namespace roboticslab * @brief Contains roboticslab::JointCalibrator. */ +/** + * @ingroup JointCalibrator + * @brief ... + */ +struct MovementSpecs +{ + std::vector pos; + std::vector vel; + std::vector acc; +}; + /** * @ingroup JointCalibrator * @brief ... @@ -48,7 +61,13 @@ class JointCalibrator : public yarp::dev::DeviceDriver, virtual bool close(); private: + bool move(const std::vector & joints, const MovementSpecs & specs); + int axes; + + MovementSpecs homeSpecs; + MovementSpecs parkSpecs; + yarp::dev::IControlMode * iControlMode; yarp::dev::IEncoders * iEncoders; yarp::dev::IPositionControl * iPositionControl; diff --git a/programs/launchCanBus/LaunchCanBus.cpp b/programs/launchCanBus/LaunchCanBus.cpp index 2793f9cbf..b3989eeb5 100644 --- a/programs/launchCanBus/LaunchCanBus.cpp +++ b/programs/launchCanBus/LaunchCanBus.cpp @@ -128,6 +128,7 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) return false; } + calibratorDeviceOptions.put("joints", wrapperDeviceOptions.find("joints")); yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver(calibratorDeviceOptions); yarp::dev::PolyDriverDescriptor descriptor(calibratorDevice, "calibrator"); // key name enforced by CBW2::attachAll() calibratorDevices.push(descriptor); From 30066c0e3c0a2788993c3516f9f7648d80cf4470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Tue, 26 Nov 2019 18:58:53 +0100 Subject: [PATCH 07/12] Update share dir layout --- share/CMakeLists.txt | 31 ++++++++++--------- .../spaceNavigator}/spaceNavigator.xml | 0 share/{ => applications}/ymanager.ini | 0 share/checkCanBus/CMakeLists.txt | 10 ------ .../checkCanBus}/checkCanBus.ini | 0 .../checkCanBus}/checkLocomotionCan0.ini | 0 .../checkCanBus}/checkLocomotionCan1.ini | 0 .../checkCanBus}/checkManipulationCan2.ini | 0 .../checkCanBus}/checkManipulationCan3.ini | 0 .../dumpCanBus}/dumpCanBus.ini | 0 .../oneCanBusOneWrapper-CuiAbsolute.ini | 0 .../oneCanBusOneWrapper-left-arm.ini | 0 .../oneCanBusOneWrapper-right-arm.ini | 0 .../launchCanBus}/oneCanBusOneWrapper.ini | 0 .../launchCanBus}/twoCanBusThreeWrappers.ini | 0 .../testCuiAbsolute}/testCuiAbsolute.ini | 0 share/dumpCanBus/CMakeLists.txt | 6 ---- share/{ => hardware}/drivers/ipos-3602-mx.ini | 0 share/{ => hardware}/drivers/ipos-3604-mx.ini | 0 share/{ => hardware}/drivers/ipos-4808-mx.ini | 0 .../{ => hardware}/encoders/cui-amt-203-v.ini | 0 share/{ => hardware}/motors/maxon-339282.ini | 0 share/{ => hardware}/motors/maxon-339287.ini | 0 share/{ => hardware}/motors/maxon-400108.ini | 0 share/{ => hardware}/motors/maxon-402686.ini | 0 share/{ => hardware}/motors/maxon-411815.ini | 0 share/{ => hardware}/transmissions/hd-100.ini | 0 share/{ => hardware}/transmissions/hd-160.ini | 0 share/launchCanBus/CMakeLists.txt | 10 ------ share/spaceNavigator/CMakeLists.txt | 2 -- share/testCuiAbsolute/CMakeLists.txt | 6 ---- 31 files changed, 17 insertions(+), 48 deletions(-) rename share/{spaceNavigator/scripts => applications/spaceNavigator}/spaceNavigator.xml (100%) rename share/{ => applications}/ymanager.ini (100%) delete mode 100644 share/checkCanBus/CMakeLists.txt rename share/{checkCanBus/conf => contexts/checkCanBus}/checkCanBus.ini (100%) rename share/{checkCanBus/conf => contexts/checkCanBus}/checkLocomotionCan0.ini (100%) rename share/{checkCanBus/conf => contexts/checkCanBus}/checkLocomotionCan1.ini (100%) rename share/{checkCanBus/conf => contexts/checkCanBus}/checkManipulationCan2.ini (100%) rename share/{checkCanBus/conf => contexts/checkCanBus}/checkManipulationCan3.ini (100%) rename share/{dumpCanBus/conf => contexts/dumpCanBus}/dumpCanBus.ini (100%) rename share/{launchCanBus/conf => contexts/launchCanBus}/oneCanBusOneWrapper-CuiAbsolute.ini (100%) rename share/{launchCanBus/conf => contexts/launchCanBus}/oneCanBusOneWrapper-left-arm.ini (100%) rename share/{launchCanBus/conf => contexts/launchCanBus}/oneCanBusOneWrapper-right-arm.ini (100%) rename share/{launchCanBus/conf => contexts/launchCanBus}/oneCanBusOneWrapper.ini (100%) rename share/{launchCanBus/conf => contexts/launchCanBus}/twoCanBusThreeWrappers.ini (100%) rename share/{testCuiAbsolute/conf => contexts/testCuiAbsolute}/testCuiAbsolute.ini (100%) delete mode 100644 share/dumpCanBus/CMakeLists.txt rename share/{ => hardware}/drivers/ipos-3602-mx.ini (100%) rename share/{ => hardware}/drivers/ipos-3604-mx.ini (100%) rename share/{ => hardware}/drivers/ipos-4808-mx.ini (100%) rename share/{ => hardware}/encoders/cui-amt-203-v.ini (100%) rename share/{ => hardware}/motors/maxon-339282.ini (100%) rename share/{ => hardware}/motors/maxon-339287.ini (100%) rename share/{ => hardware}/motors/maxon-400108.ini (100%) rename share/{ => hardware}/motors/maxon-402686.ini (100%) rename share/{ => hardware}/motors/maxon-411815.ini (100%) rename share/{ => hardware}/transmissions/hd-100.ini (100%) rename share/{ => hardware}/transmissions/hd-160.ini (100%) delete mode 100644 share/launchCanBus/CMakeLists.txt delete mode 100644 share/spaceNavigator/CMakeLists.txt delete mode 100644 share/testCuiAbsolute/CMakeLists.txt diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index eee575ec6..1bb39d100 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -1,34 +1,37 @@ # Copyright: 2019 UC3M # Author: Juan G Victores and Raul de Santos Rico -# CopyPolicy: Released under the terms of the GNU GPL v2.0. +# CopyPolicy: Released under the terms of the GNU GPL v2.0 -yarp_install(FILES ymanager.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_DATA_INSTALL_DIR}) - -### Go through single applications +set(applications) +set(contexts) +set(data) if(ENABLE_checkCanBus) - add_subdirectory(checkCanBus) + list(APPEND contexts contexts/checkCanBus) endif() if(ENABLE_dumpCanBus) - add_subdirectory(dumpCanBus) + list(APPEND contexts contexts/dumpCanBus) endif() if(ENABLE_launchCanBus) - add_subdirectory(launchCanBus) + list(APPEND contexts contexts/launchCanBus) + list(APPEND data hardware) endif() if(ENABLE_SpaceNavigator) - add_subdirectory(spaceNavigator) + list(APPEND applications applications/spaceNavigator) endif() if(ENABLE_tests) - add_subdirectory(testCuiAbsolute) + list(APPEND contexts contexts/testCuiAbsolute) endif() -yarp_install(DIRECTORY drivers - encoders - motors - transmissions +yarp_install(DIRECTORY ${applications} + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}) + +yarp_install(DIRECTORY ${contexts} DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) + +yarp_install(DIRECTORY ${data} + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_DATA_INSTALL_DIR}) diff --git a/share/spaceNavigator/scripts/spaceNavigator.xml b/share/applications/spaceNavigator/spaceNavigator.xml similarity index 100% rename from share/spaceNavigator/scripts/spaceNavigator.xml rename to share/applications/spaceNavigator/spaceNavigator.xml diff --git a/share/ymanager.ini b/share/applications/ymanager.ini similarity index 100% rename from share/ymanager.ini rename to share/applications/ymanager.ini diff --git a/share/checkCanBus/CMakeLists.txt b/share/checkCanBus/CMakeLists.txt deleted file mode 100644 index 8b95dffd0..000000000 --- a/share/checkCanBus/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright: 2014 UC3M -# Author: Raúl de Santos Rico -# CopyPolicy: Released under the terms of the GNU GPL v2.0. - -yarp_install(FILES conf/checkCanBus.ini - conf/checkLocomotionCan0.ini - conf/checkLocomotionCan1.ini - conf/checkManipulationCan2.ini - conf/checkManipulationCan3.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/checkCanBus) diff --git a/share/checkCanBus/conf/checkCanBus.ini b/share/contexts/checkCanBus/checkCanBus.ini similarity index 100% rename from share/checkCanBus/conf/checkCanBus.ini rename to share/contexts/checkCanBus/checkCanBus.ini diff --git a/share/checkCanBus/conf/checkLocomotionCan0.ini b/share/contexts/checkCanBus/checkLocomotionCan0.ini similarity index 100% rename from share/checkCanBus/conf/checkLocomotionCan0.ini rename to share/contexts/checkCanBus/checkLocomotionCan0.ini diff --git a/share/checkCanBus/conf/checkLocomotionCan1.ini b/share/contexts/checkCanBus/checkLocomotionCan1.ini similarity index 100% rename from share/checkCanBus/conf/checkLocomotionCan1.ini rename to share/contexts/checkCanBus/checkLocomotionCan1.ini diff --git a/share/checkCanBus/conf/checkManipulationCan2.ini b/share/contexts/checkCanBus/checkManipulationCan2.ini similarity index 100% rename from share/checkCanBus/conf/checkManipulationCan2.ini rename to share/contexts/checkCanBus/checkManipulationCan2.ini diff --git a/share/checkCanBus/conf/checkManipulationCan3.ini b/share/contexts/checkCanBus/checkManipulationCan3.ini similarity index 100% rename from share/checkCanBus/conf/checkManipulationCan3.ini rename to share/contexts/checkCanBus/checkManipulationCan3.ini diff --git a/share/dumpCanBus/conf/dumpCanBus.ini b/share/contexts/dumpCanBus/dumpCanBus.ini similarity index 100% rename from share/dumpCanBus/conf/dumpCanBus.ini rename to share/contexts/dumpCanBus/dumpCanBus.ini diff --git a/share/launchCanBus/conf/oneCanBusOneWrapper-CuiAbsolute.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper-CuiAbsolute.ini similarity index 100% rename from share/launchCanBus/conf/oneCanBusOneWrapper-CuiAbsolute.ini rename to share/contexts/launchCanBus/oneCanBusOneWrapper-CuiAbsolute.ini diff --git a/share/launchCanBus/conf/oneCanBusOneWrapper-left-arm.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper-left-arm.ini similarity index 100% rename from share/launchCanBus/conf/oneCanBusOneWrapper-left-arm.ini rename to share/contexts/launchCanBus/oneCanBusOneWrapper-left-arm.ini diff --git a/share/launchCanBus/conf/oneCanBusOneWrapper-right-arm.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper-right-arm.ini similarity index 100% rename from share/launchCanBus/conf/oneCanBusOneWrapper-right-arm.ini rename to share/contexts/launchCanBus/oneCanBusOneWrapper-right-arm.ini diff --git a/share/launchCanBus/conf/oneCanBusOneWrapper.ini b/share/contexts/launchCanBus/oneCanBusOneWrapper.ini similarity index 100% rename from share/launchCanBus/conf/oneCanBusOneWrapper.ini rename to share/contexts/launchCanBus/oneCanBusOneWrapper.ini diff --git a/share/launchCanBus/conf/twoCanBusThreeWrappers.ini b/share/contexts/launchCanBus/twoCanBusThreeWrappers.ini similarity index 100% rename from share/launchCanBus/conf/twoCanBusThreeWrappers.ini rename to share/contexts/launchCanBus/twoCanBusThreeWrappers.ini diff --git a/share/testCuiAbsolute/conf/testCuiAbsolute.ini b/share/contexts/testCuiAbsolute/testCuiAbsolute.ini similarity index 100% rename from share/testCuiAbsolute/conf/testCuiAbsolute.ini rename to share/contexts/testCuiAbsolute/testCuiAbsolute.ini diff --git a/share/dumpCanBus/CMakeLists.txt b/share/dumpCanBus/CMakeLists.txt deleted file mode 100644 index 3b341dd91..000000000 --- a/share/dumpCanBus/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright: 2014 UC3M -# Author: Juan G Victores -# CopyPolicy: Released under the terms of the GNU GPL v2.0. - -yarp_install(FILES conf/dumpCanBus.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/dumpCanBus) diff --git a/share/drivers/ipos-3602-mx.ini b/share/hardware/drivers/ipos-3602-mx.ini similarity index 100% rename from share/drivers/ipos-3602-mx.ini rename to share/hardware/drivers/ipos-3602-mx.ini diff --git a/share/drivers/ipos-3604-mx.ini b/share/hardware/drivers/ipos-3604-mx.ini similarity index 100% rename from share/drivers/ipos-3604-mx.ini rename to share/hardware/drivers/ipos-3604-mx.ini diff --git a/share/drivers/ipos-4808-mx.ini b/share/hardware/drivers/ipos-4808-mx.ini similarity index 100% rename from share/drivers/ipos-4808-mx.ini rename to share/hardware/drivers/ipos-4808-mx.ini diff --git a/share/encoders/cui-amt-203-v.ini b/share/hardware/encoders/cui-amt-203-v.ini similarity index 100% rename from share/encoders/cui-amt-203-v.ini rename to share/hardware/encoders/cui-amt-203-v.ini diff --git a/share/motors/maxon-339282.ini b/share/hardware/motors/maxon-339282.ini similarity index 100% rename from share/motors/maxon-339282.ini rename to share/hardware/motors/maxon-339282.ini diff --git a/share/motors/maxon-339287.ini b/share/hardware/motors/maxon-339287.ini similarity index 100% rename from share/motors/maxon-339287.ini rename to share/hardware/motors/maxon-339287.ini diff --git a/share/motors/maxon-400108.ini b/share/hardware/motors/maxon-400108.ini similarity index 100% rename from share/motors/maxon-400108.ini rename to share/hardware/motors/maxon-400108.ini diff --git a/share/motors/maxon-402686.ini b/share/hardware/motors/maxon-402686.ini similarity index 100% rename from share/motors/maxon-402686.ini rename to share/hardware/motors/maxon-402686.ini diff --git a/share/motors/maxon-411815.ini b/share/hardware/motors/maxon-411815.ini similarity index 100% rename from share/motors/maxon-411815.ini rename to share/hardware/motors/maxon-411815.ini diff --git a/share/transmissions/hd-100.ini b/share/hardware/transmissions/hd-100.ini similarity index 100% rename from share/transmissions/hd-100.ini rename to share/hardware/transmissions/hd-100.ini diff --git a/share/transmissions/hd-160.ini b/share/hardware/transmissions/hd-160.ini similarity index 100% rename from share/transmissions/hd-160.ini rename to share/hardware/transmissions/hd-160.ini diff --git a/share/launchCanBus/CMakeLists.txt b/share/launchCanBus/CMakeLists.txt deleted file mode 100644 index 57f7f747d..000000000 --- a/share/launchCanBus/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright: 2014 UC3M -# Author: Juan G Victores -# CopyPolicy: Released under the terms of the GNU GPL v2.0. - -yarp_install(FILES conf/oneCanBusOneWrapper.ini - conf/oneCanBusOneWrapper-CuiAbsolute.ini - conf/oneCanBusOneWrapper-left-arm.ini - conf/oneCanBusOneWrapper-right-arm.ini - conf/twoCanBusThreeWrappers.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/launchCanBus) diff --git a/share/spaceNavigator/CMakeLists.txt b/share/spaceNavigator/CMakeLists.txt deleted file mode 100644 index bf4ca30fc..000000000 --- a/share/spaceNavigator/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -yarp_install(FILES scripts/spaceNavigator.xml - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}) diff --git a/share/testCuiAbsolute/CMakeLists.txt b/share/testCuiAbsolute/CMakeLists.txt deleted file mode 100644 index ffa1c321f..000000000 --- a/share/testCuiAbsolute/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright: 2014 UC3M -# Author: Raúl de Santos Rico -# CopyPolicy: Released under the terms of the GNU GPL v2.0. - -yarp_install(FILES conf/testCuiAbsolute.ini - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}/testCuiAbsolute) From d16f39c4b6201dc9453ac0b9461699db11fd63fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Wed, 27 Nov 2019 13:53:26 +0100 Subject: [PATCH 08/12] Parse new .ini file format --- .../CanBusControlboard/CanBusControlboard.hpp | 2 +- .../CanBusControlboard/DeviceDriverImpl.cpp | 140 +++++++++--------- .../CanBusControlboard/IControlModeImpl.cpp | 2 +- .../TechnosoftIpos/DeviceDriverImpl.cpp | 72 +++++++-- programs/launchCanBus/LaunchCanBus.cpp | 22 +-- 5 files changed, 141 insertions(+), 97 deletions(-) diff --git a/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp b/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp index de4d782bd..8f24ff06c 100644 --- a/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp +++ b/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp @@ -322,7 +322,7 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, yarp::dev::PolyDriver canBusDevice; yarp::dev::ICanBus * iCanBus; - yarp::dev::PolyDriverList nodes; + yarp::dev::PolyDriverList nodeDevices; DeviceMapper deviceMapper; std::vector iCanBusSharers; diff --git a/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp b/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp index 29b91c7a4..47f866c8c 100644 --- a/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp @@ -5,54 +5,50 @@ #include #include +#include +#include +#include + using namespace roboticslab; // ----------------------------------------------------------------------------- bool CanBusControlboard::open(yarp::os::Searchable & config) { - int cuiTimeout = config.check("waitEncoder", yarp::os::Value(DEFAULT_CUI_TIMEOUT), "CUI timeout (seconds)").asInt32(); + CD_DEBUG("%s\n", config.toString().c_str()); - std::string canBusType = config.check("canBusType", yarp::os::Value(DEFAULT_CAN_BUS), "CAN bus device name").asString(); - int canRxBufferSize = config.check("canBusRxBufferSize", yarp::os::Value(DEFAULT_CAN_RX_BUFFER_SIZE), "CAN bus RX buffer size").asInt(); - int canTxBufferSize = config.check("canBusTxBufferSize", yarp::os::Value(DEFAULT_CAN_TX_BUFFER_SIZE), "CAN bus TX buffer size").asInt(); - double canRxPeriodMs = config.check("canRxPeriodMs", yarp::os::Value(DEFAULT_CAN_RX_PERIOD_MS), "CAN bus RX period (milliseconds)").asFloat64(); - double canTxPeriodMs = config.check("canTxPeriodMs", yarp::os::Value(DEFAULT_CAN_TX_PERIOD_MS), "CAN bus TX period (milliseconds)").asFloat64(); - double canSdoTimeoutMs = config.check("canSdoTimeoutMs", yarp::os::Value(DEFAULT_CAN_SDO_TIMEOUT_MS), "CAN bus SDO timeout (milliseconds)").asFloat64(); - double canDriveStateTimeout = config.check("canDriveStateTimeout", yarp::os::Value(DEFAULT_CAN_DRIVE_STATE_TIMEOUT), "CAN drive state timeout (seconds)").asFloat64(); + yarp::os::ResourceFinder & rf = yarp::os::ResourceFinder::getResourceFinderSingleton(); + const std::string slash = yarp::os::NetworkBase::getPathSeparator(); - linInterpPeriodMs = config.check("linInterpPeriodMs", yarp::os::Value(DEFAULT_LIN_INTERP_PERIOD_MS), "linear interpolation mode period (milliseconds)").asInt32(); - linInterpBufferSize = config.check("linInterpBufferSize", yarp::os::Value(DEFAULT_LIN_INTERP_BUFFER_SIZE), "linear interpolation mode buffer size").asInt32(); - linInterpMode = config.check("linInterpMode", yarp::os::Value(DEFAULT_LIN_INTERP_MODE), "linear interpolation mode (pt/pvt)").asString(); + if (!config.check("bus", "CAN bus") || !config.check("nodes", "CAN nodes")) + { + CD_ERROR("Some mandatory keys are missing: \"bus\", \"nodes\".\n"); + return false; + } - yarp::os::Bottle ids = config.findGroup("ids", "CAN bus IDs").tail(); //-- e.g. 15 - yarp::os::Bottle trs = config.findGroup("trs", "reductions").tail(); //-- e.g. 160 - yarp::os::Bottle ks = config.findGroup("ks", "motor constants").tail(); //-- e.g. 0.0706 + std::string bus = config.find("bus").asString(); + yarp::os::Bottle * nodes = config.find("nodes").asList(); - yarp::os::Bottle maxs = config.findGroup("maxs", "maximum joint limits (meters or degrees)").tail(); //-- e.g. 360 - yarp::os::Bottle mins = config.findGroup("mins", "minimum joint limits (meters or degrees)").tail(); //-- e.g. -360 - yarp::os::Bottle maxVels = config.findGroup("maxVels", "maximum joint velocities (meters/second or degrees/second)").tail(); //-- e.g. 1000 - yarp::os::Bottle refAccelerations = config.findGroup("refAccelerations", "ref accelerations (meters/second^2 or degrees/second^2)").tail(); //-- e.g. 0.575437 - yarp::os::Bottle refSpeeds = config.findGroup("refSpeeds", "ref speeds (meters/second or degrees/second)").tail(); //-- e.g. 737.2798 - yarp::os::Bottle encoderPulsess = config.findGroup("encoderPulsess", "encoder pulses (multiple nodes)").tail(); //-- e.g. 4096 (4 * 1024) - yarp::os::Bottle pulsesPerSamples = config.findGroup("pulsesPerSamples", "encoder pulses per sample (multiple nodes)").tail(); //-- e.g. 1000 + if (bus.empty() || nodes == nullptr) + { + CD_ERROR("Illegal key(s): empty \"bus\" or nullptr \"nodes\".\n"); + return false; + } - yarp::os::Bottle types = config.findGroup("types", "device name of each node").tail(); //-- e.g. 15 + std::string busPath = rf.findFileByName("buses" + slash + bus + ".ini"); yarp::os::Property canBusOptions; - canBusOptions.fromString(config.toString()); // canDevice, canBitrate - canBusOptions.put("device", canBusType); - canBusOptions.put("canBlockingMode", false); // enforce non-blocking mode - canBusOptions.put("canAllowPermissive", false); // always check usage requirements - canBusOptions.setMonitor(config.getMonitor(), canBusType.c_str()); + canBusOptions.setMonitor(config.getMonitor(), bus.c_str()); - int parallelCanThreadLimit = config.check("parallelCanThreadLimit", yarp::os::Value(0), "parallel CAN TX thread limit").asInt32(); - - if (parallelCanThreadLimit > 0) + if (!canBusOptions.fromConfigFile(busPath)) { - deviceMapper.enableParallelization(parallelCanThreadLimit); + CD_ERROR("File %s does not exist or unsufficient permissions.\n", busPath.c_str()); + return false; } + canBusOptions.put("canBlockingMode", false); // enforce non-blocking mode + canBusOptions.put("canAllowPermissive", false); // always check usage requirements + if (!canBusDevice.open(canBusOptions)) { CD_ERROR("canBusDevice instantiation not worked.\n"); @@ -61,7 +57,7 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) if (!canBusDevice.view(iCanBus)) { - CD_ERROR("Cannot view ICanBus interface in device: %s.\n", canBusType.c_str()); + CD_ERROR("Cannot view ICanBus interface in device: %s.\n", bus.c_str()); return false; } @@ -69,50 +65,56 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) if (!canBusDevice.view(iCanBufferFactory)) { - CD_ERROR("Cannot view ICanBufferFactory interface in device: %s.\n", canBusType.c_str()); + CD_ERROR("Cannot view ICanBufferFactory interface in device: %s.\n", bus.c_str()); return false; } - iCanBusSharers.resize(ids.size()); + iCanBusSharers.resize(nodes->size()); + + int cuiTimeout = config.check("waitEncoder", yarp::os::Value(DEFAULT_CUI_TIMEOUT), "CUI timeout (seconds)").asInt32(); + + std::string canBusType = config.check("canBusType", yarp::os::Value(DEFAULT_CAN_BUS), "CAN bus device name").asString(); + int canRxBufferSize = config.check("canBusRxBufferSize", yarp::os::Value(DEFAULT_CAN_RX_BUFFER_SIZE), "CAN bus RX buffer size").asInt(); + int canTxBufferSize = config.check("canBusTxBufferSize", yarp::os::Value(DEFAULT_CAN_TX_BUFFER_SIZE), "CAN bus TX buffer size").asInt(); + double canRxPeriodMs = config.check("canRxPeriodMs", yarp::os::Value(DEFAULT_CAN_RX_PERIOD_MS), "CAN bus RX period (milliseconds)").asFloat64(); + double canTxPeriodMs = config.check("canTxPeriodMs", yarp::os::Value(DEFAULT_CAN_TX_PERIOD_MS), "CAN bus TX period (milliseconds)").asFloat64(); + double canSdoTimeoutMs = config.check("canSdoTimeoutMs", yarp::os::Value(DEFAULT_CAN_SDO_TIMEOUT_MS), "CAN bus SDO timeout (milliseconds)").asFloat64(); + double canDriveStateTimeout = config.check("canDriveStateTimeout", yarp::os::Value(DEFAULT_CAN_DRIVE_STATE_TIMEOUT), "CAN drive state timeout (seconds)").asFloat64(); - for (int i = 0; i < ids.size(); i++) + linInterpPeriodMs = config.check("linInterpPeriodMs", yarp::os::Value(DEFAULT_LIN_INTERP_PERIOD_MS), "linear interpolation mode period (milliseconds)").asInt32(); + linInterpBufferSize = config.check("linInterpBufferSize", yarp::os::Value(DEFAULT_LIN_INTERP_BUFFER_SIZE), "linear interpolation mode buffer size").asInt32(); + linInterpMode = config.check("linInterpMode", yarp::os::Value(DEFAULT_LIN_INTERP_MODE), "linear interpolation mode (pt/pvt)").asString(); + + int parallelCanThreadLimit = config.check("parallelCanThreadLimit", yarp::os::Value(0), "parallel CAN TX thread limit").asInt32(); + + if (parallelCanThreadLimit > 0) { - if (types.get(i).asString().empty()) + deviceMapper.enableParallelization(parallelCanThreadLimit); + } + + for (int i = 0; i < nodes->size(); i++) + { + std::string node = nodes->get(i).asString(); + std::string nodePath = rf.findFileByName("nodes" + slash + node + ".ini"); + + yarp::os::Property nodeOptions; + nodeOptions.setMonitor(config.getMonitor(), node.c_str()); + + if (!nodeOptions.fromConfigFile(nodePath)) { - CD_WARNING("Argument \"types\" empty at %d.\n", i); + CD_ERROR("File %s does not exist or unsufficient permissions.\n", nodePath.c_str()); + return false; } - yarp::os::Property options; - options.put("device", types.get(i)); - options.put("canId", ids.get(i)); - options.put("tr", trs.get(i)); - options.put("min", mins.get(i)); - options.put("max", maxs.get(i)); - options.put("maxVel", maxVels.get(i)); - options.put("k", ks.get(i)); - options.put("refAcceleration", refAccelerations.get(i)); - options.put("refSpeed", refSpeeds.get(i)); - options.put("encoderPulses", encoderPulsess.get(i)); - options.put("pulsesPerSample", pulsesPerSamples.get(i)); - options.put("linInterpPeriodMs", linInterpPeriodMs); - options.put("linInterpBufferSize", linInterpBufferSize); - options.put("linInterpMode", linInterpMode); - options.put("canSdoTimeoutMs", canSdoTimeoutMs); - options.put("canDriveStateTimeout", canDriveStateTimeout); - options.put("cuiTimeout", cuiTimeout); - std::string context = types.get(i).asString() + "_" + std::to_string(ids.get(i).asInt32()); - options.setMonitor(config.getMonitor(),context.c_str()); - - yarp::dev::PolyDriver * device = new yarp::dev::PolyDriver(options); - - if (!device->isValid()) + yarp::dev::PolyDriver * device = new yarp::dev::PolyDriver; + nodeDevices.push(device, node.c_str()); + + if (!device->open(nodeOptions)) { - CD_ERROR("CAN node [%d] '%s' instantiation failure.\n", i, types.get(i).asString().c_str()); + CD_ERROR("CAN node device %s configuration failure.\n", node.c_str()); return false; } - nodes.push(device, ""); // TODO: device key - if (!deviceMapper.registerDevice(device)) { CD_ERROR("Unable to register device.\n"); @@ -127,9 +129,9 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) iCanBusSharers[i]->registerSender(canWriterThread->getDelegate()); - if (!iCanBus->canIdAdd(ids.get(i).asInt32())) + if (!iCanBus->canIdAdd(iCanBusSharers[i]->getId())) { - CD_ERROR("Cannot register acceptance filter for node ID: %d.\n", ids.get(i).asInt32()); + CD_ERROR("Cannot register acceptance filter for node ID: %d.\n", iCanBusSharers[i]->getId()); return false; } } @@ -178,10 +180,10 @@ bool CanBusControlboard::close() ok &= p->finalize(); } - for (int i = 0; i < nodes.size(); i++) + for (int i = 0; i < nodeDevices.size(); i++) { - ok &= nodes[i]->poly->close(); - delete nodes[i]->poly; + ok &= nodeDevices[i]->poly->close(); + delete nodeDevices[i]->poly; } if (canWriterThread && canWriterThread->isRunning()) diff --git a/libraries/YarpPlugins/CanBusControlboard/IControlModeImpl.cpp b/libraries/YarpPlugins/CanBusControlboard/IControlModeImpl.cpp index 982c4d75a..b3ed03ac4 100644 --- a/libraries/YarpPlugins/CanBusControlboard/IControlModeImpl.cpp +++ b/libraries/YarpPlugins/CanBusControlboard/IControlModeImpl.cpp @@ -60,7 +60,7 @@ bool CanBusControlboard::setControlModes(int * modes) return false; } - for (unsigned int i = 0; i < nodes.size(); i++) + for (unsigned int i = 0; i < nodeDevices.size(); i++) { posdThread->updateControlModeRegister(i, modes[i] == VOCAB_CM_POSITION_DIRECT); } diff --git a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp index 5956d9549..3cd9f907c 100644 --- a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp @@ -4,36 +4,75 @@ #include +#include +#include +#include + #include using namespace roboticslab; +namespace +{ + yarp::os::Property getConfig(const yarp::os::Searchable & config, const std::string & key, const std::string & comment, + const std::string & dir) + { + yarp::os::ResourceFinder & rf = yarp::os::ResourceFinder::getResourceFinderSingleton(); + const std::string slash = yarp::os::NetworkBase::getPathSeparator(); + + std::string value = config.check(key, yarp::os::Value(""), comment).asString(); + std::string path = rf.findFileByName(dir + slash + value + ".ini"); + + yarp::os::Property nestedConfig; + nestedConfig.setMonitor(config.getMonitor(), value.c_str()); + + if (!nestedConfig.fromConfigFile(path)) + { + CD_WARNING("File %s does not exist or unsufficient permissions.\n", path.c_str()); + } + + return nestedConfig; + } +} + // ----------------------------------------------------------------------------- bool TechnosoftIpos::open(yarp::os::Searchable & config) { CD_DEBUG("%s\n", config.toString().c_str()); - int canId = config.check("canId", yarp::os::Value(0), "CAN bus ID").asInt32(); + yarp::os::ResourceFinder & rf = yarp::os::ResourceFinder::getResourceFinderSingleton(); + const std::string slash = yarp::os::NetworkBase::getPathSeparator(); + + int canId = config.check("canId", yarp::os::Value(0), "CAN node ID").asInt32(); + + std::string joint = config.check("joint", yarp::os::Value(""), "controlled joint").asString(); + std::string jointPath = rf.findFileByName("joints/" + joint + ".ini"); + + yarp::os::Property jointConfig = getConfig(config, "joint", "controlled joint", "joints"); + yarp::os::Property driverConfig = getConfig(jointConfig, "driver", "driver", "drivers"); + yarp::os::Property motorConfig = getConfig(jointConfig, "motor", "motor", "motors"); + yarp::os::Property transmissionConfig = getConfig(jointConfig, "transmission", "transmission", "transmissions"); + yarp::os::Property encoderConfig = getConfig(jointConfig, "encoder", "internal encoder", "encoders"); // mutable variables - vars.tr = config.check("tr", yarp::os::Value(0.0), "reduction").asFloat64(); - vars.k = config.check("k", yarp::os::Value(0.0), "motor constant").asFloat64(); - vars.encoderPulses = config.check("encoderPulses", yarp::os::Value(0), "encoderPulses").asInt32(); - vars.pulsesPerSample = config.check("pulsesPerSample", yarp::os::Value(0), "pulsesPerSample").asInt32(); + vars.tr = transmissionConfig.check("tr", yarp::os::Value(0.0), "reduction").asFloat64(); + vars.k = driverConfig.check("k", yarp::os::Value(0.0), "motor constant").asFloat64(); + vars.encoderPulses = encoderConfig.check("encoderPulses", yarp::os::Value(0), "encoderPulses").asInt32(); + vars.pulsesPerSample = motorConfig.check("pulsesPerSample", yarp::os::Value(0), "pulsesPerSample").asInt32(); vars.actualControlMode = VOCAB_CM_NOT_CONFIGURED; // immutable variables - vars.drivePeakCurrent = config.check("drivePeakCurrent", yarp::os::Value(0.0), "peak drive current (amperes)").asFloat64(); - vars.maxVel = config.check("maxVel", yarp::os::Value(0.0), "maxVel (meters/second or degrees/second)").asFloat64(); - vars.axisName = config.check("axisName", yarp::os::Value(""), "axis name").asString(); - vars.jointType = config.check("jointType", yarp::os::Value(yarp::dev::VOCAB_JOINTTYPE_UNKNOWN), "joint type [atrv|atpr|unkn]").asVocab(); - vars.reverse = config.check("reverse", yarp::os::Value(false), "reverse motor encoder counts").asBool(); - vars.min = config.check("min", yarp::os::Value(0.0), "min (meters or degrees)").asFloat64(); - vars.max = config.check("max", yarp::os::Value(0.0), "max (meters or degrees)").asFloat64(); - vars.refSpeed = config.check("refSpeed", yarp::os::Value(0.0), "ref speed (meters/second or degrees/second)").asFloat64(); - vars.refAcceleration = config.check("refAcceleration", yarp::os::Value(0.0), "ref acceleration (meters/second^2 or degrees/second^2)").asFloat64(); + vars.drivePeakCurrent = driverConfig.check("drivePeakCurrent", yarp::os::Value(0.0), "peak drive current (amperes)").asFloat64(); + vars.maxVel = jointConfig.check("maxVel", yarp::os::Value(0.0), "maxVel (meters/second or degrees/second)").asFloat64(); + vars.axisName = jointConfig.check("axisName", yarp::os::Value(""), "axis name").asString(); + vars.jointType = jointConfig.check("jointType", yarp::os::Value(yarp::dev::VOCAB_JOINTTYPE_UNKNOWN), "joint type [atrv|atpr|unkn]").asVocab(); + vars.reverse = jointConfig.check("reverse", yarp::os::Value(false), "reverse motor encoder counts").asBool(); + vars.min = jointConfig.check("min", yarp::os::Value(0.0), "min (meters or degrees)").asFloat64(); + vars.max = jointConfig.check("max", yarp::os::Value(0.0), "max (meters or degrees)").asFloat64(); + vars.refSpeed = jointConfig.check("refSpeed", yarp::os::Value(0.0), "ref speed (meters/second or degrees/second)").asFloat64(); + vars.refAcceleration = jointConfig.check("refAcceleration", yarp::os::Value(0.0), "ref acceleration (meters/second^2 or degrees/second^2)").asFloat64(); if (!vars.validateInitialState(canId)) { @@ -41,11 +80,12 @@ bool TechnosoftIpos::open(yarp::os::Searchable & config) return false; } - if (config.check("externalEncoder", "external encoder device")) + if (config.check("externalEncoder", "external encoder")) { + yarp::os::Property externalEncoderOptions = getConfig(config, "externalEncoder", "external encoder", "nodes"); std::string externalEncoder = config.find("externalEncoder").asString(); - if (!externalEncoderDevice.open(externalEncoder)) + if (!externalEncoderDevice.open(externalEncoderOptions)) { CD_ERROR("Unable to open external encoder device: %s.\n", externalEncoder.c_str()); return false; diff --git a/programs/launchCanBus/LaunchCanBus.cpp b/programs/launchCanBus/LaunchCanBus.cpp index b3989eeb5..cd59bf6ad 100644 --- a/programs/launchCanBus/LaunchCanBus.cpp +++ b/programs/launchCanBus/LaunchCanBus.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -68,12 +69,12 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) canDeviceOptions.fromString(canDeviceGroup.toString()); canDeviceOptions.put("home", homing); - yarp::dev::PolyDriver * canDevice = new yarp::dev::PolyDriver(canDeviceOptions); + yarp::dev::PolyDriver * canDevice = new yarp::dev::PolyDriver; canDevices.push(canDevice, canDeviceLabel.c_str()); - if (!canDevice->isValid()) + if (!canDevice->open(canDeviceOptions)) { - CD_ERROR("CAN device %s instantiation failure.\n", canDeviceLabel.c_str()); + CD_ERROR("CAN device %s configuration failure.\n", canDeviceLabel.c_str()); return false; } } @@ -95,12 +96,12 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) wrapperDeviceOptions.fromString(wrapperDeviceGroup.toString()); wrapperDeviceOptions.unput("calibrator"); // custom property added by us - yarp::dev::PolyDriver * wrapperDevice = new yarp::dev::PolyDriver(wrapperDeviceOptions); + yarp::dev::PolyDriver * wrapperDevice = new yarp::dev::PolyDriver; wrapperDevices.push(wrapperDevice, wrapperDeviceLabel.c_str()); - if (!wrapperDevice->isValid()) + if (!wrapperDevice->open(wrapperDeviceOptions)) { - CD_ERROR("Wrapper device %s instantiation failure.\n", wrapperDeviceLabel.c_str()); + CD_ERROR("Wrapper device %s configuration failure.\n", wrapperDeviceLabel.c_str()); return false; } @@ -119,7 +120,8 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) if (!calibratorDeviceLabel.empty()) { - std::string calibratorFilePath = rf.findFileByName("calibrators/" + calibratorDeviceLabel + ".ini"); + std::string slash = yarp::os::NetworkBase::getPathSeparator(); + std::string calibratorFilePath = rf.findFileByName("calibrators" + slash + calibratorDeviceLabel + ".ini"); yarp::os::Property calibratorDeviceOptions; if (!calibratorDeviceOptions.fromConfigFile(calibratorFilePath)) @@ -129,13 +131,13 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) } calibratorDeviceOptions.put("joints", wrapperDeviceOptions.find("joints")); - yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver(calibratorDeviceOptions); + yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver; yarp::dev::PolyDriverDescriptor descriptor(calibratorDevice, "calibrator"); // key name enforced by CBW2::attachAll() calibratorDevices.push(descriptor); - if (!calibratorDevice->isValid()) + if (!calibratorDevice->open(calibratorDeviceOptions)) { - CD_ERROR("Calibrator device %s instantiation failure.\n", calibratorDeviceLabel.c_str()); + CD_ERROR("Calibrator device %s configuration failure.\n", calibratorDeviceLabel.c_str()); return false; } From e0bde3aa6ffa0de497966892649a634307fbeb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Thu, 28 Nov 2019 02:02:48 +0100 Subject: [PATCH 09/12] Move config files back to TEO-specific repo, parse new .ini format --- .../CanBusControlboard/CanBusControlboard.hpp | 2 - .../CanBusControlboard/DeviceDriverImpl.cpp | 37 ++++----- .../TechnosoftIpos/DeviceDriverImpl.cpp | 79 +++++++------------ programs/launchCanBus/LaunchCanBus.cpp | 25 ++++-- share/CMakeLists.txt | 5 -- share/hardware/drivers/ipos-3602-mx.ini | 4 - share/hardware/drivers/ipos-3604-mx.ini | 4 - share/hardware/drivers/ipos-4808-mx.ini | 4 - share/hardware/encoders/cui-amt-203-v.ini | 4 - share/hardware/motors/maxon-339282.ini | 6 -- share/hardware/motors/maxon-339287.ini | 6 -- share/hardware/motors/maxon-400108.ini | 6 -- share/hardware/motors/maxon-402686.ini | 6 -- share/hardware/motors/maxon-411815.ini | 6 -- share/hardware/transmissions/hd-100.ini | 4 - share/hardware/transmissions/hd-160.ini | 4 - 16 files changed, 64 insertions(+), 138 deletions(-) delete mode 100644 share/hardware/drivers/ipos-3602-mx.ini delete mode 100644 share/hardware/drivers/ipos-3604-mx.ini delete mode 100644 share/hardware/drivers/ipos-4808-mx.ini delete mode 100644 share/hardware/encoders/cui-amt-203-v.ini delete mode 100644 share/hardware/motors/maxon-339282.ini delete mode 100644 share/hardware/motors/maxon-339287.ini delete mode 100644 share/hardware/motors/maxon-400108.ini delete mode 100644 share/hardware/motors/maxon-402686.ini delete mode 100644 share/hardware/motors/maxon-411815.ini delete mode 100644 share/hardware/transmissions/hd-100.ini delete mode 100644 share/hardware/transmissions/hd-160.ini diff --git a/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp b/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp index 8f24ff06c..5934a2da6 100644 --- a/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp +++ b/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp @@ -10,8 +10,6 @@ #include #include -#include - #include "ICanBusSharer.hpp" #include "PositionDirectThread.hpp" #include "DeviceMapper.hpp" diff --git a/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp b/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp index 47f866c8c..55b5601fd 100644 --- a/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp @@ -2,12 +2,9 @@ #include "CanBusControlboard.hpp" -#include -#include - -#include #include -#include + +#include using namespace roboticslab; @@ -17,9 +14,6 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) { CD_DEBUG("%s\n", config.toString().c_str()); - yarp::os::ResourceFinder & rf = yarp::os::ResourceFinder::getResourceFinderSingleton(); - const std::string slash = yarp::os::NetworkBase::getPathSeparator(); - if (!config.check("bus", "CAN bus") || !config.check("nodes", "CAN nodes")) { CD_ERROR("Some mandatory keys are missing: \"bus\", \"nodes\".\n"); @@ -35,19 +29,20 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) return false; } - std::string busPath = rf.findFileByName("buses" + slash + bus + ".ini"); + yarp::os::Bottle & canBusGroup = config.findGroup(bus); - yarp::os::Property canBusOptions; - canBusOptions.setMonitor(config.getMonitor(), bus.c_str()); - - if (!canBusOptions.fromConfigFile(busPath)) + if (canBusGroup.isNull()) { - CD_ERROR("File %s does not exist or unsufficient permissions.\n", busPath.c_str()); + CD_ERROR("Missing CAN bus device group %s.\n", bus.c_str()); return false; } + yarp::os::Property canBusOptions; + canBusOptions.fromString(canBusGroup.toString(), false); + canBusOptions.fromString(config.toString(), false); canBusOptions.put("canBlockingMode", false); // enforce non-blocking mode canBusOptions.put("canAllowPermissive", false); // always check usage requirements + canBusOptions.setMonitor(config.getMonitor(), bus.c_str()); if (!canBusDevice.open(canBusOptions)) { @@ -95,17 +90,19 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) for (int i = 0; i < nodes->size(); i++) { std::string node = nodes->get(i).asString(); - std::string nodePath = rf.findFileByName("nodes" + slash + node + ".ini"); - - yarp::os::Property nodeOptions; - nodeOptions.setMonitor(config.getMonitor(), node.c_str()); + yarp::os::Bottle & nodeGroup = config.findGroup(node); - if (!nodeOptions.fromConfigFile(nodePath)) + if (nodeGroup.isNull()) { - CD_ERROR("File %s does not exist or unsufficient permissions.\n", nodePath.c_str()); + CD_ERROR("Missing CAN node device group %s.\n", node.c_str()); return false; } + yarp::os::Property nodeOptions; + nodeOptions.fromString(nodeGroup.toString(), false); + nodeOptions.fromString(config.toString(), false); + nodeOptions.setMonitor(config.getMonitor(), node.c_str()); + yarp::dev::PolyDriver * device = new yarp::dev::PolyDriver; nodeDevices.push(device, node.c_str()); diff --git a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp index 3cd9f907c..8f1171fca 100644 --- a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp @@ -4,75 +4,43 @@ #include -#include #include -#include #include using namespace roboticslab; -namespace -{ - yarp::os::Property getConfig(const yarp::os::Searchable & config, const std::string & key, const std::string & comment, - const std::string & dir) - { - yarp::os::ResourceFinder & rf = yarp::os::ResourceFinder::getResourceFinderSingleton(); - const std::string slash = yarp::os::NetworkBase::getPathSeparator(); - - std::string value = config.check(key, yarp::os::Value(""), comment).asString(); - std::string path = rf.findFileByName(dir + slash + value + ".ini"); - - yarp::os::Property nestedConfig; - nestedConfig.setMonitor(config.getMonitor(), value.c_str()); - - if (!nestedConfig.fromConfigFile(path)) - { - CD_WARNING("File %s does not exist or unsufficient permissions.\n", path.c_str()); - } - - return nestedConfig; - } -} - // ----------------------------------------------------------------------------- bool TechnosoftIpos::open(yarp::os::Searchable & config) { CD_DEBUG("%s\n", config.toString().c_str()); - yarp::os::ResourceFinder & rf = yarp::os::ResourceFinder::getResourceFinderSingleton(); - const std::string slash = yarp::os::NetworkBase::getPathSeparator(); - int canId = config.check("canId", yarp::os::Value(0), "CAN node ID").asInt32(); - std::string joint = config.check("joint", yarp::os::Value(""), "controlled joint").asString(); - std::string jointPath = rf.findFileByName("joints/" + joint + ".ini"); - - yarp::os::Property jointConfig = getConfig(config, "joint", "controlled joint", "joints"); - yarp::os::Property driverConfig = getConfig(jointConfig, "driver", "driver", "drivers"); - yarp::os::Property motorConfig = getConfig(jointConfig, "motor", "motor", "motors"); - yarp::os::Property transmissionConfig = getConfig(jointConfig, "transmission", "transmission", "transmissions"); - yarp::os::Property encoderConfig = getConfig(jointConfig, "encoder", "internal encoder", "encoders"); + yarp::os::Bottle & driverGroup = config.findGroup("driver"); + yarp::os::Bottle & motorGroup = config.findGroup("motor"); + yarp::os::Bottle & transmissionGroup = config.findGroup("transmission"); + yarp::os::Bottle & encoderGroup = config.findGroup("encoder"); // mutable variables - vars.tr = transmissionConfig.check("tr", yarp::os::Value(0.0), "reduction").asFloat64(); - vars.k = driverConfig.check("k", yarp::os::Value(0.0), "motor constant").asFloat64(); - vars.encoderPulses = encoderConfig.check("encoderPulses", yarp::os::Value(0), "encoderPulses").asInt32(); - vars.pulsesPerSample = motorConfig.check("pulsesPerSample", yarp::os::Value(0), "pulsesPerSample").asInt32(); + vars.tr = transmissionGroup.check("tr", yarp::os::Value(0.0), "reduction").asFloat64(); + vars.k = motorGroup.check("k", yarp::os::Value(0.0), "motor constant").asFloat64(); + vars.encoderPulses = encoderGroup.check("encoderPulses", yarp::os::Value(0), "encoderPulses").asInt32(); + vars.pulsesPerSample = motorGroup.check("pulsesPerSample", yarp::os::Value(0), "pulsesPerSample").asInt32(); vars.actualControlMode = VOCAB_CM_NOT_CONFIGURED; // immutable variables - vars.drivePeakCurrent = driverConfig.check("drivePeakCurrent", yarp::os::Value(0.0), "peak drive current (amperes)").asFloat64(); - vars.maxVel = jointConfig.check("maxVel", yarp::os::Value(0.0), "maxVel (meters/second or degrees/second)").asFloat64(); - vars.axisName = jointConfig.check("axisName", yarp::os::Value(""), "axis name").asString(); - vars.jointType = jointConfig.check("jointType", yarp::os::Value(yarp::dev::VOCAB_JOINTTYPE_UNKNOWN), "joint type [atrv|atpr|unkn]").asVocab(); - vars.reverse = jointConfig.check("reverse", yarp::os::Value(false), "reverse motor encoder counts").asBool(); - vars.min = jointConfig.check("min", yarp::os::Value(0.0), "min (meters or degrees)").asFloat64(); - vars.max = jointConfig.check("max", yarp::os::Value(0.0), "max (meters or degrees)").asFloat64(); - vars.refSpeed = jointConfig.check("refSpeed", yarp::os::Value(0.0), "ref speed (meters/second or degrees/second)").asFloat64(); - vars.refAcceleration = jointConfig.check("refAcceleration", yarp::os::Value(0.0), "ref acceleration (meters/second^2 or degrees/second^2)").asFloat64(); + vars.drivePeakCurrent = driverGroup.check("drivePeakCurrent", yarp::os::Value(0.0), "peak drive current (amperes)").asFloat64(); + vars.maxVel = config.check("maxVel", yarp::os::Value(0.0), "maxVel (meters/second or degrees/second)").asFloat64(); + vars.axisName = config.check("axisName", yarp::os::Value(""), "axis name").asString(); + vars.jointType = config.check("jointType", yarp::os::Value(yarp::dev::VOCAB_JOINTTYPE_UNKNOWN), "joint type [atrv|atpr|unkn]").asVocab(); + vars.reverse = config.check("reverse", yarp::os::Value(false), "reverse motor encoder counts").asBool(); + vars.min = config.check("min", yarp::os::Value(0.0), "min (meters or degrees)").asFloat64(); + vars.max = config.check("max", yarp::os::Value(0.0), "max (meters or degrees)").asFloat64(); + vars.refSpeed = config.check("refSpeed", yarp::os::Value(0.0), "ref speed (meters/second or degrees/second)").asFloat64(); + vars.refAcceleration = config.check("refAcceleration", yarp::os::Value(0.0), "ref acceleration (meters/second^2 or degrees/second^2)").asFloat64(); if (!vars.validateInitialState(canId)) { @@ -82,8 +50,19 @@ bool TechnosoftIpos::open(yarp::os::Searchable & config) if (config.check("externalEncoder", "external encoder")) { - yarp::os::Property externalEncoderOptions = getConfig(config, "externalEncoder", "external encoder", "nodes"); std::string externalEncoder = config.find("externalEncoder").asString(); + yarp::os::Bottle & externalEncoderGroup = config.findGroup(externalEncoder); + + if (externalEncoderGroup.isNull()) + { + CD_ERROR("Missing external encoder device group %s.\n", externalEncoder.c_str()); + return false; + } + + yarp::os::Property externalEncoderOptions; + externalEncoderOptions.fromString(externalEncoderGroup.toString(), false); + externalEncoderOptions.fromString(config.toString(), false); + externalEncoderOptions.setMonitor(config.getMonitor(), externalEncoder.c_str()); if (!externalEncoderDevice.open(externalEncoderOptions)) { diff --git a/programs/launchCanBus/LaunchCanBus.cpp b/programs/launchCanBus/LaunchCanBus.cpp index cd59bf6ad..00b469ba4 100644 --- a/programs/launchCanBus/LaunchCanBus.cpp +++ b/programs/launchCanBus/LaunchCanBus.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -34,6 +33,15 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) return false; } + yarp::os::Property robotConfig; + std::string configPath = rf.findFileByName("config.ini"); + + if (configPath.empty() || !robotConfig.fromConfigFile(configPath)) + { + CD_ERROR("File %s does not exist or unsufficient permissions.\n", configPath.c_str()); + return false; + } + yarp::conf::vocab32_t mode = rf.check("mode", yarp::os::Value(VOCAB_CM_POSITION), "initial mode of operation").asVocab(); bool homing = rf.check("home", yarp::os::Value(false), "perform initial homing procedure").asBool(); @@ -66,7 +74,8 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) } yarp::os::Property canDeviceOptions; - canDeviceOptions.fromString(canDeviceGroup.toString()); + canDeviceOptions.fromString(canDeviceGroup.toString(), false); + canDeviceOptions.fromString(robotConfig.toString(), false); canDeviceOptions.put("home", homing); yarp::dev::PolyDriver * canDevice = new yarp::dev::PolyDriver; @@ -120,17 +129,19 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf) if (!calibratorDeviceLabel.empty()) { - std::string slash = yarp::os::NetworkBase::getPathSeparator(); - std::string calibratorFilePath = rf.findFileByName("calibrators" + slash + calibratorDeviceLabel + ".ini"); - yarp::os::Property calibratorDeviceOptions; + yarp::os::Bottle & calibratorDeviceGroup = robotConfig.findGroup(calibratorDeviceLabel); - if (!calibratorDeviceOptions.fromConfigFile(calibratorFilePath)) + if (calibratorDeviceGroup.isNull()) { - CD_ERROR("File %s does not exist or unsufficient permissions.\n", calibratorFilePath.c_str()); + CD_ERROR("Missing calibrator device group %s.\n", calibratorDeviceLabel.c_str()); return false; } + yarp::os::Property calibratorDeviceOptions; + calibratorDeviceOptions.fromString(calibratorDeviceGroup.toString(), false); + calibratorDeviceOptions.fromString(robotConfig.toString(), false); calibratorDeviceOptions.put("joints", wrapperDeviceOptions.find("joints")); + yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver; yarp::dev::PolyDriverDescriptor descriptor(calibratorDevice, "calibrator"); // key name enforced by CBW2::attachAll() calibratorDevices.push(descriptor); diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 1bb39d100..f72ba7e12 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -4,7 +4,6 @@ set(applications) set(contexts) -set(data) if(ENABLE_checkCanBus) list(APPEND contexts contexts/checkCanBus) @@ -16,7 +15,6 @@ endif() if(ENABLE_launchCanBus) list(APPEND contexts contexts/launchCanBus) - list(APPEND data hardware) endif() if(ENABLE_SpaceNavigator) @@ -32,6 +30,3 @@ yarp_install(DIRECTORY ${applications} yarp_install(DIRECTORY ${contexts} DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) - -yarp_install(DIRECTORY ${data} - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_DATA_INSTALL_DIR}) diff --git a/share/hardware/drivers/ipos-3602-mx.ini b/share/hardware/drivers/ipos-3602-mx.ini deleted file mode 100644 index c1eb9c30c..000000000 --- a/share/hardware/drivers/ipos-3602-mx.ini +++ /dev/null @@ -1,4 +0,0 @@ -// ipos-3602-mx.ini -name "ipos-3602-mx" -description "iPOS3602 MX Intelligent Drive (75 W, CANopen / EtherCAT)" -maxCurrent 3.2 diff --git a/share/hardware/drivers/ipos-3604-mx.ini b/share/hardware/drivers/ipos-3604-mx.ini deleted file mode 100644 index a21a20bdc..000000000 --- a/share/hardware/drivers/ipos-3604-mx.ini +++ /dev/null @@ -1,4 +0,0 @@ -// ipos-3604-mx.ini -name "ipos-3604-mx" -description "iPOS3604 MX Intelligent Drive (144 W, CANopen / EtherCAT)" -maxCurrent 10.0 diff --git a/share/hardware/drivers/ipos-4808-mx.ini b/share/hardware/drivers/ipos-4808-mx.ini deleted file mode 100644 index 405ad41aa..000000000 --- a/share/hardware/drivers/ipos-4808-mx.ini +++ /dev/null @@ -1,4 +0,0 @@ -// ipos-4808-mx.ini -name "ipos-4808-mx" -description "iPOS4808 MX Intelligent Drive (400 W, CANopen / EtherCAT)" -maxCurrent 20.0 diff --git a/share/hardware/encoders/cui-amt-203-v.ini b/share/hardware/encoders/cui-amt-203-v.ini deleted file mode 100644 index 57807befd..000000000 --- a/share/hardware/encoders/cui-amt-203-v.ini +++ /dev/null @@ -1,4 +0,0 @@ -// cui-amt-203-v.ini -name "cui-amt-203-v" -description "CUI encoder" -encoderPulses 4096 diff --git a/share/hardware/motors/maxon-339282.ini b/share/hardware/motors/maxon-339282.ini deleted file mode 100644 index ebad048e8..000000000 --- a/share/hardware/motors/maxon-339282.ini +++ /dev/null @@ -1,6 +0,0 @@ -// maxon-339282.ini -name "maxon-339282" -description "EC 45 flat Ø42.9 mm, brushless, 30 Watt, with Hall sensors" -url "https://www.maxongroup.com/maxon/view/product/339282" -k 0.0706 -pulsesPerSample 1000 diff --git a/share/hardware/motors/maxon-339287.ini b/share/hardware/motors/maxon-339287.ini deleted file mode 100644 index 799a22771..000000000 --- a/share/hardware/motors/maxon-339287.ini +++ /dev/null @@ -1,6 +0,0 @@ -// maxon-339287.ini -name "maxon-339287" -description "EC 45 flat Ø42.8 mm, brushless, 50 Watt, with Hall sensors" -url "https://www.maxongroup.com/maxon/view/product/339287" -k 0.101 -pulsesPerSample 1000 diff --git a/share/hardware/motors/maxon-400108.ini b/share/hardware/motors/maxon-400108.ini deleted file mode 100644 index 1d37b4179..000000000 --- a/share/hardware/motors/maxon-400108.ini +++ /dev/null @@ -1,6 +0,0 @@ -// maxon-400108.ini -name "maxon-400108" -description "EC 45 flat Ø45 mm, brushless, 50 W, with Hall sensors, with cable" -url "https://www.maxongroup.com/maxon/view/product/400108" -k 0.101 -pulsesPerSample 1000 diff --git a/share/hardware/motors/maxon-402686.ini b/share/hardware/motors/maxon-402686.ini deleted file mode 100644 index bb8328282..000000000 --- a/share/hardware/motors/maxon-402686.ini +++ /dev/null @@ -1,6 +0,0 @@ -// maxon-402686.ini -name "maxon-402686" -description "EC 45 flat Ø42.8 mm, brushless, 70 Watt, with Hall sensors" -url "https://www.maxongroup.com/maxon/view/product/402686" -k 0.0533 -pulsesPerSample 1000 diff --git a/share/hardware/motors/maxon-411815.ini b/share/hardware/motors/maxon-411815.ini deleted file mode 100644 index 834668d3d..000000000 --- a/share/hardware/motors/maxon-411815.ini +++ /dev/null @@ -1,6 +0,0 @@ -// maxon-411815.ini -name "maxon-411815" -description "EC 45 flat Ø45 mm, brushless, 70 W, with Hall sensors, with cable" -url "https://www.maxongroup.com/maxon/view/product/411815" -k 0.0533 -pulsesPerSample 1000 diff --git a/share/hardware/transmissions/hd-100.ini b/share/hardware/transmissions/hd-100.ini deleted file mode 100644 index d6e627525..000000000 --- a/share/hardware/transmissions/hd-100.ini +++ /dev/null @@ -1,4 +0,0 @@ -// hd-100.ini -name "hd-100" -description "Harmonic Drive 100" -tr 100.0 diff --git a/share/hardware/transmissions/hd-160.ini b/share/hardware/transmissions/hd-160.ini deleted file mode 100644 index 0c6255d73..000000000 --- a/share/hardware/transmissions/hd-160.ini +++ /dev/null @@ -1,4 +0,0 @@ -// hd-160.ini -name "hd-160" -description "Harmonic Drive 160" -tr 160.0 From d8320768d92f28c6e30db5086ac8ccfec1700548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Thu, 28 Nov 2019 16:17:55 +0100 Subject: [PATCH 10/12] Install ymanager.ini --- share/CMakeLists.txt | 7 +++++-- .../{ => yarpmanager}/spaceNavigator/spaceNavigator.xml | 0 share/applications/{ => yarpmanager}/ymanager.ini | 0 3 files changed, 5 insertions(+), 2 deletions(-) rename share/applications/{ => yarpmanager}/spaceNavigator/spaceNavigator.xml (100%) rename share/applications/{ => yarpmanager}/ymanager.ini (100%) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index f72ba7e12..49a9795ce 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -18,15 +18,18 @@ if(ENABLE_launchCanBus) endif() if(ENABLE_SpaceNavigator) - list(APPEND applications applications/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) + yarp_install(DIRECTORY ${applications} - DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}) + DESTINATION ${ROBOTICSLAB-YARP-DEVICES_APPLICATIONS_INSTALL_DIR}/yarpmanager) yarp_install(DIRECTORY ${contexts} DESTINATION ${ROBOTICSLAB-YARP-DEVICES_CONTEXTS_INSTALL_DIR}) diff --git a/share/applications/spaceNavigator/spaceNavigator.xml b/share/applications/yarpmanager/spaceNavigator/spaceNavigator.xml similarity index 100% rename from share/applications/spaceNavigator/spaceNavigator.xml rename to share/applications/yarpmanager/spaceNavigator/spaceNavigator.xml diff --git a/share/applications/ymanager.ini b/share/applications/yarpmanager/ymanager.ini similarity index 100% rename from share/applications/ymanager.ini rename to share/applications/yarpmanager/ymanager.ini From d8c5f8591a4f5c937daac1c18685b9380f95e823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Thu, 28 Nov 2019 18:13:15 +0100 Subject: [PATCH 11/12] Read gearbox data, use extra tr value --- libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp index 8f1171fca..8a01972a6 100644 --- a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp @@ -20,15 +20,16 @@ bool TechnosoftIpos::open(yarp::os::Searchable & config) yarp::os::Bottle & driverGroup = config.findGroup("driver"); yarp::os::Bottle & motorGroup = config.findGroup("motor"); - yarp::os::Bottle & transmissionGroup = config.findGroup("transmission"); + yarp::os::Bottle & gearboxGroup = config.findGroup("gearbox"); yarp::os::Bottle & encoderGroup = config.findGroup("encoder"); // mutable variables - vars.tr = transmissionGroup.check("tr", yarp::os::Value(0.0), "reduction").asFloat64(); + vars.tr = gearboxGroup.check("tr", yarp::os::Value(0.0), "reduction").asFloat64(); vars.k = motorGroup.check("k", yarp::os::Value(0.0), "motor constant").asFloat64(); vars.encoderPulses = encoderGroup.check("encoderPulses", yarp::os::Value(0), "encoderPulses").asInt32(); vars.pulsesPerSample = motorGroup.check("pulsesPerSample", yarp::os::Value(0), "pulsesPerSample").asInt32(); + vars.tr = vars.tr * config.check("extraTr", yarp::os::Value(1.0), "extra reduction").asFloat64(); vars.actualControlMode = VOCAB_CM_NOT_CONFIGURED; // immutable variables From b752d18ea8d3bd898083632c3a4d13d35e7c36d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Thu, 28 Nov 2019 20:17:51 +0100 Subject: [PATCH 12/12] Tweak moar config params, clean stuff in DeviceDriver::open --- .../CanBusControlboard/CanBusControlboard.hpp | 7 +-- .../CanBusControlboard/DeviceDriverImpl.cpp | 47 ++++++++++--------- .../YarpPlugins/CanBusHico/CanBusHico.hpp | 22 ++++----- .../CanBusHico/DeviceDriverImpl.cpp | 14 +++--- .../YarpPlugins/CanBusPeak/CanBusPeak.hpp | 20 ++++---- .../CanBusPeak/DeviceDriverImpl.cpp | 12 ++--- .../TechnosoftIpos/DeviceDriverImpl.cpp | 6 +-- 7 files changed, 64 insertions(+), 64 deletions(-) diff --git a/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp b/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp index 5934a2da6..dfc6b6a2b 100644 --- a/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp +++ b/libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp @@ -17,9 +17,6 @@ #define CHECK_JOINT(j) do { int n = deviceMapper.getControlledAxes(); if ((j) < 0 || (j) > n - 1) return false; } while (0) -#define DEFAULT_MODE "position" -#define DEFAULT_CUI_TIMEOUT 1.0 -#define DEFAULT_CAN_BUS "CanBusHico" #define DEFAULT_LIN_INTERP_PERIOD_MS 50 #define DEFAULT_LIN_INTERP_BUFFER_SIZE 1 #define DEFAULT_LIN_INTERP_MODE "pt" @@ -28,8 +25,8 @@ #define DEFAULT_CAN_TX_BUFFER_SIZE 500 #define DEFAULT_CAN_RX_PERIOD_MS -1 #define DEFAULT_CAN_TX_PERIOD_MS 1.0 -#define DEFAULT_CAN_SDO_TIMEOUT_MS 25.0 -#define DEFAULT_CAN_DRIVE_STATE_TIMEOUT 2.5 +#define DEFAULT_CAN_SDO_TIMEOUT_MS 25.0 // FIXME unused +#define DEFAULT_CAN_DRIVE_STATE_TIMEOUT 2.5 // FIXME unused namespace roboticslab { diff --git a/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp b/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp index 55b5601fd..201c27463 100644 --- a/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/CanBusControlboard/DeviceDriverImpl.cpp @@ -20,20 +20,20 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) return false; } - std::string bus = config.find("bus").asString(); + std::string canBus = config.find("bus").asString(); yarp::os::Bottle * nodes = config.find("nodes").asList(); - if (bus.empty() || nodes == nullptr) + if (canBus.empty() || nodes == nullptr) { CD_ERROR("Illegal key(s): empty \"bus\" or nullptr \"nodes\".\n"); return false; } - yarp::os::Bottle & canBusGroup = config.findGroup(bus); + yarp::os::Bottle & canBusGroup = config.findGroup(canBus); if (canBusGroup.isNull()) { - CD_ERROR("Missing CAN bus device group %s.\n", bus.c_str()); + CD_ERROR("Missing CAN bus device group %s.\n", canBus.c_str()); return false; } @@ -42,7 +42,7 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) canBusOptions.fromString(config.toString(), false); canBusOptions.put("canBlockingMode", false); // enforce non-blocking mode canBusOptions.put("canAllowPermissive", false); // always check usage requirements - canBusOptions.setMonitor(config.getMonitor(), bus.c_str()); + canBusOptions.setMonitor(config.getMonitor(), canBus.c_str()); if (!canBusDevice.open(canBusOptions)) { @@ -52,7 +52,7 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) if (!canBusDevice.view(iCanBus)) { - CD_ERROR("Cannot view ICanBus interface in device: %s.\n", bus.c_str()); + CD_ERROR("Cannot view ICanBus interface in device: %s.\n", canBus.c_str()); return false; } @@ -60,21 +60,24 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) if (!canBusDevice.view(iCanBufferFactory)) { - CD_ERROR("Cannot view ICanBufferFactory interface in device: %s.\n", bus.c_str()); + CD_ERROR("Cannot view ICanBufferFactory interface in device: %s.\n", canBus.c_str()); return false; } iCanBusSharers.resize(nodes->size()); - int cuiTimeout = config.check("waitEncoder", yarp::os::Value(DEFAULT_CUI_TIMEOUT), "CUI timeout (seconds)").asInt32(); - - std::string canBusType = config.check("canBusType", yarp::os::Value(DEFAULT_CAN_BUS), "CAN bus device name").asString(); int canRxBufferSize = config.check("canBusRxBufferSize", yarp::os::Value(DEFAULT_CAN_RX_BUFFER_SIZE), "CAN bus RX buffer size").asInt(); int canTxBufferSize = config.check("canBusTxBufferSize", yarp::os::Value(DEFAULT_CAN_TX_BUFFER_SIZE), "CAN bus TX buffer size").asInt(); double canRxPeriodMs = config.check("canRxPeriodMs", yarp::os::Value(DEFAULT_CAN_RX_PERIOD_MS), "CAN bus RX period (milliseconds)").asFloat64(); double canTxPeriodMs = config.check("canTxPeriodMs", yarp::os::Value(DEFAULT_CAN_TX_PERIOD_MS), "CAN bus TX period (milliseconds)").asFloat64(); - double canSdoTimeoutMs = config.check("canSdoTimeoutMs", yarp::os::Value(DEFAULT_CAN_SDO_TIMEOUT_MS), "CAN bus SDO timeout (milliseconds)").asFloat64(); - double canDriveStateTimeout = config.check("canDriveStateTimeout", yarp::os::Value(DEFAULT_CAN_DRIVE_STATE_TIMEOUT), "CAN drive state timeout (seconds)").asFloat64(); + + canReaderThread = new CanReaderThread(canBus, iCanBusSharers); + canReaderThread->setCanHandles(iCanBus, iCanBufferFactory, canRxBufferSize); + canReaderThread->setPeriod(canRxPeriodMs); + + canWriterThread = new CanWriterThread(canBus); + canWriterThread->setCanHandles(iCanBus, iCanBufferFactory, canTxBufferSize); + canWriterThread->setPeriod(canTxPeriodMs); linInterpPeriodMs = config.check("linInterpPeriodMs", yarp::os::Value(DEFAULT_LIN_INTERP_PERIOD_MS), "linear interpolation mode period (milliseconds)").asInt32(); linInterpBufferSize = config.check("linInterpBufferSize", yarp::os::Value(DEFAULT_LIN_INTERP_BUFFER_SIZE), "linear interpolation mode buffer size").asInt32(); @@ -133,17 +136,17 @@ bool CanBusControlboard::open(yarp::os::Searchable & config) } } - const std::string canDevice = canBusOptions.find("canDevice").asString(); - - canReaderThread = new CanReaderThread(canDevice, iCanBusSharers); - canReaderThread->setCanHandles(iCanBus, iCanBufferFactory, canRxBufferSize); - canReaderThread->setPeriod(canRxPeriodMs); - canReaderThread->start(); + if (!canReaderThread->start()) + { + CD_ERROR("Unable to start reader thread.\n"); + return false; + } - canWriterThread = new CanWriterThread(canDevice); - canWriterThread->setCanHandles(iCanBus, iCanBufferFactory, canTxBufferSize); - canWriterThread->setPeriod(canTxPeriodMs); - canWriterThread->start(); + if (!canWriterThread->start()) + { + CD_ERROR("Unable to start writer thread.\n"); + return false; + } for (auto p : iCanBusSharers) { diff --git a/libraries/YarpPlugins/CanBusHico/CanBusHico.hpp b/libraries/YarpPlugins/CanBusHico/CanBusHico.hpp index dc2db2438..0e5f5724d 100644 --- a/libraries/YarpPlugins/CanBusHico/CanBusHico.hpp +++ b/libraries/YarpPlugins/CanBusHico/CanBusHico.hpp @@ -17,18 +17,18 @@ #include "hico_api.h" #include "HicoCanMessage.hpp" -#define DEFAULT_CAN_DEVICE "/dev/can0" -#define DEFAULT_CAN_BITRATE 1000000 +#define DEFAULT_PORT "/dev/can0" +#define DEFAULT_BITRATE 1000000 -#define DEFAULT_CAN_RX_TIMEOUT_MS 1 -#define DEFAULT_CAN_TX_TIMEOUT_MS 0 // '0' means no timeout +#define DEFAULT_RX_TIMEOUT_MS 1 +#define DEFAULT_TX_TIMEOUT_MS 0 // '0' means no timeout -#define DEFAULT_CAN_BLOCKING_MODE true -#define DEFAULT_CAN_ALLOW_PERMISSIVE false +#define DEFAULT_BLOCKING_MODE true +#define DEFAULT_ALLOW_PERMISSIVE false #define DELAY 0.001 // [s] -#define DEFAULT_CAN_FILTER_CONFIGURATION "disabled" +#define DEFAULT_FILTER_CONFIGURATION "disabled" namespace roboticslab { @@ -51,10 +51,10 @@ class CanBusHico : public yarp::dev::DeviceDriver, public: CanBusHico() : fileDescriptor(0), - rxTimeoutMs(DEFAULT_CAN_RX_TIMEOUT_MS), - txTimeoutMs(DEFAULT_CAN_TX_TIMEOUT_MS), - blockingMode(DEFAULT_CAN_BLOCKING_MODE), - allowPermissive(DEFAULT_CAN_ALLOW_PERMISSIVE), + rxTimeoutMs(DEFAULT_RX_TIMEOUT_MS), + txTimeoutMs(DEFAULT_TX_TIMEOUT_MS), + blockingMode(DEFAULT_BLOCKING_MODE), + allowPermissive(DEFAULT_ALLOW_PERMISSIVE), filterManager(NULL), filterConfig(FilterManager::DISABLED) {} diff --git a/libraries/YarpPlugins/CanBusHico/DeviceDriverImpl.cpp b/libraries/YarpPlugins/CanBusHico/DeviceDriverImpl.cpp index a04fb3bb6..abe07159e 100644 --- a/libraries/YarpPlugins/CanBusHico/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/CanBusHico/DeviceDriverImpl.cpp @@ -19,18 +19,18 @@ bool roboticslab::CanBusHico::open(yarp::os::Searchable& config) { - std::string devicePath = config.check("canDevice", yarp::os::Value(DEFAULT_CAN_DEVICE), "CAN device path").asString(); - int bitrate = config.check("canBitrate", yarp::os::Value(DEFAULT_CAN_BITRATE), "CAN bitrate (bps)").asInt32(); + std::string devicePath = config.check("port", yarp::os::Value(DEFAULT_PORT), "CAN device path").asString(); + int bitrate = config.check("bitrate", yarp::os::Value(DEFAULT_BITRATE), "CAN bitrate (bps)").asInt32(); - blockingMode = config.check("canBlockingMode", yarp::os::Value(DEFAULT_CAN_BLOCKING_MODE), "CAN blocking mode enabled").asBool(); - allowPermissive = config.check("canAllowPermissive", yarp::os::Value(DEFAULT_CAN_ALLOW_PERMISSIVE), "CAN read/write permissive mode").asBool(); + blockingMode = config.check("blockingMode", yarp::os::Value(DEFAULT_BLOCKING_MODE), "CAN blocking mode enabled").asBool(); + allowPermissive = config.check("allowPermissive", yarp::os::Value(DEFAULT_ALLOW_PERMISSIVE), "CAN read/write permissive mode").asBool(); if (blockingMode) { CD_INFO("Blocking mode enabled for CAN device: %s.\n", devicePath.c_str()); - rxTimeoutMs = config.check("canRxTimeoutMs", yarp::os::Value(DEFAULT_CAN_RX_TIMEOUT_MS), "CAN RX timeout (milliseconds)").asInt32(); - txTimeoutMs = config.check("canTxTimeoutMs", yarp::os::Value(DEFAULT_CAN_TX_TIMEOUT_MS), "CAN TX timeout (milliseconds)").asInt32(); + rxTimeoutMs = config.check("rxTimeoutMs", yarp::os::Value(DEFAULT_RX_TIMEOUT_MS), "CAN RX timeout (milliseconds)").asInt32(); + txTimeoutMs = config.check("txTimeoutMs", yarp::os::Value(DEFAULT_TX_TIMEOUT_MS), "CAN TX timeout (milliseconds)").asInt32(); if (rxTimeoutMs <= 0) { @@ -49,7 +49,7 @@ bool roboticslab::CanBusHico::open(yarp::os::Searchable& config) CD_INFO("Permissive mode flag for read/write operations on CAN device %s: %d.\n", devicePath.c_str(), allowPermissive); - std::string filterConfigStr = config.check("canFilterConfiguration", yarp::os::Value(DEFAULT_CAN_FILTER_CONFIGURATION), + std::string filterConfigStr = config.check("filterConfiguration", yarp::os::Value(DEFAULT_FILTER_CONFIGURATION), "CAN filter configuration (disabled|noRange|maskAndRange)").asString(); CD_INFO("CAN filter configuration for CAN device %s: %s.\n", devicePath.c_str(), filterConfigStr.c_str()); diff --git a/libraries/YarpPlugins/CanBusPeak/CanBusPeak.hpp b/libraries/YarpPlugins/CanBusPeak/CanBusPeak.hpp index 3b5dc391c..2dfb74de7 100644 --- a/libraries/YarpPlugins/CanBusPeak/CanBusPeak.hpp +++ b/libraries/YarpPlugins/CanBusPeak/CanBusPeak.hpp @@ -15,14 +15,14 @@ #include "PeakCanMessage.hpp" -#define DEFAULT_CAN_DEVICE "/dev/pcan0" -#define DEFAULT_CAN_BITRATE 1000000 +#define DEFAULT_PORT "/dev/pcan0" +#define DEFAULT_BITRATE 1000000 -#define DEFAULT_CAN_RX_TIMEOUT_MS 1 -#define DEFAULT_CAN_TX_TIMEOUT_MS 0 // '0' means no timeout +#define DEFAULT_RX_TIMEOUT_MS 1 +#define DEFAULT_TX_TIMEOUT_MS 0 // '0' means no timeout -#define DEFAULT_CAN_BLOCKING_MODE true -#define DEFAULT_CAN_ALLOW_PERMISSIVE false +#define DEFAULT_BLOCKING_MODE true +#define DEFAULT_ALLOW_PERMISSIVE false namespace roboticslab { @@ -76,10 +76,10 @@ class CanBusPeak : public yarp::dev::DeviceDriver, public: CanBusPeak() : fileDescriptor(0), - rxTimeoutMs(DEFAULT_CAN_RX_TIMEOUT_MS), - txTimeoutMs(DEFAULT_CAN_TX_TIMEOUT_MS), - blockingMode(DEFAULT_CAN_BLOCKING_MODE), - allowPermissive(DEFAULT_CAN_ALLOW_PERMISSIVE) + rxTimeoutMs(DEFAULT_RX_TIMEOUT_MS), + txTimeoutMs(DEFAULT_TX_TIMEOUT_MS), + blockingMode(DEFAULT_BLOCKING_MODE), + allowPermissive(DEFAULT_ALLOW_PERMISSIVE) {} // --------- DeviceDriver declarations. Implementation in DeviceDriverImpl.cpp --------- diff --git a/libraries/YarpPlugins/CanBusPeak/DeviceDriverImpl.cpp b/libraries/YarpPlugins/CanBusPeak/DeviceDriverImpl.cpp index fad3c79a4..c97d6b35b 100644 --- a/libraries/YarpPlugins/CanBusPeak/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/CanBusPeak/DeviceDriverImpl.cpp @@ -12,12 +12,12 @@ bool roboticslab::CanBusPeak::open(yarp::os::Searchable& config) { - std::string devicePath = config.check("canDevice", yarp::os::Value(DEFAULT_CAN_DEVICE), "CAN device path").asString(); + std::string devicePath = config.check("port", yarp::os::Value(DEFAULT_PORT), "CAN device path").asString(); - int bitrate = config.check("canBitrate", yarp::os::Value(DEFAULT_CAN_BITRATE), "CAN bitrate (bps)").asInt32(); + int bitrate = config.check("bitrate", yarp::os::Value(DEFAULT_BITRATE), "CAN bitrate (bps)").asInt32(); - blockingMode = config.check("canBlockingMode", yarp::os::Value(DEFAULT_CAN_BLOCKING_MODE), "CAN blocking mode enabled").asBool(); - allowPermissive = config.check("canAllowPermissive", yarp::os::Value(DEFAULT_CAN_ALLOW_PERMISSIVE), "CAN read/write permissive mode").asBool(); + blockingMode = config.check("blockingMode", yarp::os::Value(DEFAULT_BLOCKING_MODE), "blocking mode enabled").asBool(); + allowPermissive = config.check("allowPermissive", yarp::os::Value(DEFAULT_ALLOW_PERMISSIVE), "read/write permissive mode").asBool(); int flags = OFD_BITRATE | PCANFD_INIT_STD_MSG_ONLY; @@ -25,8 +25,8 @@ bool roboticslab::CanBusPeak::open(yarp::os::Searchable& config) { CD_INFO("Blocking mode enabled for CAN device: %s.\n", devicePath.c_str()); - rxTimeoutMs = config.check("canRxTimeoutMs", yarp::os::Value(DEFAULT_CAN_RX_TIMEOUT_MS), "RX timeout (milliseconds)").asInt32(); - txTimeoutMs = config.check("canTxTimeoutMs", yarp::os::Value(DEFAULT_CAN_TX_TIMEOUT_MS), "TX timeout (milliseconds)").asInt32(); + rxTimeoutMs = config.check("rxTimeoutMs", yarp::os::Value(DEFAULT_RX_TIMEOUT_MS), "RX timeout (milliseconds)").asInt32(); + txTimeoutMs = config.check("txTimeoutMs", yarp::os::Value(DEFAULT_TX_TIMEOUT_MS), "TX timeout (milliseconds)").asInt32(); if (rxTimeoutMs <= 0) { diff --git a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp index 8a01972a6..17d28e602 100644 --- a/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp +++ b/libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp @@ -33,10 +33,10 @@ bool TechnosoftIpos::open(yarp::os::Searchable & config) vars.actualControlMode = VOCAB_CM_NOT_CONFIGURED; // immutable variables - vars.drivePeakCurrent = driverGroup.check("drivePeakCurrent", yarp::os::Value(0.0), "peak drive current (amperes)").asFloat64(); + vars.drivePeakCurrent = driverGroup.check("peakCurrent", yarp::os::Value(0.0), "peak drive current (amperes)").asFloat64(); vars.maxVel = config.check("maxVel", yarp::os::Value(0.0), "maxVel (meters/second or degrees/second)").asFloat64(); - vars.axisName = config.check("axisName", yarp::os::Value(""), "axis name").asString(); - vars.jointType = config.check("jointType", yarp::os::Value(yarp::dev::VOCAB_JOINTTYPE_UNKNOWN), "joint type [atrv|atpr|unkn]").asVocab(); + vars.axisName = config.check("name", yarp::os::Value(""), "axis name").asString(); + vars.jointType = config.check("type", yarp::os::Value(yarp::dev::VOCAB_JOINTTYPE_UNKNOWN), "joint type [atrv|atpr|unkn]").asVocab(); vars.reverse = config.check("reverse", yarp::os::Value(false), "reverse motor encoder counts").asBool(); vars.min = config.check("min", yarp::os::Value(0.0), "min (meters or degrees)").asFloat64(); vars.max = config.check("max", yarp::os::Value(0.0), "max (meters or degrees)").asFloat64();