Skip to content

Commit 1a4f36a

Browse files
committed
[WIP]
1 parent 06d22f2 commit 1a4f36a

File tree

6 files changed

+516
-229
lines changed

6 files changed

+516
-229
lines changed

libraries/YarpPlugins/CanBusBroker/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if(NOT SKIP_CanBusBroker)
1010

1111
yarp_add_plugin(CanBusBroker CanBusBroker.hpp
1212
DeviceDriverImpl.cpp
13+
IMultipleWrapperImpl.cpp
1314
# control board interfaces
1415
motor/IAmplifierControlImpl.cpp
1516
motor/IAxisInfoImpl.cpp

libraries/YarpPlugins/CanBusBroker/CanBusBroker.hpp

+26-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
#ifndef __CAN_BUS_BROKER_HPP__
44
#define __CAN_BUS_BROKER_HPP__
55

6+
#include <map>
7+
#include <string>
8+
#include <tuple>
69
#include <vector>
710

11+
#include <yarp/dev/IMultipleWrapper.h>
812
#include <yarp/dev/ControlBoardInterfaces.h>
913
#include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
14+
#include <yarp/dev/PolyDriverList.h>
1015

1116
#include "DeviceMapper.hpp"
1217
#include "SingleBusBroker.hpp"
@@ -25,7 +30,7 @@ namespace roboticslab
2530

2631
/**
2732
* @ingroup CanBusBroker
28-
* @brief CAN-oriented control board that implements all YARP motor interfaces.
33+
* @brief CAN-oriented control board that implements all YARP motor and MAS interfaces.
2934
*
3035
* This control board wrapper subdevice exposes motor commands to CAN nodes
3136
* modelled as wrapped motor raw subdevices (i.e. devices which implement the
@@ -38,6 +43,7 @@ namespace roboticslab
3843
* <a href="https://github.com/roboticslab-uc3m/yarp-devices/issues/241#issuecomment-569112698">instructions</a>.
3944
*/
4045
class CanBusBroker : public yarp::dev::DeviceDriver,
46+
public yarp::dev::IMultipleWrapper,
4147
// control board interfaces
4248
public yarp::dev::IAmplifierControl,
4349
public yarp::dev::IAxisInfo,
@@ -79,6 +85,11 @@ class CanBusBroker : public yarp::dev::DeviceDriver,
7985
bool open(yarp::os::Searchable & config) override;
8086
bool close() override;
8187

88+
// -------- IMultipleWrapper declarations. Implementation in IMultipleWrapperImpl.cpp --------
89+
90+
bool attachAll(const yarp::dev::PolyDriverList & drivers) override;
91+
bool detachAll() override;
92+
8293
// ---------- CONTROL BOARD INTERFACES ----------
8394

8495
// --------- IAmplifierControl declarations. Implementation in IAmplifierControlImpl.cpp ---------
@@ -408,10 +419,22 @@ class CanBusBroker : public yarp::dev::DeviceDriver,
408419
bool getThreeAxisMagnetometerMeasure(std::size_t sens_index, yarp::sig::Vector & out, double & timestamp) const override;
409420

410421
private:
422+
bool attachBusDevice(const yarp::dev::PolyDriverDescriptor * device, int index);
423+
bool attachNodeDevice(const yarp::dev::PolyDriverDescriptor * device);
424+
411425
DeviceMapper deviceMapper;
412426

413-
std::vector<yarp::dev::PolyDriver *> busDevices;
414-
std::vector<yarp::dev::PolyDriver *> nodeDevices;
427+
std::map<std::string, std::vector<std::string>> deviceKeys;
428+
429+
std::vector<std::string> busNames;
430+
// std::map<std::string, std::pair<std::string, int>>
431+
std::vector<std::tuple<std::string, std::string, int>> deviceKeys2;
432+
433+
yarp::dev::PolyDriverList busDevices;
434+
yarp::dev::PolyDriverList nodeDevices;
435+
// std::vector<yarp::dev::PolyDriver *> busDevices;
436+
// std::vector<yarp::dev::PolyDriver *> nodeDevices;
437+
415438
std::vector<SingleBusBroker *> brokers;
416439

417440
SyncPeriodicThread * syncThread {nullptr};

0 commit comments

Comments
 (0)