Ask Your Question
0

How to get visualization_msgs::Marker::CUBE vertex coordinates?

asked 2021-08-09 03:53:49 -0500

nayan gravatar image

updated 2021-08-10 08:02:40 -0500

Hello!

I have a visualization_msgs::Marker::CUBE called box with the values:

            box.pose.position.x = (m_point[0].x + m_point[1].x)/2;
            box.pose.position.y = (m_point[0].y + m_point[1].y)/2;
            box.pose.position.z = (m_point[0].z + m_point[1].z)/2;

            box.pose.orientation.x = 0.0;
            box.pose.orientation.y = 0.0;
            box.pose.orientation.z = 0.0;
            box.pose.orientation.w = 1.0;
            box.scale.x = (m_point[0].x - m_point[1].x);
            box.scale.y = (m_point[0].y - m_point[1].y);
            box.scale.z = (m_point[0].z - m_point[1].z);

where m.point[0] is min and m.point[1] is max.

Is there a way I can get the xyz coordinates of the corner or edge of this box?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-09 07:36:46 -0500

nayan gravatar image

Hi all!

I managed to get the edge coordinates. Here is the solution:

            float x1 = box.pose.position.x + box.scale.x/2;
            float x2 = box.pose.position.x - box.scale.x/2;
            float y1 = box.pose.position.y + box.scale.y/2;
            float y2 = box.pose.position.y - box.scale.y/2;
            float z1 = box.pose.position.z + box.scale.z/2;
            float z2 = box.pose.position.z - box.scale.z/2;

            float x_coordinate [2] = {x1, x2};
            float y_coordinate [2] = {y1, y2};
            float z_coordinate [2] = {z1, z2};

            vector<geometry_msgs::PointStamped> box_corner_coordinates;
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 2; k++) {
                        geometry_msgs::PointStamped Point;

                        Point.point.x = x_coordinate[i];
                        Point.point.y = y_coordinate[i];
                        Point.point.z = z_coordinate[i];
                        box_corner_coordinates.push_back(Point);
                    }
                }
            }

Hope it helps!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-08-09 03:53:49 -0500

Seen: 53 times

Last updated: Aug 10 '21