update file cmakelists
This commit is contained in:
@@ -18,3 +18,6 @@ target_include_directories(geometry_msgs INTERFACE
|
||||
|
||||
# Liên kết với std_msgs nếu bạn có file Header.h trong include/std_msgs/
|
||||
target_link_libraries(geometry_msgs INTERFACE std_msgs)
|
||||
|
||||
add_executable(test_geometry test/main.cpp)
|
||||
target_link_libraries(test_geometry PRIVATE geometry_msgs)
|
||||
|
||||
39
geometry_msgs/test/main.cpp
Normal file
39
geometry_msgs/test/main.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "geometry_msgs/PolygonStamped.h"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
geometry_msgs::PolygonStamped poly_stamped;
|
||||
|
||||
poly_stamped.header.seq = 1;
|
||||
poly_stamped.header.stamp.sec = 1625079042;
|
||||
poly_stamped.header.stamp.nsec = 123456789;
|
||||
poly_stamped.header.frame_id = "map";
|
||||
poly_stamped.polygon.points.resize(3);
|
||||
poly_stamped.polygon.points[0].x = 1.1;
|
||||
poly_stamped.polygon.points[0].y = 2.5;
|
||||
poly_stamped.polygon.points[0].z = 0.8;
|
||||
poly_stamped.polygon.points[1].x = 2.1;
|
||||
poly_stamped.polygon.points[1].y = 2.3;
|
||||
poly_stamped.polygon.points[1].z = 0.3;
|
||||
poly_stamped.polygon.points[2].x = 3.2;
|
||||
poly_stamped.polygon.points[2].y = 5.9;
|
||||
poly_stamped.polygon.points[2].z = 4.6;
|
||||
|
||||
std::cout << "PolygonStamped:" << std::endl;
|
||||
std::cout << " Header:" << std::endl;
|
||||
std::cout << " seq: " << poly_stamped.header.seq << std::endl;
|
||||
std::cout << " stamp: " << poly_stamped.header.stamp.sec << "s " << poly_stamped.header.stamp.nsec << "ns" << std::endl;
|
||||
std::cout << " frame_id: " << poly_stamped.header.frame_id << std::endl;
|
||||
std::cout << " Polygon points:" << std::endl;
|
||||
for (size_t i = 0; i < poly_stamped.polygon.points.size(); ++i)
|
||||
{
|
||||
std::cout << " Point " << i << ": ("
|
||||
<< poly_stamped.polygon.points[i].x << ", "
|
||||
<< poly_stamped.polygon.points[i].y << ", "
|
||||
<< poly_stamped.polygon.points[i].z << ")" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user