ros_client.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import roslib
3 roslib.load_manifest('mini_maxwell')
4 import rospy
5 import sys
6 from mm2client import *
7 
8 from dynamic_reconfigure.server import Server as DynamicReconfigureServer
9 from mini_maxwell.cfg import RosClientConfig as ConfigType
10 
11 class MMClient():
12  def __init__(self):
13  MM_REV = 12
14  if MM_REV >= 12:
15  # Read the current settings from the Mini Maxwell
16  try:
17  self.bnds = GetCurrentBands(mm2name)
18  except:
19  self.bnds = Bands()
20  else: # MM_REV < 12
21  self.bnds = Bands()
22 
23  # Get parameter
24  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)]')
25  self.mm2name = rospy.get_param('~ip', '192.168.0.5')
26  self.round_trip = rospy.get_param('~round_trip', 100) #100ms
27  self.rate_limit = rospy.get_param('~rate_limit', 100000) #100kbps
28  self.band_number = 5
29  rospy.loginfo('mm2 hostname or ip = %s', self.mm2name)
30 
31  # Create a dynamic reconfigure server.
32  self.server = DynamicReconfigureServer(ConfigType, self.reconfigure)
33  rospy.spin()
34 
35  def reconfigure(self, config, level):
36  self.round_trip = config["round_trip"]
37  self.rate_limit = config["rate_limit"]
38 
39  # Return the new variables.
40  self.updateMM()
41  return config
42 
43  def updateMM(self):
44  self.bnds.SetDelayAmount(self.band_number, True, self.round_trip)
45  self.bnds.SetDelayAmount(self.band_number, False, self.round_trip)
46  self.bnds.SetRateLimit(self.band_number, True, self.rate_limit)
47  self.bnds.SetRateLimit(self.band_number, False, self.rate_limit)
48  self.bnds.SetDelayReorder(self.band_number, True, False)
49  self.bnds.SetDelayReorder(self.band_number, False, False)
50 
51  rospy.loginfo('round_trip = %s', self.round_trip)
52  rospy.loginfo('rate_limit = %s', self.rate_limit)
53  #update MM setting
54  ChangeBandsOnMM(self.bnds, self.mm2name)
55 
56 
57 if __name__ == '__main__':
58  rospy.init_node('mini_maxwell_client')
59 
60  try:
61  mmc = MMClient()
62  except rospy.ROSInterruptException: pass
def ChangeBandsOnMM(bandsobj, mm2host)
Definition: mm2client.py:479
def reconfigure(self, config, level)
Definition: ros_client.py:35
def __init__(self)
Definition: ros_client.py:12
def updateMM(self)
Definition: ros_client.py:43
def GetCurrentBands(mm2name)
Definition: mm2client.py:446


mini_maxwell
Author(s): Yusuke Furuta
autogenerated on Wed Jul 10 2019 03:47:09