wheel_scaler.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 """
00004    wheel_scaler
00005    scales the wheel readings (and inverts the sign)
00006    
00007      Copyright (C) 2012 Jon Stephan. 
00008      
00009     This program is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021    
00022 """
00023 
00024 import rospy
00025 import roslib
00026 
00027 from std_msgs.msg import Int16
00028 
00029 def lwheelCallback(msg):
00030     lscaled_pub.publish( msg.data * -1 * scale)
00031     
00032 def rwheelCallback(msg):
00033     rscaled_pub.publish( msg.data * -1 * scale)
00034     
00035 
00036 if __name__ == '__main__':
00037     """main"""
00038     rospy.init_node("wheel_scaler")
00039     rospy.loginfo("wheel_scaler started")
00040     
00041     scale = rospy.get_param('distance_scale', 1)
00042     rospy.loginfo("wheel_scaler scale: %0.2f", scale)
00043     
00044     rospy.Subscriber("lwheel", Int16, lwheelCallback)
00045     rospy.Subscriber("rwheel", Int16, rwheelCallback)
00046     
00047     lscaled_pub = rospy.Publisher("lwheel_scaled", Int16)
00048     rscaled_pub = rospy.Publisher("rwheel_scaled", Int16) 
00049     
00050     ### testing sleep CPU usage
00051     r = rospy.Rate(50) 
00052     while not rospy.is_shutdown:
00053         r.sleep()
00054         
00055     rospy.spin()


differential_drive
Author(s): Jon Stephan
autogenerated on Sun Oct 5 2014 23:28:30