YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementInteractionMode.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <cstdio>
7
12
13using namespace yarp::dev;
14using namespace yarp::os;
15#define JOINTIDCHECK if (j >= castToMapper(helper)->axes()){yError("joint id out of bound"); return false;}
16
18 iInteraction(class_p),
19 helper(nullptr),
20 imodeBuffManager(nullptr),
21 intBuffManager(nullptr)
22{;}
23
24
29
37{
38 return initialize(size, amap, nullptr, nullptr);
39}
40
41bool ImplementInteractionMode::initialize(int size, const int *amap, const double *enc, const double *zos)
42{
43 if (helper != nullptr) {
44 return false;
45 }
46
47 helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
48 yAssert(helper != nullptr);
49
51 yAssert (intBuffManager != nullptr);
52
54 yAssert (imodeBuffManager != nullptr);
55
56 return true;
57}
58
64{
65 if(helper != nullptr)
66 {
67 delete castToMapper(helper);
68 helper = nullptr;
69 }
70
72 {
73 delete intBuffManager;
74 intBuffManager=nullptr;
75 }
76
78 {
79 delete imodeBuffManager;
80 imodeBuffManager=nullptr;
81 }
82 return true;
83}
84
90
92{
93 if (!castToMapper(helper)->checkAxesIds(n_joints, joints)) {
94 return false;
95 }
96
98
99 for (int i = 0; i < n_joints; i++)
100 {
102 }
103 bool ret = iInteraction->getInteractionModesRaw(n_joints, buffJoints.getData(), modes);
104
106 return ret;
107}
108
125
131
133{
134 if (!castToMapper(helper)->checkAxesIds(n_joints, joints)) {
135 return false;
136 }
137
139
140 for(int idx=0; idx<n_joints; idx++)
141 {
143 }
144 bool ret = iInteraction->setInteractionModesRaw(n_joints, buffJoints.getData(), modes);
146 return ret;
147}
148
yarp::dev::ControlBoardHelper * castToMapper(void *p)
bool ret
#define yAssert(x)
Definition Log.h:388
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
virtual bool getInteractionModesRaw(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes)=0
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
virtual bool setInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum mode)=0
Set the interaction mode of the robot, values can be stiff or compliant.
virtual bool setInteractionModesRaw(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes)=0
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
virtual bool getInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum *mode)=0
Get the current interaction mode of the robot, values can be stiff or compliant.
bool setInteractionMode(int axis, yarp::dev::InteractionModeEnum mode) override
Set the interaction mode of the robot, values can be stiff or compliant.
bool getInteractionMode(int axis, yarp::dev::InteractionModeEnum *mode) override
Get the current interaction mode of the robot, values can be stiff or compliant.
yarp::dev::IInteractionModeRaw * iInteraction
bool setInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
yarp::dev::impl::FixedSizeBuffersManager< int > * intBuffManager
bool getInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool uninitialize()
Clean up internal data and memory.
yarp::dev::impl::FixedSizeBuffersManager< yarp::dev::InteractionModeEnum > * imodeBuffManager
ImplementInteractionMode(yarp::dev::IInteractionModeRaw *Class_p)
Constructor.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory, smaller version.
Buffer contains info about a buffer of type T and it is used to exchange information with yarp::dev::...
A manager of fixed size buffers in multi-thread environment.
Buffer< T > getBuffer()
Get a buffer and fill its information in @buffer.
void releaseBuffer(Buffer< T > &buffer)
Release a buffer.
A mini-server for performing network communication in the background.
For streams capable of holding different kinds of content, check what they actually have.
Definition jointData.cpp:13
An interface to the operating system, including Port based communication.