class_xbox_ptu_teleop.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
31 #include <ros/ros.h>
32 #include <string>
33 #include <iostream>
34 #include <vector>
35 #include <sensor_msgs/Joy.h>
36 #include <atlascar_base/AtlascarCommand.h>
37 
38 
39 #ifndef _ATLASCAR_XBOX_TELEOP_
40 #define _ATLASCAR_XBOX_TELEOP_
41 
42 using namespace std;
43 using namespace ros;
44 
45 
50 {
51  public:
58  XboxTeleopAtlascar(int num_but, int num_axis);
63 
65  struct TYPE_analog{
66  int toggled;
67  float val;
68 
69  friend ostream& operator<<(ostream &o, const TYPE_analog& i)
70  {
71  o<<"toogle:"<<i.toggled<<"\nval:"<<i.val<<endl;
72  return o;
73  }
74  };
75 
77  enum{MAN_AUTO_STEER=0, MAN_AUTO_BRAKE=1, MAN_AUTO_THROTTLE=2, MAN_AUTO_CLUTCH=3, _B4=4, MAN_AUTO_IGNITION=5,\
78  START=6, E_STOP=7, _B8=8, _B9=9, HIGH_LIGHTS=10, WARNING_LIGHTS=11, MEDIUM_LIGHTS=12,\
79  _B13=13, STOP=14};
81  enum{STEERING=0, _A1=1, BRAKE=2, _A3=3, CLUTCH=4, THROTTLE=5};
82 
83 
84  private:
85 
91  void XboxCallback(const sensor_msgs::Joy::ConstPtr& joy);
92 
96  ros::NodeHandle nh_teleop;
97 
101  vector<int> button;
102 
106  vector<TYPE_analog> analog;
107 
111  float steering_left_ang, steering_right_ang;
115  float m_left_ang, b_left_ang, m_right_ang, b_right_ang;
116 
120  float speed_min, speed_max;
124  float m_speed, b_speed;
128  float m_brake, b_brake;
132  int num_buttons, num_axes;
133 
137  atlascar_base::AtlascarCommand command;
141  ros::Publisher atlascar_cmd_;
145  ros::Subscriber joy_sub_;
146 
147 };
148 
149 
150 #endif
float speed_min
car speed limits
ros::Publisher atlascar_cmd_
method just to publish the base message
atlascar_base::AtlascarCommand command
struct with the Atlascar Base Command message
int num_buttons
variable with number of digital buttons and analog axis
ros::Subscriber joy_sub_
method to subscribe the gamepad message
friend ostream & operator<<(ostream &o, const TYPE_analog &i)
ros::NodeHandle nh_teleop
float m_speed
line segment slope to calculate whished car speed value
struct to define a analog button
float m_brake
line segment slope to calculate whished car speed value
vector< int > button
vector with all digital buttons status
vector< TYPE_analog > analog
vector with analog/axis values
This class simplifies the implementation of a interface between xbox and PTU.


atlascar_teleop
Author(s): David Gameiro
autogenerated on Mon Mar 2 2015 01:31:27