Пример #1
0
def callbackCommandResponse(data):
    print "callbackCommandResponse name command:" + data.name
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.name)
    clipsFunctions.Assert('(BB_received "{0}" {1} {2} "{3}")'.format(data.name, data.id, data.successful, data.params))
    clipsFunctions.PrintOutput()
    clipsFunctions.Run(BBFunctions.gui.getRunTimes())
    clipsFunctions.PrintOutput()
Пример #2
0
def callbackCommandSendAndRunClips(data):
    print 'SEND AND RUN COMMAND'
    _clipsLock.acquire()
    clips.SendCommand(data.data, True)
    clipsFunctions.PrintOutput()
    _clipsLock.release()
    clipsFunctions.Run('')
    clipsFunctions.PrintOutput()
def RunCommand(c):
    clipsFunctions.Assert('(BB_cmd "{0}" {1} "{2}")'.format(
        c.name, c._id, c.params))
    clipsFunctions.PrintOutput()
    clipsFunctions.Run()
    clipsFunctions.PrintOutput()
    time.sleep(1)
    return Response.FromCommandObject(
        c, False, 'CLIPS was busy or not able to handle the command.')
Пример #4
0
def callbackCommandResponse(data):
    print "callbackCommandResponse name command:" + data.name
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.name)
    clipsFunctions.Assert('(BB_received "{0}" {1} {2} "{3}")'.format(
        data.name, data.id, data.successful, data.params))
    clipsFunctions.PrintOutput()
    clipsFunctions.Run(
        ''
    )  # aqui se manda el numero de pasos que ejecutara CLIPS con [''] se ejecutan todos los pasos sin detenerse
    clipsFunctions.PrintOutput()
Пример #5
0
def str_query_KDB(req):
    print 'QUERY IN KDB ' + req.query
    _clipsLock.acquire()
    clips.SendCommand(req.query, True)
    clipsFunctions.PrintOutput()
    _clipsLock.release()
    clipsFunctions.Run('')
    result = str(clips.StdoutStream.Read())
    print 'RESULT OF QUERY= ' + result
    print ''
    return StrQueryKDBResponse(result)
Пример #6
0
def str_query(req):
    print 'Query in KDB' + req.query
    _clipsLock.acquire()
    clips.SendCommand(req.query, True)
    clipsFunctions.PrintOutput()
    _clipsLock.release()
    clipsFunctions.Run('')
    result = str(clips.StdoutStream.Read())
    if result.count('ROS') == 2:
        print 'ROS response'
        r = result.split('ROS')
        print r
        result = r[1]

    else:
        result = 'None'
        
    print 'Result of Query= ' + result
    print ''
    return StrQueryKDBResponse(result)
Пример #7
0
def init_KDB(req):
    print 'INIT KDB'
    print 'LOAD FILE'
    global file_gpsr
    rospack = rospkg.RosPack()
    #file_gpsr = rospack.get_path('simulator') + '/src/rules_base/oracle.dat'
    if not req.filePath:
        filePath = file_gpsr
    else:
        filepath = rospack.get_path('simulator') 
        #clips.BatchStar(filepath + os.sep + 'CLIPS' + os.sep + 'BB_interface.clp')
        filePath = filepath + req.filePath
        #filePath = req.filePath
    print 'Load file in path' + filePath
    if filePath[-3:] == 'clp':
        _clipsLock.acquire()
        clips.BatchStar(filePath)
        clipsFunctions.PrintOutput()
        _clipsLock.release()
        print 'File Loaded!'
        return

    path = os.path.dirname(os.path.abspath(filePath))
    f = open(filePath, 'r')
    line = f.readline()
    _clipsLock.acquire()
    while line:
        clips.BatchStar((path + os.sep + line).strip())
        line = f.readline()
    f.close()
    clipsFunctions.PrintOutput()
    _clipsLock.release()

    print 'Files Loaded!'

    clipsFunctions.Reset()
    print 'Facts were reset!'
    setLogLevelTest()
    if req.run == True:
        clipsFunctions.Run('')
    return InitKDBResponse()
Пример #8
0
def init_KDB(req):
    print 'INIT KDB'
    print 'LOAD FILE'
    global file_gpsr
    if not req.filePath:
        filePath = file_gpsr
    else:
        filePath = req.filePath
    print 'Load file in path' + filePath
    if filePath[-3:] == 'clp':
        _clipsLock.acquire()
        clips.BatchStar(filePath)
        clipsFunctions.PrintOutput()
        _clipsLock.release()
        print 'File Loaded!'
        return

    path = os.path.dirname(os.path.abspath(filePath))
    f = open(filePath, 'r')
    line = f.readline()
    _clipsLock.acquire()
    while line:
        clips.BatchStar((path + os.sep + line).strip())
        line = f.readline()
    f.close()
    clipsFunctions.PrintOutput()
    _clipsLock.release()

    print 'Files Loaded!'

    clipsFunctions.Reset()
    print 'Facts were reset!'
    setLogLevelTest()
    if req.run == True:
        clipsFunctions.Run('')
    return InitKDBResponse()
Пример #9
0
def callbackCommandRunCLIPS(data):
    print "callbackCommandRUNCLIPS "
    clipsFunctions.Run('') # aqui se manda el numero de pasos que ejecutara CLIPS con [''] se ejecutan todos los pasos sin detenerse
    clipsFunctions.PrintOutput()
Пример #10
0
 def runCLIPS(self, *args):
     clipsFunctions.Run(self.getRunTimes())
     clipsFunctions.PrintOutput()
Пример #11
0
def ResponseReceived(r):
    clipsFunctions.Assert('(BB_received "{0}" {1} {2} "{3}")'.format(
        r.name, r._id, r.successful, r.params))
    clipsFunctions.PrintOutput()
    clipsFunctions.Run(gui.getRunTimes())
    clipsFunctions.PrintOutput()