segway_node.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 # Copyright (c) 2009, Georgia Tech Research Corporation
00003 # All rights reserved.
00004 #
00005 # Redistribution and use in source and binary forms, with or without
00006 # modification, are permitted provided that the following conditions are met:
00007 #     * Redistributions of source code must retain the above copyright
00008 #       notice, this list of conditions and the following disclaimer.
00009 #     * Redistributions in binary form must reproduce the above copyright
00010 #       notice, this list of conditions and the following disclaimer in the
00011 #       documentation and/or other materials provided with the distribution.
00012 #     * Neither the name of the Georgia Tech Research Corporation nor the
00013 #       names of its contributors may be used to endorse or promote products
00014 #       derived from this software without specific prior written permission.
00015 #
00016 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00017 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00021 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00022 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00024 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 #
00027 #  \author Hai Nguyen (Healthcare Robotics Lab, Georgia Tech.)
00028 #  \author Marc Killpack (Healthcare Robotics Lab, Georgia Tech.)
00029 
00030 import roslib; roslib.load_manifest('hrl_segway_omni')
00031 from hrl_lib.msg import PlanarBaseVel
00032 from geometry_msgs.msg import Twist
00033 import rospy
00034 import segway
00035 import numpy as np
00036 
00037 def callback(cmd):
00038     #print 'segway_node:', cmd.xvel, cmd.yvel, cmd.angular_velocity
00039     mecanum.set_velocity(cmd.xvel, cmd.yvel, cmd.angular_velocity)
00040 
00041 def callback_ros(cmd):
00042     #print 'segway_node:', cmd.linear.x, cmd.linear.y, cmd.angular.z
00043     avel = cmd.angular.z * 0.5
00044     avel = np.clip(avel,-0.2,0.2)
00045     mecanum.set_velocity(cmd.linear.x, cmd.linear.y, avel)
00046 
00047 rospy.init_node("segway_node", anonymous=False)
00048 rospy.Subscriber("base", PlanarBaseVel, callback, None, 1)
00049 rospy.Subscriber("cmd_vel", Twist, callback_ros, None, 1)
00050 #mecanum = segway.Mecanum(init_ros_node=False)
00051 mecanum = segway.Mecanum()
00052 rospy.spin()
00053 


hrl_segway_omni
Author(s): Cressel Anderson, Hai Nguyen, Marc Killpack, Advait Jain Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:55:25