Skip to content
Snippets Groups Projects
Commit a5bd5ad7 authored by Tommy Persson's avatar Tommy Persson
Browse files

Adding json coding of PointCloud2.

parent ad49976a
No related branches found
No related tags found
No related merge requests found
Pipeline #74559 passed
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<!-- <test_depend>gtest</test_depend> --> <!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend> <buildtool_depend>catkin</buildtool_depend>
<depend>gazebo_msgs</depend> <depend>gazebo_msgs</depend>
<depend>sensor_msgs</depend>
<depend>lrs_msgs_common</depend> <depend>lrs_msgs_common</depend>
<depend>lrs_srvs_wdb</depend> <depend>lrs_srvs_wdb</depend>
<depend>tf</depend> <depend>tf</depend>
......
...@@ -427,7 +427,7 @@ def type_is_complex(ty): ...@@ -427,7 +427,7 @@ def type_is_complex(ty):
"FIPAAclMessage", "PathElementTree", "TSTExecStatus", "TSTExecInfo", "FIPAAclMessage", "PathElementTree", "TSTExecStatus", "TSTExecInfo",
"BoundingBoxCVL", "ImageSize", "CVLImage", "DiagnosticStatus", "MultiArrayDimension", "BoundingBoxCVL", "ImageSize", "CVLImage", "DiagnosticStatus", "MultiArrayDimension",
"Point32", "KeyValue", "TransformStamped", "ChannelFloat32", "PointField", "Marker", "Point32", "KeyValue", "TransformStamped", "ChannelFloat32", "PointField", "Marker",
"LandingDetection", "CompressedImage", "LandingDetection", "CompressedImage", "PointCloud2",
"TargetPrediction", "DepotBookingInfo", "SalientPoint", "LrsVisionDetection", "TargetPrediction", "DepotBookingInfo", "SalientPoint", "LrsVisionDetection",
"DelLogItem", "StringList", "Team", "VisionDetection", "SearchUnit", "SearchCell", "DelLogItem", "StringList", "Team", "VisionDetection", "SearchUnit", "SearchCell",
"PathElement", "ResourceInfo", "Interval", "NavigationData", "GeopointHeadingSpeed", "PathElement", "ResourceInfo", "Interval", "NavigationData", "GeopointHeadingSpeed",
...@@ -450,6 +450,8 @@ def field_assignment_get_json_value(field, ty, fieldtype, name): ...@@ -450,6 +450,8 @@ def field_assignment_get_json_value(field, ty, fieldtype, name):
if ty == "bytes": if ty == "bytes":
res = "" res = ""
res += f'// {ty} {field} {fieldtype} {name}\n' res += f'// {ty} {field} {fieldtype} {name}\n'
if name == "PointCloud2":
res += f' res["{field}"] = macaron::Base64::Encode(msg.{field});\n'
if name == "CompressedImage": if name == "CompressedImage":
res += f' res["{field}"] = macaron::Base64::Encode(msg.{field});\n' res += f' res["{field}"] = macaron::Base64::Encode(msg.{field});\n'
if name == "CVLImage": if name == "CVLImage":
...@@ -507,6 +509,16 @@ def field_assignment_parse_json_value(field, ty, fieldtype, name): ...@@ -507,6 +509,16 @@ def field_assignment_parse_json_value(field, ty, fieldtype, name):
res += " for (unsigned int i=0; i<out.size(); i++) {\n" res += " for (unsigned int i=0; i<out.size(); i++) {\n"
res += f' msg.{field}.push_back(out[i]);\n' res += f' msg.{field}.push_back(out[i]);\n'
res += " }" res += " }"
if name == "PointCloud2":
res += " std::string out;\n"
res += f' std::string res = macaron::Base64::Decode(m["{field}"].asString(), out);\n'
res += " if (res != \"\") {\n"
res += " ROS_ERROR(\"FAILED TO DECODE CVL IMAGE Base64 Data: %s\", res.c_str());\n"
res += " return false;\n"
res += " }\n"
res += " for (unsigned int i=0; i<out.size(); i++) {\n"
res += f' msg.{field}.push_back(out[i]);\n'
res += " }"
return res return res
listprefix = "" listprefix = ""
gen_for_list = True gen_for_list = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment