JoystickDemo.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015-2019, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef JOYSTICKDEMO_H_
36 #define JOYSTICKDEMO_H_
37 
38 #include <ros/ros.h>
39 #include <sensor_msgs/Joy.h>
40 #include <std_msgs/Empty.h>
41 
42 #include <dbw_mkz_msgs/ThrottleCmd.h>
43 #include <dbw_mkz_msgs/BrakeCmd.h>
44 #include <dbw_mkz_msgs/SteeringCmd.h>
45 #include <dbw_mkz_msgs/GearCmd.h>
47 
48 typedef struct {
49  ros::Time stamp;
50  float brake_joy;
51  float throttle_joy;
52  float steering_joy;
53  bool steering_mult;
54  int gear_cmd;
55  int turn_signal_cmd;
56  bool joy_throttle_valid;
57  bool joy_brake_valid;
59 
60 class JoystickDemo {
61 public:
63 private:
64  void recvJoy(const sensor_msgs::Joy::ConstPtr& msg);
65  void cmdCallback(const ros::TimerEvent& event);
66 
67  // Topics
76 
77  // Parameters
78  bool brake_; // Send brake commands
79  bool throttle_; // Send throttle commands
80  bool steer_; // Send steering commands
81  bool shift_; // Send shift commands
82  bool signal_; // Send turn signal commands
83 
84  // Parameters
85  float brake_gain_; // Adjust brake value
86  float throttle_gain_; // Adjust throttle value
87 
88  // Parameters
89  bool ignore_; // Ignore driver overrides
90  bool enable_; // Use enable and disable buttons
91  bool count_; // Increment counter to enable watchdog
92  bool strq_; // Steering torque command (otherwise angle)
93  float svel_; // Steering command speed
94 
95  // Variables
98  sensor_msgs::Joy joy_;
99  uint8_t counter_;
101 
102  enum {
103  BTN_PARK = 3,
120  };
121 };
122 
123 #endif /* JOYSTICKDEMO_H_ */
124 
JoystickDemo::strq_
bool strq_
Definition: JoystickDemo.h:92
JoystickDemo::BTN_STEER_MULT_2
@ BTN_STEER_MULT_2
Definition: JoystickDemo.h:110
JoystickDemo::AXIS_TURN_SIG
@ AXIS_TURN_SIG
Definition: JoystickDemo.h:117
JoystickDemo::BTN_STEER_MULT_1
@ BTN_STEER_MULT_1
Definition: JoystickDemo.h:109
JoystickDemo::throttle_gain_
float throttle_gain_
Definition: JoystickDemo.h:86
JoystickDataStruct
Definition: JoystickDemo.h:48
msg
msg
ros::Publisher
JoystickDemo::pub_gear_
ros::Publisher pub_gear_
Definition: JoystickDemo.h:72
JoystickDemo::steer_
bool steer_
Definition: JoystickDemo.h:80
JoystickDemo::BTN_COUNT_X
@ BTN_COUNT_X
Definition: JoystickDemo.h:111
JoystickDemo::pub_disable_
ros::Publisher pub_disable_
Definition: JoystickDemo.h:75
ros.h
JoystickDemo::AXIS_STEER_2
@ AXIS_STEER_2
Definition: JoystickDemo.h:116
JoystickDemo::BTN_COUNT_D
@ BTN_COUNT_D
Definition: JoystickDemo.h:112
JoystickDemo::pub_turn_signal_
ros::Publisher pub_turn_signal_
Definition: JoystickDemo.h:73
JoystickDemo::pub_brake_
ros::Publisher pub_brake_
Definition: JoystickDemo.h:69
JoystickDemo::throttle_
bool throttle_
Definition: JoystickDemo.h:79
JoystickDemo::BTN_REVERSE
@ BTN_REVERSE
Definition: JoystickDemo.h:104
JoystickDemo::BTN_ENABLE
@ BTN_ENABLE
Definition: JoystickDemo.h:107
JoystickDemo::ignore_
bool ignore_
Definition: JoystickDemo.h:89
JoystickDemo::BTN_NEUTRAL
@ BTN_NEUTRAL
Definition: JoystickDemo.h:105
JoystickDemo::joy_
sensor_msgs::Joy joy_
Definition: JoystickDemo.h:98
JoystickDemo::counter_
uint8_t counter_
Definition: JoystickDemo.h:99
JoystickDemo::signal_
bool signal_
Definition: JoystickDemo.h:82
JoystickDemo::pub_steering_
ros::Publisher pub_steering_
Definition: JoystickDemo.h:71
JoystickDemo::sub_joy_
ros::Subscriber sub_joy_
Definition: JoystickDemo.h:68
JoystickDemo::enable_
bool enable_
Definition: JoystickDemo.h:90
JoystickDemo::recvJoy
void recvJoy(const sensor_msgs::Joy::ConstPtr &msg)
Definition: JoystickDemo.cpp:189
JoystickDemo::AXIS_STEER_1
@ AXIS_STEER_1
Definition: JoystickDemo.h:115
JoystickDemo::brake_
bool brake_
Definition: JoystickDemo.h:78
ros::TimerEvent
JoystickDemo::svel_
float svel_
Definition: JoystickDemo.h:93
JoystickDemo
Definition: JoystickDemo.h:60
ros::Time
JoystickDemo::timer_
ros::Timer timer_
Definition: JoystickDemo.h:96
JoystickDemo::brake_gain_
float brake_gain_
Definition: JoystickDemo.h:85
JoystickDemo::AXIS_THROTTLE
@ AXIS_THROTTLE
Definition: JoystickDemo.h:113
JoystickDemo::pub_enable_
ros::Publisher pub_enable_
Definition: JoystickDemo.h:74
JoystickDemo::BTN_DRIVE
@ BTN_DRIVE
Definition: JoystickDemo.h:106
JoystickDemo::data_
JoystickDataStruct data_
Definition: JoystickDemo.h:97
JoystickDemo::last_steering_filt_output_
float last_steering_filt_output_
Definition: JoystickDemo.h:100
TurnSignalCmd.h
JoystickDemo::AXIS_COUNT_D
@ AXIS_COUNT_D
Definition: JoystickDemo.h:118
JoystickDemo::BTN_DISABLE
@ BTN_DISABLE
Definition: JoystickDemo.h:108
JoystickDemo::pub_throttle_
ros::Publisher pub_throttle_
Definition: JoystickDemo.h:70
JoystickDemo::count_
bool count_
Definition: JoystickDemo.h:91
JoystickDemo::BTN_PARK
@ BTN_PARK
Definition: JoystickDemo.h:103
JoystickDemo::cmdCallback
void cmdCallback(const ros::TimerEvent &event)
Definition: JoystickDemo.cpp:106
JoystickDemo::AXIS_COUNT_X
@ AXIS_COUNT_X
Definition: JoystickDemo.h:119
ros::Timer
node
node
JoystickDemo::AXIS_BRAKE
@ AXIS_BRAKE
Definition: JoystickDemo.h:114
ros::NodeHandle
ros::Subscriber
JoystickDemo::shift_
bool shift_
Definition: JoystickDemo.h:81
JoystickDemo::JoystickDemo
JoystickDemo(ros::NodeHandle &node, ros::NodeHandle &priv_nh)
Definition: JoystickDemo.cpp:37


dbw_mkz_joystick_demo
Author(s): Micho Radovnikovich
autogenerated on Thu Jan 4 2024 03:46:29