qualisys-to-ros.hpp
Go to the documentation of this file.
1 #ifndef ROS_QUALISYS_QUALISYS_TO_ROS_HPP
2 #define ROS_QUALISYS_QUALISYS_TO_ROS_HPP
3 
4 #include <geometry_msgs/TransformStamped.h>
5 #include <ros/ros.h>
6 #include <tf2/LinearMath/Matrix3x3.h>
7 #include <tf2/LinearMath/Quaternion.h>
8 #include <tf2_ros/transform_broadcaster.h>
9 
10 #include "RTPacket.h"
11 #include "RTProtocol.h"
12 
16 namespace ros_qualisys {
17 
46  public:
51  QualisysToRos();
52 
57 
63  void setNodeHandle(ros::NodeHandle& nh);
64 
73  bool initialize();
74 
79  void run();
80 
84  void terminate();
85 
86  private:
94  bool connect();
95 
96  private:
98  ros::NodeHandle* node_handle_;
99 
101  CRTProtocol crt_protocol_;
102 
103  // Server parameters.
104  std::string server_address_;
105  unsigned short base_port_;
106  unsigned short udp_port_;
107  int minor_version_;
108  int major_version_;
109  bool big_endian_;
110 
111  // Maximum rate at which application is running, can be less.
112  int frame_rate_;
113 
114  // Publisher to the /tf ROS topic.
115  bool publish_tf_;
116 
117  // Name of the fix frame in which the object are expressed in. This is the
118  // mocap frame.
119  std::string fixed_frame_id_;
120 
121  // Sanity check variables
122  bool data_available_ = false;
123 
124  // Qualisys SDK acquiring data objects.
125  CRTPacket::EPacketType packet_type_;
126  CRTPacket* rt_packet_;
127  unsigned int body_count_;
128  const char* body_name_;
129  float px_;
130  float py_;
131  float pz_;
132  std::array<float, 9> rotation_matrix_;
133 
134  // ROS interface.
135  std::shared_ptr<ros::Rate> rate_;
136  tf2::Matrix3x3 ros_rotation_matrix_;
137  tf2::Quaternion ros_quaternion_;
138  geometry_msgs::TransformStamped ros_transform_;
139  tf2_ros::TransformBroadcaster publisher_;
140 };
141 
142 } // namespace ros_qualisys
143 
144 #endif // ROS_QUALISYS_QUALISYS_TO_ROS_HPP
145 
This class is a ROS node allowing us to parametrize the connection to a Qualisys system and export th...
Definition: qualisys-to-ros.hpp:45
void run()
Acquire the data from the Qualisys stream and send it back to the /tf or /tf_static topic.
Definition: qualisys-to-ros.cpp:91
void setNodeHandle(ros::NodeHandle &nh)
Set the Node Handle object.
Definition: qualisys-to-ros.cpp:11
QualisysToRos()
Construct a new Qualisys To Ros object, this a simple default constructor.
Definition: qualisys-to-ros.cpp:7
bool initialize()
Initialize the object by:
Definition: qualisys-to-ros.cpp:15
void terminate()
Properly shutdown the connection with the Qualisys system.
Definition: qualisys-to-ros.cpp:166
~QualisysToRos()
Destroy the Qualisys To Ros object.
Definition: qualisys-to-ros.cpp:9
Global namespace of the package.
Definition: qualisys-to-ros.hpp:16