28 std::cout <<
"[thread_reader ID:" << std::this_thread::get_id()
29 <<
"] Started." << std::endl;
37 cout <<
"RX: " << buf << endl;
43 #ifndef HAS_BROKEN_CLANG_STD_VISIT 44 auto doprint = [](
auto& pose) { cout <<
"RX pose: " << pose << endl; };
47 std::visit(doprint, var);
49 std::visit(doprint, var);
52 printf(
"[thread_reader] Finished.\n");
54 catch (std::exception& e)
56 cerr << e.what() << endl;
64 std::cout <<
"[thread_writer ID:" << std::this_thread::get_id()
65 <<
"] Started." << std::endl;
68 const char* str =
"Hello world!";
69 size_t len = strlen(str);
76 std::variant<mrpt::poses::CPose3D, mrpt::poses::CPose2D> var1(
78 std::variant<mrpt::poses::CPose3D, mrpt::poses::CPose2D> var2(
81 #ifndef HAS_BROKEN_CLANG_STD_VISIT 82 arch.WriteVariant(var1);
83 arch.WriteVariant(var2);
85 printf(
"[thread_writer] Finished.\n");
87 catch (std::exception& e)
89 cerr << e.what() << endl;
99 std::unique_ptr<CPipeReadEndPoint> read_pipe;
100 std::unique_ptr<CPipeWriteEndPoint> write_pipe;
102 CPipe::createPipe(read_pipe, write_pipe);
108 using namespace std::chrono_literals;
109 std::this_thread::sleep_for(10ms);
129 catch (std::exception& e)
131 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
136 printf(
"Untyped exception!!");
virtual size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
void thread_reader(CPipeReadEndPoint &read_pipe)
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream
virtual size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
The write end-point in a pipe created with mrpt::synch::CPipe.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
The read end-point in a pipe created with mrpt::synch::CPipe.
void thread_writer(CPipeWriteEndPoint &write_pipe)