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>
46 #include <dbw_mkz_msgs/TurnSignalCmd.h>
47 
48 typedef struct {
50  float brake_joy;
51  float throttle_joy;
52  float steering_joy;
54  int gear_cmd;
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 
msg
ros::Publisher pub_steering_
Definition: JoystickDemo.h:71
ros::Publisher pub_gear_
Definition: JoystickDemo.h:72
sensor_msgs::Joy joy_
Definition: JoystickDemo.h:98
ros::Publisher pub_brake_
Definition: JoystickDemo.h:69
JoystickDataStruct data_
Definition: JoystickDemo.h:97
ros::Timer timer_
Definition: JoystickDemo.h:96
JoystickDemo(ros::NodeHandle &node, ros::NodeHandle &priv_nh)
ros::Publisher pub_enable_
Definition: JoystickDemo.h:74
ros::Publisher pub_disable_
Definition: JoystickDemo.h:75
ros::Subscriber sub_joy_
Definition: JoystickDemo.h:68
void recvJoy(const sensor_msgs::Joy::ConstPtr &msg)
uint8_t counter_
Definition: JoystickDemo.h:99
ros::Publisher pub_throttle_
Definition: JoystickDemo.h:70
void cmdCallback(const ros::TimerEvent &event)
ros::Publisher pub_turn_signal_
Definition: JoystickDemo.h:73
float last_steering_filt_output_
Definition: JoystickDemo.h:100
float throttle_gain_
Definition: JoystickDemo.h:86
float brake_gain_
Definition: JoystickDemo.h:85
node


dbw_mkz_joystick_demo
Author(s): Micho Radovnikovich
autogenerated on Fri May 14 2021 02:47:11