8 #define _USE_MATH_DEFINES
38 std::lock_guard<std::mutex> lock(m_mutex);
39 if (
id >= 0 && (
size_t)
id < m_transforms.size())
41 m_transforms.erase(m_transforms.begin() +
id);
49 std::lock_guard<std::mutex> lock(m_mutex);
50 for (
auto& m_transform : m_transforms)
53 if (m_transform.dst_frame_id ==
t.dst_frame_id && m_transform.src_frame_id ==
t.src_frame_id)
62 m_transforms.push_back(
t);
68 std::lock_guard<std::mutex> lock(m_mutex);
69 if (t1==
"*" && t2==
"*")
77 for (
size_t i = 0; i < m_transforms.size(); )
80 if (m_transforms[i].dst_frame_id == t2)
82 m_transforms.erase(m_transforms.begin() + i);
95 for (
size_t i = 0; i < m_transforms.size(); )
98 if (m_transforms[i].src_frame_id == t1)
100 m_transforms.erase(m_transforms.begin() + i);
112 for (
size_t i = 0; i < m_transforms.size(); i++)
114 if ((m_transforms[i].dst_frame_id == t1 && m_transforms[i].src_frame_id == t2) ||
115 (m_transforms[i].dst_frame_id == t2 && m_transforms[i].src_frame_id == t1) )
117 m_transforms.erase(m_transforms.begin() + i);
127 std::lock_guard<std::mutex> lock(m_mutex);
128 m_transforms.clear();
138 m_enable_publish_ros_tf =
false;
139 m_enable_subscribe_ros_tf =
false;
140 m_yarp_static_transform_storage =
nullptr;
141 m_yarp_timed_transform_storage =
nullptr;
142 m_ros_static_transform_storage =
nullptr;
143 m_ros_timed_transform_storage =
nullptr;
145 m_FrameTransformTimeout = 0.200;
151 if (m_yarp_static_transform_storage)
153 delete m_yarp_static_transform_storage;
154 m_yarp_static_transform_storage =
nullptr;
156 if (m_yarp_timed_transform_storage)
158 delete m_yarp_timed_transform_storage;
159 m_yarp_timed_transform_storage =
nullptr;
161 if (m_ros_timed_transform_storage)
163 delete m_ros_timed_transform_storage;
164 m_ros_timed_transform_storage =
nullptr;
166 if (m_ros_static_transform_storage)
168 delete m_ros_static_transform_storage;
169 m_ros_static_transform_storage =
nullptr;
175 std::vector<Transforms_server_storage*> storages;
176 std::vector<std::string> storageDescription;
177 storages.push_back(m_ros_timed_transform_storage);
178 storageDescription.emplace_back(
"ros timed transforms");
180 storages.push_back(m_ros_static_transform_storage);
181 storageDescription.emplace_back(
"ros static transforms");
183 storages.push_back(m_yarp_timed_transform_storage);
184 storageDescription.emplace_back(
"yarp timed transforms");
186 storages.push_back(m_yarp_static_transform_storage);
187 storageDescription.emplace_back(
"yarp static transforms");
189 if (storages[0]->size() == 0 &&
190 storages[1]->size() == 0 &&
191 storages[2]->size() == 0 &&
192 storages[3]->size() == 0)
198 for(
size_t s = 0; s < storages.size(); s++ )
205 std::string text_to_print = storageDescription[s] + std::string(
"(") +
std::to_string(storages[s]->size())+ std::string(
"): ");
208 for(
size_t i = 0; i < storages[s]->size(); i++)
218 if (m_show_transforms_in_diagram== show_transforms_in_diagram_t::do_not_show)
222 else if (m_show_transforms_in_diagram== show_transforms_in_diagram_t::show_quaternion)
224 return std::string(
",label=\" ") + (*storage)[i].toString(FrameTransform::display_transform_mode_t::rotation_as_quaternion) +
"\"";
226 else if (m_show_transforms_in_diagram == show_transforms_in_diagram_t::show_matrix)
228 return std::string(
",label=\" ") + (*storage)[i].toString(FrameTransform::display_transform_mode_t::rotation_as_matrix) +
"\"";
230 else if (m_show_transforms_in_diagram == show_transforms_in_diagram_t::show_rpy)
232 return std::string(
",label=\" ") + (*storage)[i].toString(FrameTransform::display_transform_mode_t::rotation_as_rpy) +
"\"";
235 yCError(TRANSFORMSERVER) <<
"get_matrix_as_text() invalid option";
246 bool TransformServer::generate_view()
248 std::string dot_string =
"digraph G { ";
249 for (
size_t i = 0; i < m_ros_timed_transform_storage->
size(); i++)
251 std::string edge_text = get_matrix_as_text(m_ros_timed_transform_storage, i);
252 std::string trf_text = (*m_ros_timed_transform_storage)[i].src_frame_id +
"->" +
253 (*m_ros_timed_transform_storage)[i].dst_frame_id +
" " +
255 dot_string += trf_text +
'\n';
257 for (
size_t i = 0; i < m_ros_static_transform_storage->
size(); i++)
259 std::string edge_text = get_matrix_as_text(m_ros_static_transform_storage,i);
260 std::string trf_text = (*m_ros_static_transform_storage)[i].src_frame_id +
"->" +
261 (*m_ros_static_transform_storage)[i].dst_frame_id +
" " +
262 "[color = black, style=dashed "+ edge_text +
"]";
263 dot_string += trf_text +
'\n';
265 for (
size_t i = 0; i < m_yarp_timed_transform_storage->
size(); i++)
267 std::string edge_text = get_matrix_as_text(m_yarp_timed_transform_storage, i);
268 std::string trf_text = (*m_yarp_timed_transform_storage)[i].src_frame_id +
"->" +
269 (*m_yarp_timed_transform_storage)[i].dst_frame_id +
" " +
270 "[color = blue "+ edge_text +
"]";
271 dot_string += trf_text +
'\n';
273 for (
size_t i = 0; i < m_yarp_static_transform_storage->
size(); i++)
275 std::string edge_text = get_matrix_as_text(m_yarp_static_transform_storage, i);
276 std::string trf_text = (*m_yarp_static_transform_storage)[i].src_frame_id +
"->" +
277 (*m_yarp_static_transform_storage)[i].dst_frame_id +
" " +
278 "[color = blue, style=dashed " + edge_text +
"]";
279 dot_string += trf_text +
'\n';
282 std::string legend =
"\n\
284 node[shape=plaintext]\n\
285 subgraph cluster_01 {\n\
286 label = \"Legend\";\n\
287 key[label=<<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" cellborder=\"0\">\n\
288 <tr><td align=\"right\" port=\"i1\">YARP timed transform</td></tr>\n\
289 <tr><td align=\"right\" port=\"i2\">YARP static transform</td></tr>\n\
290 <tr><td align=\"right\" port=\"i3\">ROS timed transform</td></tr>\n\
291 <tr><td align=\"right\" port=\"i4\">ROS static transform</td></tr>\n\
293 key2[label=<<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" cellborder=\"0\">\n\
294 <tr><td port = \"i1\"> </td></tr>\n\
295 <tr><td port = \"i2\"> </td></tr>\n\
296 <tr><td port = \"i3\"> </td></tr>\n\
297 <tr><td port = \"i4\"> </td></tr>\n\
299 key:i1:e -> key2:i1:w [color = blue]\n\
300 key:i2:e -> key2:i2:w [color = blue, style=dashed]\n\
301 key:i3:e -> key2:i3:w [color = black]\n\
302 key:i4:e -> key2:i4:w [color = black, style=dashed]\n\
305 std::string command_string =
"printf '"+dot_string+ legend +
"' | dot -Tpdf > frames.pdf";
306 #if defined (__linux__)
307 int ret = std::system(
"dot -V");
310 yCError(TRANSFORMSERVER) <<
"dot executable not found. Please install graphviz.";
314 yCDebug(TRANSFORMSERVER) <<
"Command string is:" << command_string;
315 ret = std::system(command_string.c_str());
318 yCError(TRANSFORMSERVER) <<
"The following command failed to execute:" << command_string;
322 yCError(TRANSFORMSERVER) <<
"Not yet implemented. Available only Linux";
330 std::lock_guard<std::mutex> lock(m_mutex);
333 bool ok = in.
read(connection);
350 yCError(TRANSFORMSERVER) <<
"read(): Protocol error";
387 yCError(TRANSFORMSERVER) <<
"read(): Something strange happened";
393 m_yarp_timed_transform_storage->
clear();
394 m_yarp_static_transform_storage->
clear();
395 m_ros_timed_transform_storage->
clear();
396 m_ros_static_transform_storage->
clear();
404 bool ret1 = m_yarp_timed_transform_storage->
delete_transform(frame1, frame2);
412 bool ret2 = m_yarp_static_transform_storage->
delete_transform(frame1, frame2);
423 yCError(TRANSFORMSERVER,
"Invalid vocab received");
428 else if(request ==
"help")
431 out.
addString(
"'list': get all transforms stored");
432 out.
addString(
"'delete_all': delete all transforms");
433 out.
addString(
"'set_static_transform_rad <src> <dst> <x> <y> <z> <roll> <pitch> <yaw>': create a static transform (angles in radians)");
434 out.
addString(
"'set_static_transform_deg <src> <dst> <x> <y> <z> <roll> <pitch> <yaw>': create a static transform (angles in degrees)");
435 out.
addString(
"'delete_static_transform <src> <dst>': delete a static transform");
436 out.
addString(
"'generate_view <option>': generate a frames.pdf file showing the transform tree diagram.");
437 out.
addString(
" The following values are valid for option (default=none)");
438 out.
addString(
" 'show_rpy': show roation as rpy angles");
439 out.
addString(
" 'show_quaterion:'show rotation as a quaternion");
440 out.
addString(
" 'show_matrix:'show rotationa as a 3x3 rotation matrix");
442 else if (request ==
"set_static_transform_rad" ||
443 request ==
"set_static_transform_deg")
451 if (request ==
"set_static_transform_rad")
453 else if (request ==
"set_static_transform_deg")
459 yCInfo(TRANSFORMSERVER) <<
"set_static_transform done";
460 out.
addString(
"set_static_transform done");
464 yCError(TRANSFORMSERVER) <<
"read(): something strange happened";
467 else if(request ==
"delete_all")
469 m_yarp_timed_transform_storage->
clear();
470 m_yarp_static_transform_storage->
clear();
471 m_ros_timed_transform_storage->
clear();
472 m_ros_static_transform_storage->
clear();
473 yCInfo(TRANSFORMSERVER) <<
"delete_all done";
476 else if (request ==
"list")
481 else if (request ==
"generate_view")
483 m_show_transforms_in_diagram = show_transforms_in_diagram_t::do_not_show;
485 m_show_transforms_in_diagram = show_transforms_in_diagram_t::show_quaternion;
486 }
else if (in.
get(1).
asString() ==
"show_matrix") {
487 m_show_transforms_in_diagram = show_transforms_in_diagram_t::show_matrix;
489 m_show_transforms_in_diagram = show_transforms_in_diagram_t::show_rpy;
494 else if (request ==
"delete_static_transform")
500 out.
addString(
"delete_static_transform done");
504 yCError(TRANSFORMSERVER,
"Invalid vocab received");
510 if (returnToSender !=
nullptr)
512 out.
write(*returnToSender);
516 yCError(TRANSFORMSERVER) <<
"Invalid return to sender";
524 if (!m_rpcPort.
open(m_rpcPortName))
526 yCError(TRANSFORMSERVER,
"Failed to open port %s", m_rpcPortName.c_str());
532 if (!m_streamingPort.
open(m_streamingPortName))
534 yCError(TRANSFORMSERVER,
"Failed to open port %s", m_streamingPortName.c_str());
539 if (m_enable_publish_ros_tf)
541 if (m_rosNode ==
nullptr)
547 yCError(TRANSFORMSERVER) <<
"Unable to publish data on " <<
ROSTOPICNAME_TF <<
" topic, check your yarp-ROS network configuration";
558 if (m_enable_subscribe_ros_tf)
560 if (m_rosNode ==
nullptr)
566 yCError(TRANSFORMSERVER) <<
"Unable to subscribe to " <<
ROSTOPICNAME_TF <<
" topic, check your yarp-ROS network configuration";
569 m_rosSubscriberPort_tf_timed.
setStrict();
575 m_rosSubscriberPort_tf_static.
setStrict();
584 yCInfo(TRANSFORMSERVER) <<
"Transform server started";
591 if (config.
check(
"USER_TF"))
596 for (
size_t i = 0; i < all_transforms_group.
size(); i++)
603 yCError(TRANSFORMSERVER) <<
"No entries in USER_TF group";
612 for(
int i = 0; i < 16; i++)
616 yCError(TRANSFORMSERVER) <<
"transformServer: element " << i <<
" is not a double.";
632 yCError(TRANSFORMSERVER) <<
"transformServer: param not correct.. for the 4x4 matrix mode" <<
633 "you must provide 18 parameter. the matrix, the source frame(string) and the destination frame(string)";
641 else if( b->
size() == 8 &&
658 yCError(TRANSFORMSERVER) <<
"transformServer: param not correct.. a tf requires 8 param in the format:" <<
659 "x(dbl) y(dbl) z(dbl) r(dbl) p(dbl) y(dbl) src(str) dst(str)";
665 yCInfo(TRANSFORMSERVER) <<
"Transform from" <<
t.src_frame_id <<
"to" <<
t.dst_frame_id <<
"successfully set";
669 yCInfo(TRANSFORMSERVER) <<
"Unbale to set transform from " <<
t.src_frame_id <<
"to" <<
t.dst_frame_id;
676 yCInfo(TRANSFORMSERVER) <<
"No starting tf found";
683 yCWarning(TRANSFORMSERVER) <<
"The 'transformServer' device is deprecated in favour of 'frameTransformServer'.";
684 yCWarning(TRANSFORMSERVER) <<
"The old device is no longer supported, and it will be deprecated in YARP 3.6 and removed in YARP 4.";
685 yCWarning(TRANSFORMSERVER) <<
"Please update your scripts.";
690 if (!config.
check(
"period"))
696 m_period = config.
find(
"period").
asInt32() / 1000.0;
697 yCInfo(TRANSFORMSERVER) <<
"Thread period set to:" << m_period;
700 if (config.
check(
"transforms_lifetime"))
702 m_FrameTransformTimeout = config.
find(
"transforms_lifetime").
asFloat64();
703 yCInfo(TRANSFORMSERVER) <<
"transforms_lifetime set to:" << m_FrameTransformTimeout;
707 if (!config.
check(
"name"))
709 name =
"transformServer";
715 m_streamingPortName =
"/"+ name +
"/transforms:o";
716 m_rpcPortName =
"/" + name +
"/rpc";
719 if (!config.
check(
"ROS"))
721 yCError(TRANSFORMSERVER) <<
"Missing ROS group";
725 if (ROS_config.
check(
"enable_ros_publisher") ==
false)
727 yCError(TRANSFORMSERVER) <<
"Missing 'enable_ros_publisher' in ROS group";
730 if (ROS_config.
find(
"enable_ros_publisher").
asInt32() == 1 || ROS_config.
find(
"enable_ros_publisher").
asString() ==
"true")
732 m_enable_publish_ros_tf =
true;
733 yCInfo(TRANSFORMSERVER) <<
"Enabled ROS publisher";
735 if (ROS_config.
check(
"enable_ros_subscriber") ==
false)
737 yCError(TRANSFORMSERVER) <<
"Missing 'enable_ros_subscriber' in ROS group";
740 if (ROS_config.
find(
"enable_ros_subscriber").
asInt32() == 1 || ROS_config.
find(
"enable_ros_subscriber").
asString() ==
"true")
742 m_enable_subscribe_ros_tf =
true;
743 yCInfo(TRANSFORMSERVER) <<
"Enabled ROS subscriber";
749 parseStartingTf(config);
757 m_streamingPort.
close();
760 if (m_enable_publish_ros_tf)
763 m_rosPublisherPort_tf_timed.
close();
765 if (m_enable_subscribe_ros_tf)
767 m_rosSubscriberPort_tf_timed.
interrupt();
768 m_rosSubscriberPort_tf_timed.
close();
770 if (m_enable_publish_ros_tf)
772 m_rosPublisherPort_tf_static.
interrupt();
773 m_rosPublisherPort_tf_static.
close();
775 if (m_enable_subscribe_ros_tf)
777 m_rosSubscriberPort_tf_static.
interrupt();
778 m_rosSubscriberPort_tf_static.
close();
790 std::lock_guard<std::mutex> lock(m_mutex);
799 repeat_check =
false;
800 size_t tfVecSize_timed_yarp = m_yarp_timed_transform_storage->
size();
801 for (
size_t i = 0; i < tfVecSize_timed_yarp; i++)
803 if (current_time - (*m_yarp_timed_transform_storage)[i].timestamp > m_FrameTransformTimeout)
811 while (repeat_check);
816 repeat_check =
false;
817 size_t tfVecSize_timed_ros = m_ros_timed_transform_storage->
size();
818 for (
size_t i = 0; i < tfVecSize_timed_ros; i++)
820 if (current_time - (*m_ros_timed_transform_storage)[i].timestamp > m_FrameTransformTimeout)
827 }
while (repeat_check);
830 if (m_enable_subscribe_ros_tf)
835 rosInData_timed = m_rosSubscriberPort_tf_timed.
read(
false);
836 if (rosInData_timed !=
nullptr)
838 std::vector <yarp::rosmsg::geometry_msgs::TransformStamped> tfs = rosInData_timed->
transforms;
839 size_t tfs_size = tfs.size();
840 for (
size_t i = 0; i < tfs_size; i++)
843 t.translation.tX = tfs[i].transform.translation.x;
844 t.translation.tY = tfs[i].transform.translation.y;
845 t.translation.tZ = tfs[i].transform.translation.z;
846 t.rotation.x() = tfs[i].transform.rotation.x;
847 t.rotation.y() = tfs[i].transform.rotation.y;
848 t.rotation.z() = tfs[i].transform.rotation.z;
849 t.rotation.w() = tfs[i].transform.rotation.w;
850 t.src_frame_id = tfs[i].header.frame_id;
851 t.dst_frame_id = tfs[i].child_frame_id;
855 (*m_ros_timed_transform_storage).set_transform(
t);
858 }
while (rosInData_timed !=
nullptr);
863 rosInData_static = m_rosSubscriberPort_tf_static.
read(
false);
864 if (rosInData_static !=
nullptr)
866 std::vector <yarp::rosmsg::geometry_msgs::TransformStamped> tfs = rosInData_static->
transforms;
867 size_t tfs_size = tfs.size();
868 for (
size_t i = 0; i < tfs_size; i++)
871 t.translation.tX = tfs[i].transform.translation.x;
872 t.translation.tY = tfs[i].transform.translation.y;
873 t.translation.tZ = tfs[i].transform.translation.z;
874 t.rotation.x() = tfs[i].transform.rotation.x;
875 t.rotation.y() = tfs[i].transform.rotation.y;
876 t.rotation.z() = tfs[i].transform.rotation.z;
877 t.rotation.w() = tfs[i].transform.rotation.w;
878 t.src_frame_id = tfs[i].header.frame_id;
879 t.dst_frame_id = tfs[i].child_frame_id;
883 (*m_ros_static_transform_storage).set_transform(
t);
886 }
while (rosInData_static !=
nullptr);
890 m_lastStateStamp.
update();
891 size_t tfVecSize_static_yarp = m_yarp_static_transform_storage->
size();
892 size_t tfVecSize_timed_yarp = m_yarp_timed_transform_storage->
size();
893 size_t tfVecSize_static_ros = m_ros_static_transform_storage->
size();
894 size_t tfVecSize_timed_ros = m_ros_timed_transform_storage->
size();
896 yCDebug(TRANSFORMSERVER) <<
"yarp size" << tfVecSize_yarp <<
"ros_size" << tfVecSize_ros;
901 for (
size_t i = 0; i < tfVecSize_static_yarp; i++)
904 transform.
addString((*m_yarp_static_transform_storage)[i].src_frame_id);
905 transform.
addString((*m_yarp_static_transform_storage)[i].dst_frame_id);
906 transform.
addFloat64((*m_yarp_static_transform_storage)[i].timestamp);
908 transform.
addFloat64((*m_yarp_static_transform_storage)[i].translation.tX);
909 transform.
addFloat64((*m_yarp_static_transform_storage)[i].translation.tY);
910 transform.
addFloat64((*m_yarp_static_transform_storage)[i].translation.tZ);
912 transform.
addFloat64((*m_yarp_static_transform_storage)[i].rotation.w());
913 transform.
addFloat64((*m_yarp_static_transform_storage)[i].rotation.x());
914 transform.
addFloat64((*m_yarp_static_transform_storage)[i].rotation.y());
915 transform.
addFloat64((*m_yarp_static_transform_storage)[i].rotation.z());
917 for (
size_t i = 0; i < tfVecSize_timed_yarp; i++)
920 transform.
addString((*m_yarp_timed_transform_storage)[i].src_frame_id);
921 transform.
addString((*m_yarp_timed_transform_storage)[i].dst_frame_id);
922 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].timestamp);
924 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].translation.tX);
925 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].translation.tY);
926 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].translation.tZ);
928 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].rotation.w());
929 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].rotation.x());
930 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].rotation.y());
931 transform.
addFloat64((*m_yarp_timed_transform_storage)[i].rotation.z());
933 for (
size_t i = 0; i < tfVecSize_timed_ros; i++)
936 transform.
addString((*m_ros_timed_transform_storage)[i].src_frame_id);
937 transform.
addString((*m_ros_timed_transform_storage)[i].dst_frame_id);
938 transform.
addFloat64((*m_ros_timed_transform_storage)[i].timestamp);
940 transform.
addFloat64((*m_ros_timed_transform_storage)[i].translation.tX);
941 transform.
addFloat64((*m_ros_timed_transform_storage)[i].translation.tY);
942 transform.
addFloat64((*m_ros_timed_transform_storage)[i].translation.tZ);
944 transform.
addFloat64((*m_ros_timed_transform_storage)[i].rotation.w());
945 transform.
addFloat64((*m_ros_timed_transform_storage)[i].rotation.x());
946 transform.
addFloat64((*m_ros_timed_transform_storage)[i].rotation.y());
947 transform.
addFloat64((*m_ros_timed_transform_storage)[i].rotation.z());
949 for (
size_t i = 0; i < tfVecSize_static_ros; i++)
952 transform.
addString((*m_ros_static_transform_storage)[i].src_frame_id);
953 transform.
addString((*m_ros_static_transform_storage)[i].dst_frame_id);
954 transform.
addFloat64((*m_ros_static_transform_storage)[i].timestamp);
956 transform.
addFloat64((*m_ros_static_transform_storage)[i].translation.tX);
957 transform.
addFloat64((*m_ros_static_transform_storage)[i].translation.tY);
958 transform.
addFloat64((*m_ros_static_transform_storage)[i].translation.tZ);
960 transform.
addFloat64((*m_ros_static_transform_storage)[i].rotation.w());
961 transform.
addFloat64((*m_ros_static_transform_storage)[i].rotation.x());
962 transform.
addFloat64((*m_ros_static_transform_storage)[i].rotation.y());
963 transform.
addFloat64((*m_ros_static_transform_storage)[i].rotation.z());
967 m_streamingPort.
write();
970 if (m_enable_publish_ros_tf)
972 static int rosMsgCounter = 0;
976 for (
size_t i = 0; i < tfVecSize_timed_yarp; i++)
978 transform_timed.
child_frame_id = (*m_yarp_timed_transform_storage)[i].dst_frame_id;
979 transform_timed.
header.
frame_id = (*m_yarp_timed_transform_storage)[i].src_frame_id;
980 transform_timed.
header.
seq = rosMsgCounter;
981 transform_timed.
header.
stamp = (*m_yarp_timed_transform_storage)[i].timestamp;
982 transform_timed.
transform.
rotation.
x = (*m_yarp_timed_transform_storage)[i].rotation.x();
983 transform_timed.
transform.
rotation.
y = (*m_yarp_timed_transform_storage)[i].rotation.y();
984 transform_timed.
transform.
rotation.
z = (*m_yarp_timed_transform_storage)[i].rotation.z();
985 transform_timed.
transform.
rotation.
w = (*m_yarp_timed_transform_storage)[i].rotation.w();
990 rosOutData_timed.
transforms.push_back(transform_timed);
992 m_rosPublisherPort_tf_timed.
write();
997 for (
size_t i = 0; i < tfVecSize_static_yarp; i++)
999 transform_static.
child_frame_id = (*m_yarp_static_transform_storage)[i].dst_frame_id;
1000 transform_static.
header.
frame_id = (*m_yarp_static_transform_storage)[i].src_frame_id;
1001 transform_static.
header.
seq = rosMsgCounter;
1003 transform_static.
transform.
rotation.
x = (*m_yarp_static_transform_storage)[i].rotation.x();
1004 transform_static.
transform.
rotation.
y = (*m_yarp_static_transform_storage)[i].rotation.y();
1005 transform_static.
transform.
rotation.
z = (*m_yarp_static_transform_storage)[i].rotation.z();
1006 transform_static.
transform.
rotation.
w = (*m_yarp_static_transform_storage)[i].rotation.w();
1011 rosOutData_static.
transforms.push_back(transform_static);
1013 m_rosPublisherPort_tf_static.
write();
1021 yCError(TRANSFORMSERVER,
"Returned error");
1027 yCTrace(TRANSFORMSERVER,
"Close");
1028 if (PeriodicThread::isRunning())
1030 PeriodicThread::stop();
define control board standard interfaces
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_ERR
constexpr double DEFAULT_THREAD_PERIOD
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle tail() const
Get all but the first element of a bottle.
void clear()
Empties the bottle of any objects it contains.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
void close() override
Stop port activity.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
void interrupt()
interrupt delegates the call to the Node port interrupt.
An abstraction for a periodic thread.
bool start()
Call this to start the thread.
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void close() override
Stop port activity.
bool topic(const std::string &name)
Set topic to publish to.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::Publisher::write.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void write(bool forceStrict=false)
Write the current object being returned by Publisher::prepare.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
void close() override
Stop port activity.
T * read(bool shouldWait=true)
Read a message from the port.
void setStrict(bool strict=true)
bool topic(const std::string &name)
Set topic to subscribe to.
void interrupt() override
Interrupt any current reads or writes attached to the port.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual bool isString() const
Checks if value is a string.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
virtual std::string asString() const
Get string value.
std::vector< yarp::rosmsg::geometry_msgs::TransformStamped > transforms
std::string toString(const T &value)
convert an arbitrary type to string.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
std::string to_string(IntegerType x)
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
void delay(double seconds)
Wait for a certain number of seconds.
An interface to the operating system, including Port based communication.