YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ControlBoardServerImpl.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
7#include <yarp/os/LogStream.h>
9
12using namespace yarp::os;
13using namespace yarp::dev;
14using namespace std;
15
16namespace {
17YARP_LOG_COMPONENT(CB_RPC, "yarp.device.controlBoard_nws_yarp")
18}
19
20// IJointBraked RPC methods
21
23{
24 std::lock_guard<std::mutex> lg(m_mutex);
26 if (!m_iJointBrake)
27 {
28 yCError(CB_RPC, "Invalid interface");
29 ret.ret = ReturnValue::return_code::return_value_error_not_ready;
30 return ret;
31 }
32
33 ret.ret = m_iJointBrake->isJointBraked(j, ret.isBraked);
34 if (!ret.ret)
35 {
36 yCError(CB_RPC, "isJointBraked() failed");
37 }
38 return ret;
39}
40
41ReturnValue ControlBoardRPCd::setManualBrakeActiveRPC(const std::int32_t j, const bool active)
42{
43 std::lock_guard<std::mutex> lg(m_mutex);
45 if (!m_iJointBrake) {
46 yCError(CB_RPC, "Invalid interface");
47 ret = ReturnValue::return_code::return_value_error_not_ready;
48 return ret;
49 }
50
51 ret = m_iJointBrake->setManualBrakeActive(j, active);
52 if (!ret) {
53 yCError(CB_RPC, "setManualBrakeActive() failed");
54 }
55 return ret;
56}
57
58ReturnValue ControlBoardRPCd::setAutoBrakeEnabledRPC(const std::int32_t j, const bool enabled)
59{
60 std::lock_guard<std::mutex> lg(m_mutex);
62 if (!m_iJointBrake) {
63 yCError(CB_RPC, "Invalid interface");
64 ret = ReturnValue::return_code::return_value_error_not_ready;
65 return ret;
66 }
67
68 ret = m_iJointBrake->setAutoBrakeEnabled(j, enabled);
69 if (!ret) {
70 yCError(CB_RPC, "setAutoBrakeEnabled() failed");
71 }
72 return ret;
73}
74
76{
77 std::lock_guard<std::mutex> lg(m_mutex);
79 if (!m_iJointBrake) {
80 yCError(CB_RPC, "Invalid interface");
81 ret.ret = ReturnValue::return_code::return_value_error_not_ready;
82 return ret;
83 }
84
85 ret.ret = m_iJointBrake->getAutoBrakeEnabled(j, ret.enabled);
86 if (!ret.ret) {
87 yCError(CB_RPC, "getAutoBrakeEnabled() failed");
88 }
89 return ret;
90}
91
92// IVelocityDirect RPC methods
93
95{
96 std::lock_guard<std::mutex> lg(m_mutex);
98 if (!m_iVelocityDirect) {
99 yCError(CB_RPC, "Invalid IVelocityDirect interface");
101 return ret;
102 }
103 ret.ret = m_iVelocityDirect->getDesiredVelocity(j, ret.vel);
104 if (!ret.ret) {
105 yCError(CB_RPC, "getDesiredVelocity() failed");
106 }
107 return ret;
108}
109
111{
112 std::lock_guard<std::mutex> lg(m_mutex);
114 if (!m_iVelocityDirect) {
115 yCError(CB_RPC, "Invalid IVelocityDirect interface");
117 return ret;
118 }
119 ret.ret = m_iVelocityDirect->getDesiredVelocity(ret.vel);
120 if (!ret.ret) {
121 yCError(CB_RPC, "getDesiredVelocity() failed");
122 }
123 return ret;
124}
125
127{
128 std::lock_guard<std::mutex> lg(m_mutex);
130 if (!m_iVelocityDirect) {
131 yCError(CB_RPC, "Invalid IVelocityDirect interface");
133 return ret;
134 }
135 ret.ret = m_iVelocityDirect->getDesiredVelocity(jnts, ret.vel);
136 if (!ret.ret) {
137 yCError(CB_RPC, "getDesiredVelocity() failed");
138 }
139 return ret;
140}
141
143{
144 std::lock_guard<std::mutex> lg(m_mutex);
146 if (!m_iVelocityDirect) {
147 yCError(CB_RPC, "Invalid IVelocityDirect interface");
149 return ret;
150 }
151 size_t axes=0;
152 ret.ret = m_iVelocityDirect->getAxes(axes);
153 if (!ret.ret) {
154 yCError(CB_RPC, "getAxes() failed");
155 }
156 ret.axes = axes;
157 return ret;
158}
bool ret
return_getAxes getAxesRPC() const override
return_getDesiredVelocityOne getDesiredVelocityOneRPC(const std::int32_t j) const override
yarp::dev::ReturnValue setManualBrakeActiveRPC(const std::int32_t j, const bool active) override
return_getDesiredVelocityGroup getDesiredVelocityGroupRPC(const std::vector< std::int32_t > &jnts) const override
yarp::dev::ReturnValue setAutoBrakeEnabledRPC(const std::int32_t j, const bool enabled) override
return_getDesiredVelocityAll getDesiredVelocityAllRPC() const override
return_isJointBraked isJointBrakedRPC(const std::int32_t j) const override
return_getAutoBrakeEnabled getAutoBrakeEnabledRPC(const std::int32_t j) const override
virtual yarp::dev::ReturnValue setAutoBrakeEnabled(int j, bool enabled)=0
Enables/Disables the automatic joint brake.
virtual yarp::dev::ReturnValue isJointBraked(int j, bool &braked) const =0
Check is the joint brake is currently active.
virtual yarp::dev::ReturnValue getAutoBrakeEnabled(int j, bool &enabled) const =0
checks if the automatic joint brake mode is enabled or disabled.
virtual yarp::dev::ReturnValue setManualBrakeActive(int j, bool active)=0
Enables/Disables manually the joint brake.
virtual yarp::dev::ReturnValue getDesiredVelocity(const int jnt, double &vel)=0
Get the last reference velocity set by setDesiredVelocity() for a single joint.
virtual yarp::dev::ReturnValue getAxes(size_t &axes)=0
Get the number of controlled axes.
@ return_value_error_not_ready
Method failed due to invalid internal status/invalid request.
A mini-server for performing network communication in the background.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
STL namespace.
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.