YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
INavigation2DVelocityActionsMsgs.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// Autogenerated by Thrift (based on compiler 0.14.1-yarped)
7// yarpidl_thrift version 2.0 - 11/11/2026
8// Protocol version: protocol_version=0, yarp_major=4, yarp_minor=0, yarp_patch=2
9// This is an automatically generated file.
10// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
11
12#include <yarp/conf/version.h>
15#include <yarp/os/LogStream.h>
16
18
19#include <algorithm>
20
21namespace
22{
23 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "INavigation2DVelocityActionsMsgs")
24}
25
26//INavigation2DVelocityActionsMsgs_getRemoteProtocolVersion_helper declaration
37
39{
40 yarp::os::idl::WireWriter writer(connection);
41 if (!writer.writeListHeader(1)) {
42 return false;
43 }
44 if (!writer.writeString("getRemoteProtocolVersion")) {
45 return false;
46 }
47 return true;
48}
49
50bool INavigation2DVelocityActionsMsgs_getRemoteProtocolVersion_helper ::read(yarp::os::ConnectionReader & connection)
51 {
52 yarp::os::idl::WireReader reader(connection);
53 if (!reader.readListHeader()) {
54 reader.fail();
55 return false;
56 }
57
58 if (!helper_proto.read(connection)) {
59 reader.fail();
60 return false;
61 }
62 return true;
63}
64
65//ProtocolVersion, client side
67 {
68 if(!yarp().canWrite()) {
69 yError(" Missing server method INavigation2DVelocityActionsMsgs::getRemoteProtocolVersion");
70 }
72 bool ok = yarp().write(helper, helper);
73 if (ok) {
74 return helper.helper_proto;}
75 else {
77 return failureproto;}
78}
79
80//ProtocolVersion, client side
82 {
83 auto locproto = this->getLocalProtocolVersion();
84 auto remproto = this->getRemoteProtocolVersion();
85 if (remproto.protocol_version != locproto.protocol_version)
86 {
87 yCError(SERVICE_LOG_COMPONENT) << "Invalid communication protocol.";
88 yCError(SERVICE_LOG_COMPONENT) << "Local Protocol Version: " << locproto.toString();
89 yCError(SERVICE_LOG_COMPONENT) << "Remote Protocol Version: " << remproto.toString();
90 return false;
91 }
92 return true;
93}
94
95//ProtocolVersion, server side
97{
99 //myproto.protocol_version using default value = 0
100 //to change this value add the following line to the .thrift file:
101 //const i16 protocol_version = <your_number_here>
102 myproto.protocol_version = 0;
106 return myproto;
107}
108
109// applyVelocityCommandRPC helper class declaration
111 public yarp::os::Portable
112{
113public:
115 INavigation2DVelocityActionsMsgs_applyVelocityCommandRPC_helper(const double x_vel, const double y_vel, const double theta_vel, const double timeout);
116 bool write(yarp::os::ConnectionWriter& connection) const override;
117 bool read(yarp::os::ConnectionReader& connection) override;
118
119 class Command :
121 {
122 public:
123 Command() = default;
124 Command(const double x_vel, const double y_vel, const double theta_vel, const double timeout);
125
126 ~Command() override = default;
127
128 bool write(yarp::os::ConnectionWriter& connection) const override;
129 bool read(yarp::os::ConnectionReader& connection) override;
130
131 bool write(const yarp::os::idl::WireWriter& writer) const override;
132 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
133 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
134
135 bool read(yarp::os::idl::WireReader& reader) override;
138
139 double x_vel{0.0};
140 double y_vel{0.0};
141 double theta_vel{0.0};
142 double timeout{0.0};
143 };
144
145 class Reply :
147 {
148 public:
149 Reply() = default;
150 ~Reply() override = default;
151
152 bool write(yarp::os::ConnectionWriter& connection) const override;
153 bool read(yarp::os::ConnectionReader& connection) override;
154
155 bool write(const yarp::os::idl::WireWriter& writer) const override;
156 bool read(yarp::os::idl::WireReader& reader) override;
157
159 };
160
161 using funcptr_t = yarp::dev::ReturnValue (*)(const double, const double, const double, const double);
163
166
167 static constexpr const char* s_tag{"applyVelocityCommandRPC"};
168 static constexpr size_t s_tag_len{1};
169 static constexpr size_t s_cmd_len{5};
170 static constexpr size_t s_reply_len{1};
171 static constexpr const char* s_prototype{"yarp::dev::ReturnValue INavigation2DVelocityActionsMsgs::applyVelocityCommandRPC(const double x_vel, const double y_vel, const double theta_vel, const double timeout)"};
172 static constexpr const char* s_help{""};
173};
174
175// getLastVelocityCommandRPC helper class declaration
177 public yarp::os::Portable
178{
179public:
181 bool write(yarp::os::ConnectionWriter& connection) const override;
182 bool read(yarp::os::ConnectionReader& connection) override;
183
184 class Command :
186 {
187 public:
188 Command() = default;
189 ~Command() override = default;
190
191 bool write(yarp::os::ConnectionWriter& connection) const override;
192 bool read(yarp::os::ConnectionReader& connection) override;
193
194 bool write(const yarp::os::idl::WireWriter& writer) const override;
195 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
196 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
197
198 bool read(yarp::os::idl::WireReader& reader) override;
201 };
202
203 class Reply :
205 {
206 public:
207 Reply() = default;
208 ~Reply() override = default;
209
210 bool write(yarp::os::ConnectionWriter& connection) const override;
211 bool read(yarp::os::ConnectionReader& connection) override;
212
213 bool write(const yarp::os::idl::WireWriter& writer) const override;
214 bool read(yarp::os::idl::WireReader& reader) override;
215
217 };
218
221
224
225 static constexpr const char* s_tag{"getLastVelocityCommandRPC"};
226 static constexpr size_t s_tag_len{1};
227 static constexpr size_t s_cmd_len{1};
228 static constexpr size_t s_reply_len{4};
229 static constexpr const char* s_prototype{"return_getLastVelocityCommand INavigation2DVelocityActionsMsgs::getLastVelocityCommandRPC()"};
230 static constexpr const char* s_help{""};
231};
232
233// applyVelocityCommandRPC helper class implementation
234INavigation2DVelocityActionsMsgs_applyVelocityCommandRPC_helper::INavigation2DVelocityActionsMsgs_applyVelocityCommandRPC_helper(const double x_vel, const double y_vel, const double theta_vel, const double timeout) :
235 cmd{x_vel, y_vel, theta_vel, timeout}
236{
237}
238
243
248
249INavigation2DVelocityActionsMsgs_applyVelocityCommandRPC_helper::Command::Command(const double x_vel, const double y_vel, const double theta_vel, const double timeout) :
250 x_vel{x_vel},
251 y_vel{y_vel},
252 theta_vel{theta_vel},
253 timeout{timeout}
254{
255}
256
258{
259 yarp::os::idl::WireWriter writer(connection);
260 if (!writer.writeListHeader(s_cmd_len)) {
261 return false;
262 }
263 return write(writer);
264}
265
267{
268 yarp::os::idl::WireReader reader(connection);
269 if (!reader.readListHeader()) {
270 reader.fail();
271 return false;
272 }
273 return read(reader);
274}
275
277{
278 if (!writeTag(writer)) {
279 return false;
280 }
281 if (!writeArgs(writer)) {
282 return false;
283 }
284 return true;
285}
286
288{
289 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
290 return false;
291 }
292 return true;
293}
294
296{
297 if (!writer.writeFloat64(x_vel)) {
298 return false;
299 }
300 if (!writer.writeFloat64(y_vel)) {
301 return false;
302 }
303 if (!writer.writeFloat64(theta_vel)) {
304 return false;
305 }
306 if (!writer.writeFloat64(timeout)) {
307 return false;
308 }
309 return true;
310}
311
313{
314 if (!readTag(reader)) {
315 return false;
316 }
317 if (!readArgs(reader)) {
318 return false;
319 }
320 return true;
321}
322
324{
325 std::string tag = reader.readTag(s_tag_len);
326 if (reader.isError()) {
327 return false;
328 }
329 if (tag != s_tag) {
330 reader.fail();
331 return false;
332 }
333 return true;
334}
335
337{
338 if (reader.noMore()) {
339 reader.fail();
340 return false;
341 }
342 if (!reader.readFloat64(x_vel)) {
343 reader.fail();
344 return false;
345 }
346 if (reader.noMore()) {
347 reader.fail();
348 return false;
349 }
350 if (!reader.readFloat64(y_vel)) {
351 reader.fail();
352 return false;
353 }
354 if (reader.noMore()) {
355 reader.fail();
356 return false;
357 }
358 if (!reader.readFloat64(theta_vel)) {
359 reader.fail();
360 return false;
361 }
362 if (reader.noMore()) {
363 reader.fail();
364 return false;
365 }
366 if (!reader.readFloat64(timeout)) {
367 reader.fail();
368 return false;
369 }
370 if (!reader.noMore()) {
371 reader.fail();
372 return false;
373 }
374 return true;
375}
376
382
388
390{
391 if (!writer.isNull()) {
392 if (!writer.write(return_helper)) {
393 return false;
394 }
395 }
396 return true;
397}
398
400{
401 if (reader.noMore()) {
402 reader.fail();
403 return false;
404 }
405 if (!reader.read(return_helper)) {
406 reader.fail();
407 return false;
408 }
409 return true;
410}
411
416
417// getLastVelocityCommandRPC helper class implementation
422
427
429{
430 yarp::os::idl::WireWriter writer(connection);
431 if (!writer.writeListHeader(s_cmd_len)) {
432 return false;
433 }
434 return write(writer);
435}
436
438{
439 yarp::os::idl::WireReader reader(connection);
440 if (!reader.readListHeader()) {
441 reader.fail();
442 return false;
443 }
444 return read(reader);
445}
446
448{
449 if (!writeTag(writer)) {
450 return false;
451 }
452 if (!writeArgs(writer)) {
453 return false;
454 }
455 return true;
456}
457
459{
460 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
461 return false;
462 }
463 return true;
464}
465
470
472{
473 if (!readTag(reader)) {
474 return false;
475 }
476 if (!readArgs(reader)) {
477 return false;
478 }
479 return true;
480}
481
483{
484 std::string tag = reader.readTag(s_tag_len);
485 if (reader.isError()) {
486 return false;
487 }
488 if (tag != s_tag) {
489 reader.fail();
490 return false;
491 }
492 return true;
493}
494
496{
497 if (!reader.noMore()) {
498 reader.fail();
499 return false;
500 }
501 return true;
502}
503
509
515
517{
518 if (!writer.isNull()) {
519 if (!writer.writeListHeader(s_reply_len)) {
520 return false;
521 }
522 if (!writer.write(return_helper)) {
523 return false;
524 }
525 }
526 return true;
527}
528
530{
531 if (!reader.readListReturn()) {
532 return false;
533 }
534 if (reader.noMore()) {
535 reader.fail();
536 return false;
537 }
538 if (!reader.read(return_helper)) {
539 reader.fail();
540 return false;
541 }
542 return true;
543}
544
549
550// Constructor
555
556yarp::dev::ReturnValue INavigation2DVelocityActionsMsgs::applyVelocityCommandRPC(const double x_vel, const double y_vel, const double theta_vel, const double timeout)
557{
558 if (!yarp().canWrite()) {
560 }
561 INavigation2DVelocityActionsMsgs_applyVelocityCommandRPC_helper helper{x_vel, y_vel, theta_vel, timeout};
562 bool ok = yarp().write(helper, helper);
564}
565
567{
568 if (!yarp().canWrite()) {
570 }
572 bool ok = yarp().write(helper, helper);
573 if (!ok) {
574 return_getLastVelocityCommand failed_reply{};
576 return failed_reply;
577 }
578 return helper.reply.return_helper;
579}
580
581// help method
582std::vector<std::string> INavigation2DVelocityActionsMsgs::help(const std::string& functionName)
583{
584 bool showAll = (functionName == "--all");
585 std::vector<std::string> helpString;
586 if (showAll) {
587 helpString.emplace_back("*** Available commands:");
590 helpString.emplace_back("help");
591 } else {
594 }
597 }
598 if (functionName == "help") {
599 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
600 helpString.emplace_back("Return list of available commands, or help message for a specific function");
601 helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
602 helpString.emplace_back("@return list of strings (one string per line)");
603 }
604 }
605 if (helpString.empty()) {
606 helpString.emplace_back("Command not found");
607 }
608 return helpString;
609}
610
611// read from ConnectionReader
613{
614 constexpr size_t max_tag_len = 1;
615 size_t tag_len = 1;
616
617 yarp::os::idl::WireReader reader(connection);
618 reader.expectAccept();
619 if (!reader.readListHeader()) {
620 reader.fail();
621 return false;
622 }
623
624 std::string tag = reader.readTag(1);
625 bool direct = (tag == "__direct__");
626 if (direct) {
627 tag = reader.readTag(1);
628 }
629 while (tag_len <= max_tag_len && !reader.isError()) {
630 if(tag == "getRemoteProtocolVersion") {
631 if (!reader.noMore()) {
632 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
633 reader.fail();
634 return false;
635 }
636
637 auto proto = getLocalProtocolVersion();
638
639 yarp::os::idl::WireWriter writer(reader);
640 if (!writer.writeListHeader(1)) {
641 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
642 return false;}
643 if (!writer.write(proto)) {
644 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
645 return false;
646 }
647 reader.accept();
648 return true;
649 }
652 if (!helper.cmd.readArgs(reader)) {
653 return false;
654 }
655
656 helper.call(this);
657
658 yarp::os::idl::WireWriter writer(reader);
659 if (!helper.reply.write(writer)) {
660 return false;
661 }
662 reader.accept();
663 return true;
664 }
667 if (!helper.cmd.readArgs(reader)) {
668 return false;
669 }
670
671 helper.call(this);
672
673 yarp::os::idl::WireWriter writer(reader);
674 if (!helper.reply.write(writer)) {
675 return false;
676 }
677 reader.accept();
678 return true;
679 }
680 if (tag == "help") {
681 std::string functionName;
682 if (!reader.readString(functionName)) {
683 functionName = "--all";
684 }
685 auto help_strings = help(functionName);
686 yarp::os::idl::WireWriter writer(reader);
687 if (!writer.isNull()) {
688 if (!writer.writeListHeader(2)) {
689 return false;
690 }
691 if (!writer.writeTag("many", 1, 0)) {
692 return false;
693 }
694 if (!writer.writeListBegin(0, help_strings.size())) {
695 return false;
696 }
697 for (const auto& help_string : help_strings) {
698 if (!writer.writeString(help_string)) {
699 return false;
700 }
701 }
702 if (!writer.writeListEnd()) {
703 return false;
704 }
705 }
706 reader.accept();
707 return true;
708 }
709 if (reader.noMore()) {
710 reader.fail();
711 return false;
712 }
713 std::string next_tag = reader.readTag(1);
714 if (next_tag.empty()) {
715 break;
716 }
717 tag.append("_").append(next_tag);
718 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
719 }
720 return false;
721}
#define yError(...)
Definition Log.h:361
#define __YFUNCTION__
Definition Log.h:24
#define yWarning(...)
Definition Log.h:340
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::dev::ReturnValue(*)(const double, const double, const double, const double) funcptr_t
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual yarp::dev::ReturnValue applyVelocityCommandRPC(const double x_vel, const double y_vel, const double theta_vel, const double timeout)
virtual return_getLastVelocityCommand getLastVelocityCommandRPC()
@ return_value_error_nws_nwc_communication_error
Method is not (yet) implemented.
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition Wire.h:28
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
IDL-friendly connection reader.
Definition WireReader.h:27
bool readString(std::string &str, bool *is_vocab=nullptr)
std::string readTag(size_t len=static_cast< size_t >(-1))
bool read(WirePortable &obj)
bool readFloat64(yarp::conf::float64_t &x)
IDL-friendly connection writer.
Definition WireWriter.h:28
bool write(const WirePortable &obj) const
bool writeListHeader(int len) const
bool writeTag(const char *tag, int split, int len) const
bool writeFloat64(yarp::conf::float64_t x, bool skip_tag=false) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool writeListBegin(int tag, size_t len) const
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_VERSION_PATCH
Definition version.h:12
#define YARP_VERSION_MAJOR
Definition version.h:10
#define YARP_VERSION_MINOR
Definition version.h:11