teleop_nao_joy.h
Go to the documentation of this file.
00001 /*
00002  * Nao Joystick / Gamepad teleoperation
00003  *
00004  * Copyright 2009-2012 Armin Hornung, University of Freiburg
00005  * http://www.ros.org/wiki/nao_teleop
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are met:
00009  *
00010  *     * Redistributions of source code must retain the above copyright
00011  *       notice, this list of conditions and the following disclaimer.
00012  *     * Redistributions in binary form must reproduce the above copyright
00013  *       notice, this list of conditions and the following disclaimer in the
00014  *       documentation and/or other materials provided with the distribution.
00015  *     * Neither the name of the University of Freiburg nor the names of its
00016  *       contributors may be used to endorse or promote products derived from
00017  *       this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 
00033 #ifndef NAO_TELEOP_TELEOP_NAO_JOY_
00034 #define NAO_TELEOP_TELEOP_NAO_JOY_
00035 
00036 #include <ros/ros.h>
00037 #include <std_msgs/String.h>
00038 #include <geometry_msgs/Twist.h>
00039 #include <std_srvs/Empty.h>
00040 #include <naoqi_bridge_msgs/JointAnglesWithSpeed.h>
00041 #include <naoqi_bridge_msgs/BodyPoseAction.h>
00042 #include <actionlib/client/simple_action_client.h>
00043 
00044 #include <sensor_msgs/Joy.h>
00045 
00046 
00047 namespace nao_teleop{
00053 class TeleopNaoJoy
00054 {
00055 public:
00056   TeleopNaoJoy();
00057   void pubMsg();
00058   ros::NodeHandle nh;
00059   ros::NodeHandle privateNh;
00060 
00064   ros::Subscriber subscribeToJoystick();
00065 
00070   bool callBodyPoseClient(const std::string& poseName);
00071 
00072 
00073 protected:
00074   void joyCallback(const sensor_msgs::Joy::ConstPtr& joy);
00075   bool buttonPressed(int button, const sensor_msgs::Joy::ConstPtr& joy) const;
00076   bool buttonTriggered(int button, const sensor_msgs::Joy::ConstPtr& joy) const;
00077   bool buttonChanged(int button, const sensor_msgs::Joy::ConstPtr& joy, const sensor_msgs::Joy::ConstPtr& prevJoy) const;
00078   void initializePreviousJoystick(const sensor_msgs::Joy::ConstPtr& joy);
00079   void setPreviousJoystick(const sensor_msgs::Joy::ConstPtr& joy) {
00080     m_previousJoystick = joy;
00081   }
00082 
00083   bool m_enabled;
00084 
00085 
00086 
00091   template<class M, class T>
00092   ros::Subscriber subscribeToJoystick(void(T::*fp)(M), T* obj) {
00093     m_joySub = nh.subscribe<sensor_msgs::Joy>("joy", 3, fp,obj);
00094     return m_joySub;
00095   }
00096 
00097   bool inhibitWalk(std_srvs::EmptyRequest& req, std_srvs::EmptyResponse& res);
00098   bool uninhibitWalk(std_srvs::EmptyRequest& req, std_srvs::EmptyResponse& res);
00099   bool axisValid(int axis, const sensor_msgs::Joy::ConstPtr& joy) const;
00100 
00101   int m_xAxis;
00102   int m_yAxis;
00103   int m_turnAxis;
00104   int m_headYawAxis;
00105   int m_headPitchAxis;
00106   int m_crouchBtn;
00107   int m_initPoseBtn;
00108   int m_enableBtn;
00109   int m_modifyHeadBtn;
00110   double m_maxVx;
00111   double m_maxVy;
00112   double m_maxVw;
00113   double m_maxHeadYaw;
00114   double m_maxHeadPitch;
00115   bool m_prevMotionZero;
00116   bool m_prevHeadZero;
00117   ros::Duration m_bodyPoseTimeOut;
00118   int m_inhibitCounter;
00119 
00120   bool m_previousJoystick_initialized;
00121   sensor_msgs::Joy::ConstPtr m_previousJoystick;
00122 
00123   ros::Publisher m_movePub;
00124   ros::Publisher m_moveBtnPub;
00125   ros::Publisher m_headPub;
00126   ros::Subscriber m_joySub;
00127   ros::Publisher m_speechPub;
00128   ros::ServiceServer m_inhibitWalkSrv;
00129   ros::ServiceServer m_uninhibitWalkSrv;
00130   ros::ServiceClient m_cmdVelClient;
00131   ros::ServiceClient m_stiffnessDisableClient;
00132   ros::ServiceClient m_stiffnessEnableClient;
00133   actionlib::SimpleActionClient<naoqi_bridge_msgs::BodyPoseAction> m_bodyPoseClient;
00134   geometry_msgs::Twist m_motion;
00135   naoqi_bridge_msgs::JointAnglesWithSpeed m_headAngles;
00136 };
00137 }
00138 
00139 #endif


nao_teleop
Author(s): Armin Hornung
autogenerated on Thu Jun 6 2019 21:07:29