Studica - Roscpp Documentation
VMX-pi ROS Library
navX_ros_wrapper.h
Go to the documentation of this file.
1#pragma once
2
3#include "VMXPi.h"
4#include <ros/ros.h>
5#include <thread>
6#include <unistd.h>
7#include <sys/syscall.h>
8
9#include <std_msgs/Float32MultiArray.h>
10#include <std_msgs/Float32.h>
11#include <std_msgs/Float64.h>
12#include <std_srvs/Empty.h>
13#include <std_msgs/UInt64.h>
14#include <geometry_msgs/Quaternion.h>
15#include <geometry_msgs/Pose.h>
16#include <geometry_msgs/Point.h>
17#include <geometry_msgs/Vector3.h>
18#include <vmxpi_ros/StringRes.h>
19#include <vmxpi_ros/IntRes.h>
20
22 private:
23 vmx::AHRS *ahrs;
24 ros::NodeHandle n;
25 ros::Publisher rpy_pub, pitch_pub, roll_pub, yaw_pub, angle_pub, heading_pub, linaccel_pub, fusedheading_pub,
26 timestamp_pub, quaternion_pub, velocity_pub, displace_pub,
27 linaccelx_pub, linaccely_pub, linaccelz_pub,
28 quatx_pub, quaty_pub, quatz_pub, quatw_pub,
29 velx_pub, vely_pub, velz_pub,
30 displacex_pub, displacey_pub, displacez_pub,
31 rawgyro_pub, rawgyrox_pub, rawgyroy_pub, rawgyroz_pub,
32 rawaccel_pub, rawaccelx_pub, rawaccely_pub, rawaccelz_pub,
33 rawmag_pub, rawmagx_pub, rawmagy_pub, rawmagz_pub,
34 pose_pub;
35 ros::ServiceServer firmware_ver, reset_navx, reset_displacement, update_rate;
36
37 std::thread runth;
38
39
40 public:
50 navXROSWrapper(ros::NodeHandle *nh, VMXPi *vmx);
51
57
70 // Get current firmware version of navX
71 bool GetFirmwareVersion(vmxpi_ros::StringRes::Request &req, vmxpi_ros::StringRes::Response &res);
72
77 // Grouped publisher for pitch, roll, and yaw (-180 to 180 deg)
78 void PubRollPitchYaw();
79
84 void PubPitch();
85
90 void PubRoll();
91
96 void PubYaw();
97
104 void PubAngle();
105
110 // Publish compass heading
111 void PubHeading();
112
117 // Grouped publisher for linear acceleration (G)
118 void PubLinearAccel();
119
124 void PubLinAccelX();
125
130 void PubLinAccelY();
131
136 void PubLinAccelZ();
137
144 // Publish fused (9-axis) heading, magnetometer calibration is required
145 void PubFusedHeading();
146
151 // Publish timestamp of last sensor message
152 void PubTimestamp();
153
158 // Grouped publisher for quaternion axis w.r.t where yaw was last reset
159 void PubQuaternion();
160
165 void PubQuatX();
166
171 void PubQuatY();
172
177 void PubQuatZ();
178
183 void PubQuatW();
184
192 // Grouped publisher for velocity (m/s) [experimental]
193 void PubVelocity();
194
202 void PubVelX();
203
211 void PubVelY();
212
220 void PubVelZ();
221
229 // Grouped publisher for displacement from position when reset was invoked (m)
230 void PubDisplacement();
231
239 void PubDisplaceX();
240
248 void PubDisplaceY();
249
257 void PubDisplaceZ();
258
265 // Grouped publisher for raw gyro rotation rate (deg/s)
266 void PubRawGyro();
267
274 void PubRawGyroX();
275
282 void PubRawGyroY();
283
290 void PubRawGyroZ();
291
298 // Grouped publisher for raw acceleration (G)
299 void PubRawAccel();
300
307 void PubRawAccelX();
308
315 void PubRawAccelY();
316
323 void PubRawAccelZ();
324
331 // Grouped publisher for raw magnetometer reading (uTesla)
332 void PubRawMag();
333
340 void PubRawMagX();
341
348 void PubRawMagY();
349
356 void PubRawMagZ();
357
362 // Publish pose
363 void PubPose();
364
377 // Get navX's update rate
378 bool GetUpdateRate(vmxpi_ros::IntRes::Request &req, vmxpi_ros::IntRes::Response &res);
379
392 // Reset yaw for quaternion
393 bool Reset(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
394
407 // Reset displacement, new origin will be where this is invoked
408 bool ResetDisplacement(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
409
419 bool IsCalibrating();
420
428 bool IsConnected();
429
437 bool IsMoving();
438
446 bool IsRotating();
447
455 bool IsMagnDisturbance();
456
464 bool IsMagCalibrated();
465
470 void Run_t();
471
472};
Definition: navX_ros_wrapper.h:21
void PubRawGyroX()
Publishes the raw gyro rotation rate (in degrees/sec) in the X-axis to the navx/raw_gyro/x topic.
Definition: navX_ros_wrapper.cpp:284
bool IsConnected()
Signifies whether the sensor is connected to the host computer.
Definition: navX_ros_wrapper.cpp:402
bool GetUpdateRate(vmxpi_ros::IntRes::Request &req, vmxpi_ros::IntRes::Response &res)
Provides the ROS service to access the update rate of the NavX.
Definition: navX_ros_wrapper.cpp:383
void PubLinAccelX()
Publishes the world linear acceleration in the X-axis (in G) to the navx/linear_accel/x.
Definition: navX_ros_wrapper.cpp:142
void PubFusedHeading()
Publishes the fused (9-axis) heading in degrees (range 0-360) to the navx/fused_heading....
Definition: navX_ros_wrapper.cpp:163
void PubLinAccelY()
Publishes the world linear acceleration in the Y-axis (in G) to the navx/linear_accel/y.
Definition: navX_ros_wrapper.cpp:149
void PubRawGyroY()
Publishes the raw gyro rotation rate (in degrees/sec) in the Y-axis to the navx/raw_gyro/y topic.
Definition: navX_ros_wrapper.cpp:291
bool IsCalibrating()
Returns TRUE if the NavX is currently performing gyro/accelerometer calibration.
Definition: navX_ros_wrapper.cpp:400
void PubRawAccelX()
Publishes the raw acceleration rate (G) in the X-axis to the navx/raw_accel/x topic.
Definition: navX_ros_wrapper.cpp:314
void PubRawAccelZ()
Publishes the raw acceleration rate (G) in the Z-axis to the navx/raw_accel/z topic.
Definition: navX_ros_wrapper.cpp:328
void PubVelY()
Publishes the velocity (in meters/sec) in the Y-axis to the navx/velocity/y.
Definition: navX_ros_wrapper.cpp:231
void PubDisplaceY()
Publishes the displacement (in meters) in the Y-axis to the navx/displacement/y topic since the reset...
Definition: navX_ros_wrapper.cpp:261
void PubQuatX()
Publishes the real portion (X-axis) of the orientation quaternion with respect to where the yaw angle...
Definition: navX_ros_wrapper.cpp:187
void PubDisplaceX()
Publishes the displacement (in meters) in the X-axis to the navx/displacement/x topic since the reset...
Definition: navX_ros_wrapper.cpp:254
void PubPitch()
Publishes the pitch readings from the NavX sensor to the navx/pitch topic.
Definition: navX_ros_wrapper.cpp:98
bool IsMagnDisturbance()
Signifies whether the value of the calibrated magnetic field strength for earth's magnetic field diff...
Definition: navX_ros_wrapper.cpp:408
void PubRawMagZ()
Publishes the raw magnetometer readings (in µTesla) in the Z-axis to the navx/raw_mag/z topic.
Definition: navX_ros_wrapper.cpp:358
void PubRawMagY()
Publishes the raw magnetometer readings (in µTesla) in the Y-axis to the navx/raw_mag/y topic.
Definition: navX_ros_wrapper.cpp:351
void PubRoll()
Publishes the roll readings from the NavX sensor to the navx/roll topic.
Definition: navX_ros_wrapper.cpp:105
navXROSWrapper(ros::NodeHandle *nh, VMXPi *vmx)
Constructs the NavX object using the specified parameters.
Definition: navX_ros_wrapper.cpp:3
void PubRawAccelY()
Publishes the raw acceleration rate (G) in the Y-axis to the navx/raw_accel/y topic.
Definition: navX_ros_wrapper.cpp:321
void PubRawMagX()
Publishes the raw magnetometer readings (in µTesla) in the X-axis to the navx/raw_mag/x topic.
Definition: navX_ros_wrapper.cpp:344
void PubQuatW()
Publishes the imaginary portion (W-axis) of the orientation quaternion with respect to where the yaw ...
Definition: navX_ros_wrapper.cpp:208
void PubPose()
Definition: navX_ros_wrapper.cpp:364
void PubYaw()
Publishes the yaw readings (in degrees, from -180 to 180) from the NavX sensor to the navx/yaw topic.
Definition: navX_ros_wrapper.cpp:112
void PubRawAccel()
Provides a grouped publisher for the raw acceleration rate (G) in the X, Y, and Z axes to the navx/ra...
Definition: navX_ros_wrapper.cpp:305
bool IsMoving()
Signifies whether the NavX is detecting motion based on the X and Y-axis world linear acceleration va...
Definition: navX_ros_wrapper.cpp:404
void PubRawMag()
Provides a grouped publishers to for the raw magnetometer readings (in µTesla) in the X,...
Definition: navX_ros_wrapper.cpp:335
void PubVelocity()
Provides a grouped publisher for velocity (in meters/sec) in the X, Y, and Z axes to the navx/velocit...
Definition: navX_ros_wrapper.cpp:215
~navXROSWrapper()
Destructor for the NavX object.
Definition: navX_ros_wrapper.cpp:78
void PubTimestamp()
Publishes the timestamp of the last sensor message reported from the NavX to the navx/last_sensor_tim...
Definition: navX_ros_wrapper.cpp:170
void PubLinearAccel()
Provides a grouped publisher for the linear acceleration in the X,Y, and Z axes to the navx/linear_ac...
Definition: navX_ros_wrapper.cpp:133
void PubQuatY()
Publishes the real portion (X-axis) of the orientation quaternion with respect to where the yaw angle...
Definition: navX_ros_wrapper.cpp:194
void Run_t()
Provides a method to call a thread of various Publishers of the NaxXROS library advertising sensor da...
Definition: navX_ros_wrapper.cpp:412
void PubDisplacement()
Provides a grouped publisher for displacement (in meters) in the X, Y, and Z axes since reset_displac...
Definition: navX_ros_wrapper.cpp:245
bool GetFirmwareVersion(vmxpi_ros::StringRes::Request &req, vmxpi_ros::StringRes::Response &res)
Provides the ROS service to get the firmware version number currently executing on the NavX when this...
Definition: navX_ros_wrapper.cpp:83
void PubQuatZ()
Publishes the real portion (X-axis) of the orientation quaternion with respect to where the yaw angle...
Definition: navX_ros_wrapper.cpp:201
void PubRawGyroZ()
Publishes the raw gyro rotation rate (in degrees/sec) in the X-axis to the navx/raw_gyro/z topic.
Definition: navX_ros_wrapper.cpp:298
bool IsRotating()
Signifies whether the NavX is detecting motion about the Z-axis (yaw rotation).
Definition: navX_ros_wrapper.cpp:406
void PubLinAccelZ()
Publishes the world linear acceleration in the Z-axis (in G) to the navx/linear_accel/z.
Definition: navX_ros_wrapper.cpp:156
bool IsMagCalibrated()
Signifies whether the magnetometer has been calibrated, this is done by the user.
Definition: navX_ros_wrapper.cpp:410
bool Reset(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Provides the ROS service to zero the yaw angle.
Definition: navX_ros_wrapper.cpp:389
void PubQuaternion()
Provides a grouped publisher for the orientation quaternion axes (W, X, Y, Z) with respect to where t...
Definition: navX_ros_wrapper.cpp:177
void PubDisplaceZ()
Publishes the displacement (in meters) in the Z-axis to the navx/displacement/z topic since the reset...
Definition: navX_ros_wrapper.cpp:268
void PubRawGyro()
Provides a grouped publisher for the gyro rotation rate (in degrees/sec) in the X,...
Definition: navX_ros_wrapper.cpp:275
void PubVelX()
Publishes the velocity (in meters/sec) in the X-axis to the navx/velocity/x.
Definition: navX_ros_wrapper.cpp:224
void PubVelZ()
Publishes the velocity (in meters/sec) in the Z-axis to the navx/velocity/z.
Definition: navX_ros_wrapper.cpp:238
void PubRollPitchYaw()
Provides a grouped publisher for roll, pitch, and yaw (-180 to 180 deg) to the navx/roll_pitch_yaw to...
Definition: navX_ros_wrapper.cpp:89
void PubHeading()
Publishes the compass heading readings from the NavX sensor to the navx/heading topic.
Definition: navX_ros_wrapper.cpp:126
void PubAngle()
Publishes the continuous angle readings from the NavX sensor to the navx/pitch topic.
Definition: navX_ros_wrapper.cpp:119
bool ResetDisplacement(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Provides the ROS service to reset the displacement, meaning a new origin is set where this is invoked...
Definition: navX_ros_wrapper.cpp:395