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


dbw_pacifica_joystick_speed_demo
Author(s): Jane Doe
autogenerated on Mon Jun 24 2019 19:18:35