conversion.h
Go to the documentation of this file.
1 #pragma once
2 #include "nxLib.h"
3 
4 #include <geometry_msgs/Point32.h>
5 
7 {
8 // Internally units are used with millimeters instead of meters, but ROS uses
9 // meters most often.
10 const int conversionFactor = 1000;
11 
12 geometry_msgs::Point32 toRosPoint(NxLibItem const& itemArray, bool convertUnits = true)
13 {
14  geometry_msgs::Point32 point;
15  if (convertUnits)
16  {
17  point.x = itemArray[0].asDouble() / conversionFactor;
18  point.y = itemArray[1].asDouble() / conversionFactor;
19  point.z = itemArray[2].asDouble() / conversionFactor;
20  }
21  else
22  {
23  point.x = itemArray[0].asDouble();
24  point.y = itemArray[1].asDouble();
25  point.z = itemArray[2].asDouble();
26  }
27 
28  return point;
29 }
30 
31 NxLibItem toEnsensoPoint(geometry_msgs::Point32 const& point, bool convertUnits = true)
32 {
33  NxLibItem itemPoint;
34  if (convertUnits)
35  {
36  itemPoint[0] = point.x * conversionFactor;
37  itemPoint[1] = point.y * conversionFactor;
38  itemPoint[2] = point.z * conversionFactor;
39  }
40  else
41  {
42  itemPoint[0] = point.x;
43  itemPoint[1] = point.y;
44  itemPoint[2] = point.z;
45  }
46 
47  return itemPoint;
48 }
49 } // namespace ensenso_conversion
NxLibItem toEnsensoPoint(geometry_msgs::Point32 const &point, bool convertUnits=true)
Definition: conversion.h:31
geometry_msgs::Point32 toRosPoint(NxLibItem const &itemArray, bool convertUnits=true)
Definition: conversion.h:12
const int conversionFactor
Definition: conversion.h:10


ensenso_camera
Author(s): Ensenso
autogenerated on Thu May 16 2019 02:44:23