36 #ifdef NODELETS_TEST_VERBOSE 37 printf(
"[publisher] Started\n");
40 for (
int i = 0; i < 5; i++)
42 std::this_thread::sleep_for(100ms);
43 dir->getTopic(
"/robot/odom")->publish(
p_tx);
46 #ifdef NODELETS_TEST_VERBOSE 47 printf(
"[publisher] Finish\n");
50 catch (std::exception& e)
52 cerr << e.what() << endl;
56 printf(
"[thread_publisher] Runtime error!\n");
62 #ifdef NODELETS_TEST_VERBOSE 63 std::cout <<
"sub2: rx CPose3D" <<
p.asString() << std::endl;
69 #ifdef NODELETS_TEST_VERBOSE 70 std::cout <<
"onNewMsg2: idx=" << idx <<
" rx CPose3D" <<
p.asString()
82 #ifdef NODELETS_TEST_VERBOSE 83 printf(
"[subscriber] Connecting\n");
86 #ifdef NODELETS_TEST_VERBOSE 87 printf(
"[subscriber] Connected. Waiting for a message...\n");
92 dir->getTopic(
"/robot/odom")
95 #ifdef NODELETS_TEST_VERBOSE 96 std::cout <<
"sub1: rx CPose3D" << p_rx.asString()
103 auto sub2 =
dir->getTopic(
"/robot/odom")
105 std::function<void(const mrpt::poses::CPose3D&)>(
109 auto sub3 =
dir->getTopic(
"/robot/odom")
113 using namespace std::placeholders;
114 auto sub4 =
dir->getTopic(
"/robot/odom")
121 std::this_thread::sleep_for(1000ms);
123 #ifdef NODELETS_TEST_VERBOSE 124 printf(
"[subscriber] Finish\n");
127 catch (std::exception& e)
129 cerr << e.what() << endl;
133 cerr <<
"[thread_subscriber] Runtime error!" << endl;
139 using namespace std::chrono_literals;
143 std::this_thread::sleep_for(1000ms);
void onNewMsg2(int idx, const mrpt::poses::CPose3D &p)
bool nodelets_test_passed_ok
const mrpt::poses::CPose3D p_tx(1.0, 2.0, 3.0, 0.2, 0.4, 0.6)
[example-nodelets]
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void onNewMsg(const mrpt::poses::CPose3D &p)
Serial and networking devices and utilities.