YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementJointBrake.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
10
11#include <cstdio>
12using namespace yarp::dev;
13using namespace yarp::os;
14
15namespace {
16YARP_LOG_COMPONENT(IMPLEMENT_LAYER_COMPONENT, "yarp.ImplementJointBrake")
17}
18
20 m_helper(nullptr),
21 m_iraw(r)
22{}
23
24bool ImplementJointBrake::initialize(int size, const int* amap)
25{
26 if (m_helper != nullptr) {
27 return false;
28 }
29
30 m_helper=(void *)(new ControlBoardHelper(size, amap));
31 yAssert (m_helper != nullptr);
32
33 m_buffer_ints.resize (size);
34 m_buffer_doubles.resize(size);
35
36 return true;
37}
38
43
45{
46 if (m_helper!=nullptr)
47 {
48 delete castToMapper(m_helper);
49 m_helper=nullptr;
50 }
51
52 return true;
53}
54
56{
57 std::lock_guard lock(m_imp_mutex);
59
60 int k = castToMapper(m_helper)->toHw(j);
62}
63
65{
66 std::lock_guard lock(m_imp_mutex);
68
69 int k = castToMapper(m_helper)->toHw(j);
70 return m_iraw->setManualBrakeActiveRaw(k, active);
71}
72
74{
75 std::lock_guard lock(m_imp_mutex);
77
78 int k = castToMapper(m_helper)->toHw(j);
79 return m_iraw->setAutoBrakeEnabledRaw(k, enabled);
80}
81
83{
84 std::lock_guard lock(m_imp_mutex);
86
87 int k = castToMapper(m_helper)->toHw(j);
88 return m_iraw->getAutoBrakeEnabledRaw(k, enabled);
89}
yarp::dev::ControlBoardHelper * castToMapper(void *p)
#define yAssert(x)
Definition Log.h:388
Interface for controlling a joint equipped with brakes (hardware or simulated).
Definition IJointBrake.h:70
virtual yarp::dev::ReturnValue setManualBrakeActiveRaw(int j, bool active)=0
virtual yarp::dev::ReturnValue isJointBrakedRaw(int j, bool &braked) const =0
virtual yarp::dev::ReturnValue getAutoBrakeEnabledRaw(int j, bool &enabled) const =0
virtual yarp::dev::ReturnValue setAutoBrakeEnabledRaw(int j, bool enabled)=0
virtual yarp::dev::ReturnValue setManualBrakeActive(int j, bool active) override
Enables/Disables manually the joint brake.
ImplementJointBrake(yarp::dev::IJointBrakeRaw *y)
virtual yarp::dev::ReturnValue isJointBraked(int j, bool &braked) const override
Check is the joint brake is currently active.
yarp::dev::IJointBrakeRaw * m_iraw
virtual ~ImplementJointBrake()
Destructor.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
virtual yarp::dev::ReturnValue setAutoBrakeEnabled(int j, bool enabled) override
Enables/Disables the automatic joint brake.
std::vector< double > m_buffer_doubles
virtual yarp::dev::ReturnValue getAutoBrakeEnabled(int j, bool &enabled) const override
checks if the automatic joint brake mode is enabled or disabled.
A mini-server for performing network communication in the background.
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13