Communication link uisng Pyro4 - Robot Navigation

                                      As mention in the earlier the Localization Algorithm  localize the robot using it surrounding and also surrounding according to the the robot position. it uses a standard particle filter algorithm to position it self with respect to the the obstacle and also each particle go trough a karlman filter to guess the next position of the robot according to the control signal and error dynamics of the robot.
             It is not totally correct to divide the  functionally of the the two Algorithm separately since both contribute working as one for this scenarios. But is easy to understand this way. Systematically it is the way bias too.
             Before implementation of the Algorithm, If  communication link is implemented , that way it can easily simulate the robot data transmission over the network form the robot to the server.
It also help to test the performance of the system before hand and also it is easy to work with the situation and easy to test on while building.

Data link  -Robot

So for this case .Implementation of the communication link ,We can easily cope with python pyro, using pyro4 library for the python , Communication object is created . It act as Pyro Demon to the both end and to  inner network
using the object Data can be set to the link and data can be retrieve from the link Dynamically.

Pyro object :

@Pyro4.expose



class Robot(object):
        Dataencode = " this the data"
        Datascan = " "
        avilable = False



       @staticmethod
       def set_DataEncode(data):
             global Dataencode
             Dataencode = data



        @staticmethod
        def set_DataScan(data):
             global Datascan
             Datascan = data



        @staticmethod
        def is_avilable():
             global avilable
             return avilable



         @staticmethod
         def set_avilable():
               global avilable
               avilable = True



        @staticmethod
        def false_avilable():
              global avilable
              avilable = False



        @staticmethod
        def get_DataEncode():
              global Dataencode
              return Dataencode



        @staticmethod
        def get_DataScan():
              global Datascan
              return Datascan
Here,
 
@Pyro4.expose
will expose whole class to the pyro object.

The this should run as parallel process to Main loop, So that whenever needed ,It can be called . This object is initiated as parallel process to the robot main loop. Although python is not build for parallel processing we can easily use python multiprocessing library.

def comuincation(conn):
    daemon = Pyro4.Daemon()                    # make a Pyro daemon
    ns = Pyro4.locateNS()                      # find the name server
    uri = daemon.register(Robot)               # register the greeting maker
    ns.register("example.robot", uri)          # register the object with a name in the
    daemon.requestLoop()                       # start the event loop parent_conn,



to communicate in between the process Data pipe is implemented.
parent_conn, child_conn = Pipe()
p = Process(target=comuincation, args=(child_conn,))
p.start()
……
p.join()

Then inside the main loop every time when data bundle ready to processing it is push to the child_conn of the pipe() through a connection to the Deman object
like this way,
try:

     robot = Pyro4.Proxy("PYRONAME:example.robot")
except:
    Pyro4.errors.CommunicationError

while !robot.is_avilable():
    robot.set_DataEncode("Data")
    robot.set_DataScan("Data2")
    robot.set_avilable()

then the other side of the pipe() catches that data accordingly.

Data link -server

since the data link is already in the network. Server side all should do is Listening to the channel. If the new data is available in the network, retract the data from the network and mark it as old . Using a new connection to the Demon object
robot = Pyro4.Proxy("PYRONAME:example.robot")

if  robot.is_avilable():
    data_encode = robot.get_DataEncode();
    data_scan = robot.get_DataScan();
    robot.false_avilable()

Comments

Popular posts from this blog

Measuring 3D Distances between points using Kinect

Implementation - Robot Navigation

Full stack development of Robot navigation