JoystickDemo.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2015-2018, Dataspeed Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Dataspeed Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef JOYSTICKDEMO_H_
00036 #define JOYSTICKDEMO_H_
00037 
00038 #include <ros/ros.h>
00039 #include <sensor_msgs/Joy.h>
00040 #include <std_msgs/Empty.h>
00041 
00042 #include <dbw_pacifica_msgs/AcceleratorPedalCmd.h>
00043 #include <dbw_pacifica_msgs/BrakeCmd.h>
00044 #include <dbw_pacifica_msgs/SteeringCmd.h>
00045 #include <dbw_pacifica_msgs/GearCmd.h>
00046 #include <dbw_pacifica_msgs/MiscCmd.h>
00047 #include <dbw_pacifica_msgs/GlobalEnableCmd.h>
00048 
00049 namespace joystick_demo
00050 {
00051 
00052 typedef struct {
00053   ros::Time stamp;
00054   float brake_joy;
00055   float accelerator_pedal_joy;
00056   float steering_joy;
00057   bool steering_mult;
00058   int gear_cmd;
00059   int turn_signal_cmd;
00060   bool joy_accelerator_pedal_valid;
00061   bool joy_brake_valid;
00062   float accel_decel_limits;
00063 } JoystickDataStruct;
00064 
00065 class JoystickDemo {
00066 public:
00067   JoystickDemo(ros::NodeHandle &node, ros::NodeHandle &priv_nh);
00068 private:
00069   void recvJoy(const sensor_msgs::Joy::ConstPtr& msg);
00070   void cmdCallback(const ros::TimerEvent& event);
00071 
00072   // Topics
00073   ros::Subscriber sub_joy_;
00074   ros::Publisher pub_accelerator_pedal_;
00075   ros::Publisher pub_brake_;
00076   ros::Publisher pub_steering_;
00077   ros::Publisher pub_gear_;
00078   ros::Publisher pub_misc_;
00079   ros::Publisher pub_enable_;
00080   ros::Publisher pub_disable_;
00081   ros::Publisher pub_global_enable_;
00082   // Parameters
00083   bool ignore_; // Ignore driver overrides
00084   bool enable_; // Use enable and disable buttons
00085   bool count_; // Increment counter to enable watchdog
00086   double svel_; // Steering command speed
00087 
00088   // Variables
00089   ros::Timer timer_;
00090   JoystickDataStruct data_;
00091   sensor_msgs::Joy joy_;
00092   uint8_t counter_;
00093 
00094   enum {
00095     BTN_PARK = 3,
00096     BTN_REVERSE = 1,
00097     BTN_NEUTRAL = 2,
00098     BTN_DRIVE = 0,
00099     BTN_ENABLE = 5,
00100     BTN_DISABLE = 4,
00101     BTN_STEER_MULT_1 = 6,
00102     BTN_STEER_MULT_2 = 7,
00103     BTN_COUNT = 11,
00104     AXIS_ACCELERATOR_PEDAL = 5,
00105     AXIS_BRAKE = 2,
00106     AXIS_STEER_1 = 0,
00107     AXIS_STEER_2 = 3,
00108     AXIS_TURN_SIG = 6,
00109     AXIS_COUNT = 8,
00110   };
00111 };
00112 
00113 }
00114 
00115 #endif /* JOYSTICKDEMO_H_ */


dbw_pacifica_joystick_speed_demo
Author(s): Jane Doe
autogenerated on Sun Apr 7 2019 02:21:13