ros_client.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib
00003 roslib.load_manifest('mini_maxwell')
00004 import rospy
00005 import sys
00006 from mm2client import *
00007 
00008 from dynamic_reconfigure.server import Server as DynamicReconfigureServer
00009 from mini_maxwell.cfg import RosClientConfig as ConfigType
00010 
00011 class MMClient():
00012     def __init__(self):
00013         MM_REV = 12
00014         if MM_REV >= 12:
00015         # Read the current settings from the Mini Maxwell
00016             try:
00017                 self.bnds = GetCurrentBands(mm2name)
00018             except:
00019                 self.bnds = Bands()
00020         else: # MM_REV < 12
00021             self.bnds = Bands()
00022 
00023         # Get parameter
00024         rospy.logwarn('[usage] rosrun mini_maxwell ros_client.py _ip:=[mini_maxwell ip or hostname] _round_trimp:=[round trip(ms)] _rate_limit:=[rate limit(bps)]')
00025         self.mm2name = rospy.get_param('~ip', '192.168.0.5')
00026         self.round_trip  = rospy.get_param('~round_trip', 100) #100ms
00027         self.rate_limit = rospy.get_param('~rate_limit', 100000) #100kbps
00028         self.band_number = 5
00029         rospy.loginfo('mm2 hostname or ip = %s', self.mm2name)
00030 
00031         # Create a dynamic reconfigure server.
00032         self.server = DynamicReconfigureServer(ConfigType, self.reconfigure)
00033         rospy.spin()
00034 
00035     def reconfigure(self, config, level):
00036         self.round_trip = config["round_trip"]
00037         self.rate_limit = config["rate_limit"]
00038 
00039         # Return the new variables.
00040         self.updateMM()
00041         return config
00042 
00043     def updateMM(self):
00044         self.bnds.SetDelayAmount(self.band_number, True, self.round_trip)
00045         self.bnds.SetDelayAmount(self.band_number, False, self.round_trip)
00046         self.bnds.SetRateLimit(self.band_number, True, self.rate_limit)
00047         self.bnds.SetRateLimit(self.band_number, False, self.rate_limit)
00048         self.bnds.SetDelayReorder(self.band_number, True, False)
00049         self.bnds.SetDelayReorder(self.band_number, False, False)
00050 
00051         rospy.loginfo('round_trip = %s', self.round_trip)
00052         rospy.loginfo('rate_limit = %s', self.rate_limit)
00053         #update MM setting
00054         ChangeBandsOnMM(self.bnds, self.mm2name)
00055 
00056 
00057 if __name__ == '__main__':
00058     rospy.init_node('mini_maxwell_client')
00059 
00060     try:
00061         mmc = MMClient()
00062     except rospy.ROSInterruptException: pass


mini_maxwell
Author(s): Yusuke Furuta
autogenerated on Wed Jul 10 2019 03:24:08