def callback(self, cmd_msg): pos = cmd_msg.data if (pos > 100): pos = 100 elif (pos < 0): pos = 0 Setter.callback(self, pos)
def run(self, rospy, hostname): # initialize the connection and create subscribers Setter.init(self,(1206,1207)) rospy.Subscriber('/'+hostname+'/cmd_vel', Twist, self.callback) rospy.Subscriber('/'+hostname+'/cmd_vel_left', Float64, self.set_left) rospy.Subscriber('/'+hostname+'/cmd_vel_right', Float64, self.set_right)
def callback(self, cmd_msg): # callback function - extends the setter.callback functionality # formats data to be passed to mindprobe pos = cmd_msg.data if (pos > 100): pos = 100 elif (pos < 0): pos = 0 Setter.callback(self, pos)
def handleData(self, data: bytearray): text = data[1:len(data) - 5].decode(encoding="utf-8", errors='ignore') splitted = text.split("|", ) name = True currName = "" for i in reversed(range(self.settingsContentWidget.layout().count()) ): #clear layout from previous settings self.settingsContentWidget.layout().itemAt(i).widget().setParent( None) for item in splitted: if (len(item) > 0): if (name): name = False currName = item else: name = True setter = Setter(currName, item, None) self.settingsContentWidget.layout().addWidget(setter) setter.changeAvailable.connect(self.requestChange) '''if(len(data)<6): return
# This is the code that visits the warehouse. import sys import Pyro4 import Pyro4.util from setter import Setter sys.excepthook = Pyro4.util.excepthook times = Pyro4.Proxy("PYRONAME:example.times") setter = Setter("myset") setter.set(times)
def set_right(self,cmd_msg): # callback to set the right wheel vel = cmd_msg.data Setter.callback(self,[0,vel])
def set_left(self,cmd_msg): # callback to set the left wheel vel = cmd_msg.data Setter.callback(self,[vel,0])
def callback(self, cmd_msg): # differential drive callback. vel = twist_to_vel(cmd_msg) Setter.callback(self,vel)
def set_right(self, cmd_msg): vel = cmd_msg.data Setter.callback(self, [0, vel])
def set_left(self, cmd_msg): vel = cmd_msg.data Setter.callback(self, [vel, 0])
def callback(self, cmd_msg): vel = twist_to_vel(cmd_msg) Setter.callback(self, vel)
def init(self): Setter.init(self, (1206, 1207))
def run(self, rospy, hostname): # intializes the mp connection and runs a subscriber for setting the arm position. Setter.init(self, 1077) rospy.Subscriber('/' + hostname + '/set_arm_pos', Float32, self.callback)
def init(self): Setter.init(self, 1080)