24 x->
view(stream_IPosCtrl);
25 x->
view(stream_IPosDirect);
27 x->
view(stream_ITorque);
29 x->
view(stream_ICurrent);
35 stream_IPosCtrl =
nullptr;
36 stream_IPosDirect =
nullptr;
37 stream_IVel =
nullptr;
38 stream_ITorque =
nullptr;
39 stream_IPWM =
nullptr;
40 stream_ICurrent =
nullptr;
46 if (stream_IPosCtrl) {
47 stream_IPosCtrl->getAxes(&stream_nJoints);
63 if (
static_cast<int>(cmdVector.
size()) > stream_nJoints) {
65 yCError(
CONTROLBOARD,
"Received command vector with number of elements bigger than axis controlled by this wrapper (cmd: %s requested jnts: %d received jnts: %d)\n", str.c_str(), stream_nJoints, (
int)cmdVector.
size());
68 if (cmdVector.
data() ==
nullptr) {
79 bool ok = stream_IPWM->setRefDutyCycle(b.
get(2).
asInt32(), cmdVector[0]);
89 bool ok = stream_IPWM->setRefDutyCycles(cmdVector.
data());
103 if (stream_ICurrent) {
104 bool ok = stream_ICurrent->setRefCurrent(b.
get(2).
asInt32(), cmdVector[0]);
106 yCError(
CONTROLBOARD,
"Errors while trying to command a streaming current message on single joint\n");
111 if (stream_ICurrent) {
112 bool ok = stream_ICurrent->setRefCurrents(cmdVector.
data());
114 yCError(
CONTROLBOARD,
"Errors while trying to command a streaming current message on all joints\n");
119 if (stream_ICurrent) {
122 if ((
static_cast<int>(jlut->
size()) != n_joints) && (
static_cast<int>(cmdVector.
size()) != n_joints)) {
123 yCError(
CONTROLBOARD,
"Received VOCAB_CURRENT_REF_GROUP size of joints vector or currents vector does not match the selected joint number\n");
126 int* joint_list =
new int[n_joints];
127 for (
int i = 0; i < n_joints; i++) {
132 bool ok = stream_ICurrent->setRefCurrents(n_joints, joint_list, cmdVector.
data());
134 yCError(
CONTROLBOARD,
"Error while trying to command a streaming current message on joint group\n");
143 yCError(
CONTROLBOARD,
"Unrecognized message while receiving on command port (%s)\n", str.c_str());
150 yCError(
CONTROLBOARD,
"Received VOCAB_POSITION_MODE this is an send invalid message on streaming port");
155 if (stream_IPosCtrl) {
156 bool ok = stream_IPosCtrl->positionMove(cmdVector.
data());
165 yCError(
CONTROLBOARD,
"Received VOCAB_VELOCITY_MODE this is an send invalid message on streaming port");
170 stream_IVel->velocityMove(b.
get(1).
asInt32(), cmdVector[0]);
175 bool ok = stream_IVel->velocityMove(cmdVector.
data());
183 if (stream_IPosDirect) {
184 bool ok = stream_IPosDirect->setPosition(b.
get(1).
asInt32(), cmdVector[0]);
192 if (stream_ITorque) {
193 bool ok = stream_ITorque->setRefTorque(b.
get(1).
asInt32(), cmdVector[0]);
195 yCError(
CONTROLBOARD,
"Errors while trying to command a streaming torque direct message on single joint\n");
201 if (stream_ITorque) {
202 bool ok = stream_ITorque->setRefTorques(cmdVector.
data());
204 yCError(
CONTROLBOARD,
"Errors while trying to command a streaming torque direct message on all joints\n");
210 if (stream_ITorque) {
213 if ((
static_cast<int>(jlut->
size()) != n_joints) && (
static_cast<int>(cmdVector.
size()) != n_joints)) {
214 yCError(
CONTROLBOARD,
"Received VOCAB_TORQUES_DIRECT_GROUP size of joints vector or torques vector does not match the selected joint number\n");
217 int* joint_list =
new int[n_joints];
218 for (
int i = 0; i < n_joints; i++) {
223 bool ok = stream_ITorque->setRefTorques(n_joints, joint_list, cmdVector.
data());
225 yCError(
CONTROLBOARD,
"Error while trying to command a streaming toruqe direct message on joint group\n");
233 if (stream_IPosDirect) {
236 if ((
static_cast<int>(jlut->
size()) != n_joints) && (
static_cast<int>(cmdVector.
size()) != n_joints)) {
237 yCError(
CONTROLBOARD,
"Received VOCAB_POSITION_DIRECT_GROUP size of joints vector or positions vector does not match the selected joint number\n");
240 int* joint_list =
new int[n_joints];
241 for (
int i = 0; i < n_joints; i++) {
246 bool ok = stream_IPosDirect->setPositions(n_joints, joint_list, cmdVector.
data());
248 yCError(
CONTROLBOARD,
"Error while trying to command a streaming position direct message on joint group\n");
256 if (stream_IPosDirect) {
257 bool ok = stream_IPosDirect->setPositions(cmdVector.
data());
259 yCError(
CONTROLBOARD,
"Error while trying to command a streaming position direct message on all joints\n");
268 if ((
static_cast<int>(jlut->
size()) != n_joints) && (
static_cast<int>(cmdVector.
size()) != n_joints)) {
269 yCError(
CONTROLBOARD,
"Received VOCAB_VELOCITY_MOVE_GROUP size of joints vector or positions vector does not match the selected joint number\n");
272 int* joint_list =
new int[n_joints];
273 for (
int i = 0; i < n_joints; i++) {
277 bool ok = stream_IVel->velocityMove(n_joints, joint_list, cmdVector.
data());
289 yCError(
CONTROLBOARD,
"Unrecognized message while receiving on command port (%s)\n", str.c_str());
const yarp::os::LogComponent & CONTROLBOARD()
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVE
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MODE
constexpr yarp::conf::vocab32_t VOCAB_POSITION_MODE
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVES
constexpr yarp::conf::vocab32_t VOCAB_POSITION_MOVES
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REF_GROUP
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REFS
constexpr yarp::conf::vocab32_t VOCAB_CURRENTCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REF
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_REF_PWMS
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_REF_PWM
constexpr yarp::conf::vocab32_t VOCAB_POSITION_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_POSITION_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_POSITION_DIRECT_GROUP
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT_GROUP
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVE_GROUP
void init(yarp::dev::DeviceDriver *x)
Initialization.
void onRead(CommandMessage &v) override
Callback function.
Interface implemented by all device drivers.
bool view(T *&x)
Get an interface to the device driver.
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Group a pair of objects to be sent and received together.
BODY body
An object of the second type (BODY).
HEAD head
An object of the first type (HEAD).
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
std::string toString(int precision=-1, int width=-1) const
Creates a string object containing a text representation of the object.
T * data()
Return a pointer to the first element of the vector.
#define yCError(component,...)
#define yCTrace(component,...)
An interface for the device drivers.
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
An interface to the operating system, including Port based communication.