Example #1
0
    def __init__(self,side,ik=True):
        limb.Limb.__init__(self,side)
        self.side=side
        
        self.DEFAULT_BAXTER_SPEED=0.3
        
        if not side in ["left","right"]:
            raise BaxterException,"Error non existing side: %s, please provide left or right"%side

        self.post=Post(self)
        self.__stop = False
        self.simple=self
        self._moving=False
        self.moving_lock=Lock()
        
        self.ik=ik        
        if self.ik:            
            self.ns = "/ExternalTools/%s/PositionKinematicsNode/IKService"%self.side    
            rospy.loginfo("Waiting for inverse kinematics service on %s..."%self.ns)
            rospy.wait_for_service(self.ns)
            self.iksvc = rospy.ServiceProxy(self.ns, SolvePositionIK)
            rospy.loginfo("Waiting for inverse kinematics service DONE")
        else:
            rospy.loginfo("Skipping inverse kinematics service loading")
        
        #self.simple_limb_srv = rospy.Service("/simple_limb/"+side,LimbPose,self.__cbLimbPose)
        
        self._pub_speed=rospy.Publisher("/robot/limb/%s/set_speed_ratio"%self.side,Float64,queue_size=1)
        while not rospy.is_shutdown() and self._pub_speed.get_num_connections() < 1:
            rospy.sleep(0.1)
    def __init__(self,port=1234,sub_topic="modbus_server/write_to_registers",pub_topic="modbus_server/read_from_registers"):
        """
            Creates a Modbus TCP Server object
            .. note:: The default port for modbus is 502. This modbus server uses port 1234 by default, otherwise superuser rights are required.
            
            .. note:: Use "startServer" to start the listener.
            
            :param port: Port for the modbus TCP server
            :type port: int
            :param sub_topic: ROS topic name for the subscriber that updates the modbus registers
            :type sub_topic: string
            :param pub_topic: ROS topic name for the publisher that publishes a message, once there is something written to the writeable modbus registers
            :type pub_topic: string
            
        """
        chr = CustomHoldingRegister(ADDRESS_WRITE_START, [17]*100,sub_topic,pub_topic)
        self.store = ModbusSlaveContext(
            di = ModbusSequentialDataBlock(ADDRESS_WRITE_START, [17]*100),
            co = ModbusSequentialDataBlock(ADDRESS_WRITE_START, [17]*100),
            hr = chr, 
            ir = ModbusSequentialDataBlock(ADDRESS_WRITE_START, [17]*100))
        self.context = ModbusServerContext(slaves=self.store, single=True)

        self.identity = ModbusDeviceIdentification()
        self.identity.VendorName  = 'Pymodbus'
        self.identity.ProductCode = 'PM'
        self.identity.VendorUrl   = 'http://github.com/bashwork/pymodbus/'
        self.identity.ProductName = 'Pymodbus Server'
        self.identity.ModelName   = 'Pymodbus Server'
        self.identity.MajorMinorRevision = '1.0'

        self.store.setValues(2,0,[0]*1)
        self.post = Post(self)
        framer = ModbusSocketFramer
        self.server = ModbusTcpServer(self.context, framer, self.identity, address=("0.0.0.0", port))
Example #3
0
class ModbusWrapperClient():
    """
        Wrapper that integrates python modbus into standardized ros msgs.
        The wrapper is able to read from and write to a standard modbus tcp/ip server.
    """
    def __init__(self,
                 host,
                 port=502,
                 rate=50,
                 reset_registers=True,
                 sub_topic="modbus_wrapper/output",
                 pub_topic="modbus_wrapper/input"):
        """
            Use subscribers and publisher to communicate with the modbus server. Check the scripts for example code.
            :param host: Contains the IP adress of the modbus server
            :type host: string
            :param port: The port number, where the modbus server is runnning
            :type port: integer
            :param rate: How often the registers on the modbusserver should be read per second
            :type rate: float
            :param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
            :type reset_registers: bool
        """
        try:
            self.client = ModbusTcpClient(host, port)
        except Exception, e:
            rospy.logwarn(
                "Could not get a modbus connection to the host modbus. %s",
                str(e))
            raise e
            return
        self.__rate = rate
        self.__reading_delay = 1 / rate
        self.post = Post(self)

        self.__reset_registers = reset_registers
        self.__reading_register_start = 0
        self.__num_reading_registers = 20
        #         self.input_size = 16
        self.__input = HoldingRegister()
        self.__input.data = [0 for i in xrange(self.__num_reading_registers)]

        self.__writing_registers_start = ADDRESS_WRITE_START
        self.__num_writing_registers = 20
        #         self.output_size = 16
        self.__output = [None for i in range(self.__num_writing_registers)]

        self.__last_output_time = rospy.get_time()
        self.__mutex = Lock()

        self.__sub = rospy.Subscriber(sub_topic,
                                      HoldingRegister,
                                      self.__updateModbusOutput,
                                      queue_size=500)
        self.__pub = rospy.Publisher(pub_topic,
                                     HoldingRegister,
                                     queue_size=500,
                                     latch=True)

        rospy.on_shutdown(self.closeConnection)
 def __init__(self,parent):
     super(IncomingSMS,self).__init__(parent)
     self.ui = Ui_IncomingSMS()
     self.ui.setupUi(self)
     self.post = Post(self)
     self.calling = False
     self.call_active = False
     self.ui.btn_close.clicked.connect(self.close)
Example #5
0
 def __init__(self,parent):
     super(IncomingCall,self).__init__(parent)
     self.ui = Ui_IncomingCall()
     self.ui.setupUi(self)
     self.post = Post(self)
     self.calling = False
     self.call_active = False
     self.ui.btn_hangup.clicked.connect(self.hangup)
     self.ui.btn_answer.clicked.connect(self.answer)
     self.ui.btn_close.clicked.connect(self.close)
Example #6
0
 def __init__(self, portname, rate=57142, timeout=0.04):
     """
     DO NOT CHANGE THE DEFAULT BAUDRATE HERE: 57142 is the factory setting of Dynamixel motors
     """
     self.portname = portname
     self.rate = rate
     self.timeout = timeout
     self.lock = Lock()
     self.open()
     self.configuration = None
     self.motors = {}
     self.post = Post(self)
Example #7
0
    def __init__(self, app):
        super(ControlMainWindow, self).__init__(None)
        # self.settings = QtCore.QSettings("root_window")
        self.app = app
        self.post = Post(self)
        self.widgets = {}
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.statusbar.showMessage("Not connected")
        self.show()

        self.post.initSerialBridge()
        self.initUi()
 def __init__(self):
     self.post = Post(self)
     self.conn_down = True
     self.initConnection()
     self.trigger_words = []
     self.callback = None