Skip to content

Commit

Permalink
Parse axis prefix name from config
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Aug 24, 2023
1 parent e3e935d commit 1f768c0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions libraries/DextraRawControlboardLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if(ENABLE_DextraRawControlboardLib)

add_library(DextraRawControlboardLib SHARED DextraRawControlboard.hpp
DextraRawControlboard.cpp
DeviceDriverImpl.cpp
IAxisInfoRawImpl.cpp
IControlLimitsRawImpl.cpp
IControlModeRawImpl.cpp
Expand Down
15 changes: 15 additions & 0 deletions libraries/DextraRawControlboardLib/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include "DextraRawControlboard.hpp"

using namespace roboticslab;

// -----------------------------------------------------------------------------

bool DextraRawControlboard::open(yarp::os::Searchable & config)
{
axisPrefix = config.check("axisPrefix", yarp::os::Value(""), "common refix for all axis names").asString();
return true;
}

// -----------------------------------------------------------------------------
6 changes: 6 additions & 0 deletions libraries/DextraRawControlboardLib/DextraRawControlboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define __DEXTRA_RAW_CONTROLBOARD_HPP__

#include <mutex>
#include <string>

#include <yarp/dev/ControlBoardInterfaces.h>

Expand Down Expand Up @@ -39,6 +40,10 @@ class DextraRawControlboard : public yarp::dev::DeviceDriver,
void acquireSynapseHandle(Synapse * synapse);
void destroySynapse();

// --------- DeviceDriver declarations. Implementation in DeviceDriverImpl.cpp ---------

bool open(yarp::os::Searchable & config) override;

// --------- IAxisInfoRaw declarations. Implementation in IAxisInfoRawImpl.cpp ---------

bool getAxisNameRaw(int axis, std::string & name) override;
Expand Down Expand Up @@ -128,6 +133,7 @@ class DextraRawControlboard : public yarp::dev::DeviceDriver,

protected:
Synapse * synapse {nullptr};
std::string axisPrefix;

private:
double getSetpoint(int j);
Expand Down
2 changes: 1 addition & 1 deletion libraries/DextraRawControlboardLib/IAxisInfoRawImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool DextraRawControlboard::getAxisNameRaw(int axis, std::string & name)
{
yCITrace(DEXTRA, id(), "%d", axis);
CHECK_JOINT(axis);
name = Synapse::LABELS[axis];
name = axisPrefix + Synapse::LABELS[axis];
return true;
}

Expand Down
24 changes: 12 additions & 12 deletions libraries/DextraRawControlboardLib/Synapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ constexpr int MESSAGE_SIZE = (FLOAT_SIZE + 1) * Synapse::DATA_POINTS;
constexpr unsigned char FINGER_ADDRESS[Synapse::DATA_POINTS] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};

const std::array<std::pair<Synapse::setpoint_t, Synapse::setpoint_t>, Synapse::DATA_POINTS> Synapse::LIMITS = {
{0, 90},
{0, 10},
{0, 20},
{0, 20},
{0, 20},
{0, 20}
{0.0f, 90.0f},
{0.0f, 10.0f},
{0.0f, 20.0f},
{0.0f, 20.0f},
{0.0f, 20.0f},
{0.0f, 20.0f}
};

const std::array<std::string, Synapse::DATA_POINTS> Synapse::LABELS = {
"abductor",
"thumb",
"index",
"middle",
"ring",
"pinky"
"HandAbductor",
"ThumbFinger",
"IndexFinger",
"MiddleFinger",
"RingFinger",
"PinkyFinger"
};

void Synapse::configure(void * handle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool DextraCanControlboard::open(yarp::os::Searchable & config)

acquireSynapseHandle(new CanSynapse(canId));

return true;
return DextraRawControlboard::open(config); // parses axisPrefix
}

// -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool DextraSerialControlboard::open(yarp::os::Searchable & config)

raw.acquireSynapseHandle(new SerialSynapse(iSerialDevice));

return true;
return raw.open(config); // parses axisPrefix
}

// -----------------------------------------------------------------------------
Expand Down

0 comments on commit 1f768c0

Please sign in to comment.