accelerometer_ros_i.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, Open Source Robotics Foundation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef PHIDGETS_ACCELEROMETER_ACCELEROMETER_ROS_I_H
31 #define PHIDGETS_ACCELEROMETER_ACCELEROMETER_ROS_I_H
32 
33 #include <memory>
34 #include <mutex>
35 #include <string>
36 
37 #include <ros/ros.h>
38 
40 
41 namespace phidgets {
42 
43 const double G = 9.80665;
44 
45 class AccelerometerRosI final
46 {
47  public:
48  explicit AccelerometerRosI(ros::NodeHandle nh, ros::NodeHandle nh_private);
49 
50  private:
51  std::unique_ptr<Accelerometer> accelerometer_;
52  std::string frame_id_;
54  std::mutex accel_mutex_;
55  double last_accel_x_;
56  double last_accel_y_;
57  double last_accel_z_;
58 
62  void timerCallback(const ros::TimerEvent& event);
65  std::string server_name_;
66  std::string server_ip_;
67 
70  uint64_t data_time_zero_ns_{0};
72  uint64_t last_ros_stamp_ns_{0};
74  int64_t data_interval_ns_{0};
75  bool can_publish_{false};
78 
79  void publishLatest();
80 
81  void accelerometerChangeCallback(const double acceleration[3],
82  const double timestamp);
83 };
84 
85 } // namespace phidgets
86 
87 #endif // PHIDGETS_ACCELEROMETER_ACCELEROMETER_ROS_I_H
phidgets
phidgets::AccelerometerRosI::linear_acceleration_variance_
double linear_acceleration_variance_
Definition: accelerometer_ros_i.h:53
phidgets::AccelerometerRosI::publish_rate_
int publish_rate_
Definition: accelerometer_ros_i.h:64
ros::Publisher
phidgets::AccelerometerRosI
Definition: accelerometer_ros_i.h:45
phidgets::AccelerometerRosI::nh_private_
ros::NodeHandle nh_private_
Definition: accelerometer_ros_i.h:60
phidgets::AccelerometerRosI::server_name_
std::string server_name_
Definition: accelerometer_ros_i.h:65
phidgets::AccelerometerRosI::timerCallback
void timerCallback(const ros::TimerEvent &event)
Definition: accelerometer_ros_i.cpp:193
ros.h
phidgets::AccelerometerRosI::accelerometer_pub_
ros::Publisher accelerometer_pub_
Definition: accelerometer_ros_i.h:61
phidgets::AccelerometerRosI::last_accel_y_
double last_accel_y_
Definition: accelerometer_ros_i.h:56
phidgets::AccelerometerRosI::synchronize_timestamps_
bool synchronize_timestamps_
Definition: accelerometer_ros_i.h:69
phidgets::AccelerometerRosI::accel_mutex_
std::mutex accel_mutex_
Definition: accelerometer_ros_i.h:54
phidgets::AccelerometerRosI::accelerometerChangeCallback
void accelerometerChangeCallback(const double acceleration[3], const double timestamp)
Definition: accelerometer_ros_i.cpp:202
phidgets::AccelerometerRosI::last_accel_x_
double last_accel_x_
Definition: accelerometer_ros_i.h:55
phidgets::AccelerometerRosI::last_accel_z_
double last_accel_z_
Definition: accelerometer_ros_i.h:57
phidgets::AccelerometerRosI::can_publish_
bool can_publish_
Definition: accelerometer_ros_i.h:75
phidgets::AccelerometerRosI::frame_id_
std::string frame_id_
Definition: accelerometer_ros_i.h:52
phidgets::AccelerometerRosI::AccelerometerRosI
AccelerometerRosI(ros::NodeHandle nh, ros::NodeHandle nh_private)
Definition: accelerometer_ros_i.cpp:41
phidgets::AccelerometerRosI::data_time_zero_ns_
uint64_t data_time_zero_ns_
Definition: accelerometer_ros_i.h:70
phidgets::AccelerometerRosI::ros_time_zero_
ros::Time ros_time_zero_
Definition: accelerometer_ros_i.h:68
phidgets::AccelerometerRosI::nh_
ros::NodeHandle nh_
Definition: accelerometer_ros_i.h:59
phidgets::AccelerometerRosI::publishLatest
void publishLatest()
Definition: accelerometer_ros_i.cpp:151
ros::TimerEvent
phidgets::AccelerometerRosI::timer_
ros::Timer timer_
Definition: accelerometer_ros_i.h:63
accelerometer.h
ros::Time
phidgets::AccelerometerRosI::last_ros_stamp_ns_
uint64_t last_ros_stamp_ns_
Definition: accelerometer_ros_i.h:72
phidgets::AccelerometerRosI::last_data_timestamp_ns_
uint64_t last_data_timestamp_ns_
Definition: accelerometer_ros_i.h:71
phidgets::AccelerometerRosI::data_interval_ns_
int64_t data_interval_ns_
Definition: accelerometer_ros_i.h:74
phidgets::AccelerometerRosI::server_ip_
std::string server_ip_
Definition: accelerometer_ros_i.h:66
phidgets::G
const double G
Definition: accelerometer_ros_i.h:43
phidgets::AccelerometerRosI::time_resync_interval_ns_
int64_t time_resync_interval_ns_
Definition: accelerometer_ros_i.h:73
phidgets::AccelerometerRosI::last_cb_time_
ros::Time last_cb_time_
Definition: accelerometer_ros_i.h:76
phidgets::AccelerometerRosI::accelerometer_
std::unique_ptr< Accelerometer > accelerometer_
Definition: accelerometer_ros_i.h:51
phidgets::AccelerometerRosI::cb_delta_epsilon_ns_
int64_t cb_delta_epsilon_ns_
Definition: accelerometer_ros_i.h:77
ros::Timer
ros::NodeHandle


phidgets_accelerometer
Author(s): Chris Lalancette
autogenerated on Sat Dec 2 2023 03:18:48