|
| 1 | +/* |
| 2 | + * Copyright (c) 2008, Willow Garage, Inc. |
| 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 Willow Garage, Inc. 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 SPACENAV__SPACENAV_HPP_ |
| 31 | +#define SPACENAV__SPACENAV_HPP_ |
| 32 | + |
| 33 | +#include <rclcpp/rclcpp.hpp> |
| 34 | + |
| 35 | +#include <geometry_msgs/msg/twist.hpp> |
| 36 | +#include <geometry_msgs/msg/vector3.hpp> |
| 37 | +#include <sensor_msgs/msg/joy.hpp> |
| 38 | + |
| 39 | +#include "spnav.h" // NOLINT |
| 40 | + |
| 41 | +namespace spacenav |
| 42 | +{ |
| 43 | + |
| 44 | +class Spacenav final : public rclcpp::Node |
| 45 | +{ |
| 46 | +public: |
| 47 | + explicit Spacenav(const rclcpp::NodeOptions & options); |
| 48 | + |
| 49 | + ~Spacenav(); |
| 50 | + |
| 51 | +private: |
| 52 | + void poll_spacenav(); |
| 53 | + |
| 54 | + OnSetParametersCallbackHandle::SharedPtr callback_handler; |
| 55 | + |
| 56 | + rclcpp::TimerBase::SharedPtr timer_; |
| 57 | + |
| 58 | + rclcpp::Publisher<geometry_msgs::msg::Vector3>::SharedPtr publisher_offset; |
| 59 | + |
| 60 | + rclcpp::Publisher<geometry_msgs::msg::Vector3>::SharedPtr publisher_rot_offset; |
| 61 | + |
| 62 | + rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr publisher_twist; |
| 63 | + |
| 64 | + rclcpp::Publisher<sensor_msgs::msg::Joy>::SharedPtr publisher_joy; |
| 65 | + |
| 66 | + bool spacenav_is_open = false; |
| 67 | + |
| 68 | + double full_scale; |
| 69 | + double linear_scale[3]; |
| 70 | + double angular_scale[3]; |
| 71 | + |
| 72 | + int static_count_threshold; |
| 73 | + bool zero_when_static; |
| 74 | + double static_trans_deadband; |
| 75 | + double static_rot_deadband; |
| 76 | + |
| 77 | + spnav_event sev; |
| 78 | + bool joy_stale = false; |
| 79 | + int no_motion_count = 0; |
| 80 | + bool motion_stale = false; |
| 81 | + double normed_vx = 0; |
| 82 | + double normed_vy = 0; |
| 83 | + double normed_vz = 0; |
| 84 | + double normed_wx = 0; |
| 85 | + double normed_wy = 0; |
| 86 | + double normed_wz = 0; |
| 87 | +}; |
| 88 | + |
| 89 | +} // namespace spacenav |
| 90 | + |
| 91 | +#endif // SPACENAV__SPACENAV_HPP_ |
0 commit comments