diff --git a/asset/map/map1.blend b/asset/map/map1.blend index eb898e0..16a36a4 100644 Binary files a/asset/map/map1.blend and b/asset/map/map1.blend differ diff --git a/ropy-34.blend b/ropy-34.blend index 08eaef9..8ff7c35 100644 Binary files a/ropy-34.blend and b/ropy-34.blend differ diff --git a/rp.py b/rp.py index 43a8e6f..719dc7c 100644 --- a/rp.py +++ b/rp.py @@ -10,9 +10,7 @@ import threading # Multithreading import subprocess # Multiprocessus import xml.etree.ElementTree as ET # Creating/parsing XML file import runpy # Exécution de script Python légère (sans import) -# from pylint import epylint as lint # Mesure de la qualité d'un code Python -# from pylint import run_pylint # Mesure de la qualité d'un code Python -# from pylint.lint import Run as pylint_run +import astroid # Inspection de script Python (Pylint) import rp_map1 as rp_map # Map definition import rp_doc # Documentation @@ -235,7 +233,6 @@ def python_validation(file): stout_lines = stout[0].split("\n") for stout_line in stout_lines: print ("Pylint :", stout_line) # Affichage console - return False # Absence d'erreur @@ -244,6 +241,30 @@ def python_validation(file): scene.objects['Cmd-text'].setVisible(False,False) return True +## +# Inspection du code Python : détection des appels +# +# Call(func=, +# args=[], +# keywords=[]) +## + +def python_inspect(file): + functions=[] + file_buff = open(file, 'r') + file_txt = file_buff.read() + file_lines= file_txt.split("\n") + for i in range (len(file_lines)): + try: + node = astroid.extract_node(file_lines[i]) + # print (node) + if str(node).find ("Call(func= -1: + functions.append(str(node)[16:str(node).find ("l.1")-1]) + except: + pass + file_buff.close() + return functions + ## # Exécuter le script ## @@ -286,6 +307,7 @@ def terrain_run (): scene.objects['Rover']['stop'] = False scene.objects['Points-Twins-text']['Text'] = "Connection fermée." if python_validation(scene.objects['Commands']['script']): + scene.objects['Commands']['functions'] = python_inspect(scene.objects['Commands']['script']) runpy.run_path(scene.objects['Commands']['script'], run_name='start') # Execution du script utilisateur # Arrêt de la pause diff --git a/rp_about.py b/rp_about.py index 90aabaa..c485cf7 100644 --- a/rp_about.py +++ b/rp_about.py @@ -425,6 +425,7 @@ def quality_apply(quality, start_flag=False): eevee.use_volumetric_shadows = False eevee.shadow_cascade_size='64' eevee.shadow_cube_size='64' + bpy.data.particles["Feuillage"].count = 100 # scene.objects['terrain-scatter.001'].setVisible(False,True) # scene.objects['terrain-scatter.002'].setVisible(False,True) @@ -441,6 +442,7 @@ def quality_apply(quality, start_flag=False): eevee.use_volumetric_shadows = False eevee.shadow_cascade_size='1024' eevee.shadow_cube_size='512' + bpy.data.particles["Feuillage"].count = 100 # scene.objects['terrain-scatter.001'].setVisible(False,True) # scene.objects['terrain-scatter.002'].setVisible(False,True) @@ -457,6 +459,7 @@ def quality_apply(quality, start_flag=False): eevee.use_volumetric_shadows = False eevee.shadow_cascade_size='1024' eevee.shadow_cube_size='512' + bpy.data.particles["Feuillage"].count = 100 # scene.objects['terrain-scatter.001'].setVisible(True,True) # scene.objects['terrain-scatter.002'].setVisible(True,True) @@ -473,6 +476,7 @@ def quality_apply(quality, start_flag=False): eevee.use_volumetric_shadows = False eevee.shadow_cascade_size='1024' eevee.shadow_cube_size='512' + bpy.data.particles["Feuillage"].count = 500 # scene.objects['terrain-scatter.001'].setVisible(True,True) # scene.objects['terrain-scatter.002'].setVisible(True,True) @@ -489,5 +493,6 @@ def quality_apply(quality, start_flag=False): eevee.use_volumetric_shadows = True eevee.shadow_cascade_size='4096' eevee.shadow_cube_size='4096' + bpy.data.particles["Feuillage"].count = 1000 # scene.objects['terrain-scatter.001'].setVisible(True,True) # scene.objects['terrain-scatter.002'].setVisible(True,True) diff --git a/rp_cmd.py b/rp_cmd.py index 1d2486f..5709770 100644 --- a/rp_cmd.py +++ b/rp_cmd.py @@ -1,5 +1,4 @@ import time -import inspect from rp_lib import * # Bibliothèque Ropy ############################################################################### @@ -26,19 +25,34 @@ from rp_lib import * # Bibliothèque Ropy # Commandes ############################################################################### +def mrp_avancer(): + pass + def commandes(): - # print ("inspect :", inspect.isfunction(mrp_avancer())) + print ('Go go go ...') + + # mrp_avancer() + # mrp_avancer() + # mrp_avancer() - print ('okok') rp_gauche() - rp_avancer() - rp_avancer() - rp_droite() - for i in range (3): + while rp_detect()==False: rp_avancer() - rp_marquer() - + rp_droite() + while rp_detect()==False: + rp_avancer() + + # rp_avancer() + # rp_droite() + # for i in range (4): + # rp_avancer() + # rp_marquer() + # rp_droite() + # for i in range (3): + # rp_avancer() + # rp_marquer() + rp_fin() # A garder ############################################################################### diff --git a/rp_config.xml b/rp_config.xml index aa78a1b..7021146 100644 --- a/rp_config.xml +++ b/rp_config.xml @@ -1,15 +1,15 @@ - 2.0 + 4.0 False - 4.116782188415527 - -39.253841400146484 - 29.45159339904785 + -3.7522060871124268 + -18.188343048095703 + 15.865280151367188 - 1599 - 900 + 1639 + 922 4 @@ -18,9 +18,9 @@ 6 - False - False - False + True + True + True True \ No newline at end of file diff --git a/rp_lib.py b/rp_lib.py index 48d7767..ced04a9 100644 --- a/rp_lib.py +++ b/rp_lib.py @@ -281,9 +281,14 @@ def rp_avancer (twins=True): scene.objects['Rv-Wheel-left-front'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed) scene.objects['Rv-Wheel-left-mid'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed) scene.objects['Rv-Wheel-left-rear'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed) - while scene.objects['Rv-Wheel-right-front'].isPlayingAction(): # Forçage du redraw - # scene.objects['Camera'].applyMovement((0, 0, 0), True) - scene.objects['Sun'].applyMovement((0, 0, 0), True) + + # Forçage du redraw + while scene.objects['Rv-Wheel-right-front'].isPlayingAction(): + rp_sleep(0.1) + # rp_tempo (0.1) + # # pass + # # scene.objects['Camera'].applyMovement((0, 0, 0), True) + # scene.objects['Sun'].applyMovement((0, 0, 0), True) rp_tempo (0.1) # Contrôle objectif @@ -829,7 +834,7 @@ def rover_colision_montain (back): scene.objects['Rv-Wheel-left-rear'].playAction('Wheel-Reculer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed) # Forçage du redraw - while scene.objects['Rv-Wheel-right-front'].isPlayingAction(): # Forçage du redraw + while scene.objects['Rv-Wheel-right-front'].isPlayingAction(): scene.objects['Sun'].applyMovement((0, 0, 0), True) rp_tempo (0.1) return True diff --git a/rp_map1.py b/rp_map1.py index c6b9f3e..482e4bf 100644 --- a/rp_map1.py +++ b/rp_map1.py @@ -1,9 +1,9 @@ import bge # Bibliothèque Blender Game Engine (UPBGE) import bpy # Blender import random -import inspect from rp_lib import * # Bibliothèque Ropy import os +import runpy # Exécution de script Python légère (sans import) ############################################################################### # rp_map1.py @@ -153,18 +153,15 @@ def map_init(): filename=object_name) scene.objects['Terrain']['size'] = [-15,-11,15,10] # Map size + scene.objects['Terrain-plane'].setVisible(False,True) # Plan de conception (Blender) scene.objects['Terrain']['map_tile_station']= [[-9,2],[-9,3]] - # Détection des emplacements des colisions de montagne - # scene.objects['Terrain']['map_tile_montain']= [] - # for obj_i in scene.objects: - # if "terrain_sideCliff" in obj_i.name or "terrain_sideCorner" in obj_i.name or "terrain_sideCornerInner" in obj_i.name: - # scene.objects['Terrain']['map_tile_montain'].append([round(obj_i.worldPosition.x), round(obj_i.worldPosition.y)]) + # Montagne scene.objects['Terrain']['map_tile_montain'] = [[-9, -1], [1, -9], [-14, -8], [-12, -10], [-11, -10], [-10, -10], [-9, -10], [-11, 1], [-14, 3], [-14, 4], [-14, -7], [-12, 1], [2, -7], [-12, 10], [-11,10], [-10, 10], [-9, 10], [-8, 10], [-4, 7], [-2, 6], [4, 10], [5, 10], [1, 8], [2, -6], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [14,7], [-14, -1], [13, 8], [-14, 0], [-14, -2], [8, -1], [-15, -7], [-15, -8], [-15, -9], [-15, -6], [-8, -10], [-7, -10], [10, -1], [15, 5], [11, -1], - [14, 9], [15, 10], [12, -1], [4, -9], [5, -9], [6, -9], [3, -10], [7, -10], [-14, -11], [-6, -11], [3, -11], [7, -11], [0, -11], [0, 1], [-1, 0], [13, 7], - [13, 6], [13, 5], [1, 1], [0, -1], [14, 10], [13, 9], [14, 8], [14, 6], [12, 10], [15, 9], [15, 3], [9, -1], [7, -1], [15, 8], [15, 7], [6, -1], [2, -5], + [14, 9], [15, 10], [12, -1], [4, -9], [5, -9], [6, -9], [3, -10], [7, -10], [-14, -11], [-6, -11], [3, -11], [7, -11], [0, -11], [13, 7], + [13, 6], [13, 5], [14, 10], [13, 9], [14, 8], [14, 6], [12, 10], [15, 9], [15, 3], [9, -1], [7, -1], [15, 8], [15, 7], [6, -1], [2, -5], [2, -4], [2, -3], [2, -2], [5, -1], [4, -1], [3, -1], [3, 10], [-1, 6], [0, -10], [-13, -9], [1, -8], [-12, -3], [-9, -2], [-12, -5], [-13, -6], [-13, 5], [-13, 6], [-14, 8], [-13, 2], [-10, -3], [-13, 9], [-7, 9], [-14, 7], [-6, 8], [-5, 7], [-3, 6], [0, 6], [1, 7], [2, 9], [-10, 1], [-9, 0], [-15, 2], [-14,1], [-14, -10], [-14, -5], [-13, -4], [-13, -3], [2, -1], [13, 4], [14, 3], [15, 6], [13, -1], [14, -2], [-6, -10], [15, -3], [14, 5], [3, -9], @@ -174,6 +171,18 @@ def map_init(): [2,10], [2, 10], [13, 10], [13, 10], [13, -2], [13, -2], [-15, -10], [-15, -10], [1, -10], [1, -10], [-15, 1], [-15, 1], [-15, -5], [-15, -5], [-14, -4], [-14, -4], [-14, -3], [-14, -3], [-15, 8], [-15, 8], [14, 4], [14, 4], [-15, 7], [-15, 7], [2, -8], [2, -8]] + # Visualisation des cases montagne + # for i in range (len (scene.objects['Terrain']['map_tile_montain'])): + # beacon_montain= scene.addObject("Beacon", scene.objects['Terrain']) + # beacon_montain.worldPosition=[scene.objects['Terrain']['map_tile_montain'][i][0],scene.objects['Terrain']['map_tile_montain'][i][1],0.2] + # beacon_montain.setVisible(True,True) + + # Détection des emplacements des colisions de montagne + # scene.objects['Terrain']['map_tile_montain']= [] + # for obj_i in scene.objects: + # if "terrain_sideCliff" in obj_i.name or "terrain_sideCorner" in obj_i.name or "terrain_sideCornerInner" in obj_i.name: + # scene.objects['Terrain']['map_tile_montain'].append([round(obj_i.worldPosition.x), round(obj_i.worldPosition.y)]) + # Couleurs rp_couleur_init() @@ -351,10 +360,14 @@ def objectif_control(x,y): # Mission 2 (fonction) if scene.objects['Points']['mission']==2: if [x,y] in scene.objects['Terrain']['map_aim']: # Aim + # print ("Objectif : ok") if len(scene.objects['Terrain']['map_tile_beacon'])>=6: # 6 balises posées mini + # print ("6 balises posées : ok") if scene.objects['Points']['nbligne'] <=40: # 40 lignes de code maxi - txt=["def mrp_avancer():", "def mrp_avancer() :", "def mrp_avancer ():", "def mrp_avancer () :"] # Présence de "def mrp_avancer():" - if rp_cmd_txtcount(txt, 1): + # print ("40 lignes de code maxi : ok") + # print (scene.objects['Commands']['functions']) + if scene.objects['Commands']['functions'].count("mrp_avancer")>=3: # Au moins 3 appels de "mrp_avancer()" + # print ("Fonction mrp_avancer : ok") return True # Mission 3 (structure alternative) @@ -370,8 +383,7 @@ def objectif_control(x,y): if rp_cmd_txtcount(txt, 2): return True else: - txt=["def mrp_avancer_nbpas"] # Présence de "def mrp_avancer_nbpas" - if rp_cmd_txtcount(txt, 1): + if scene.objects['Commands']['functions'].count("mrp_avancer_nbpas")>=2: # Au moins 2 appels de "mrp_avancer_nbpas()" txt=["for" ] # Présence de "for i in range" 1x if rp_cmd_txtcount(txt, 1): txt=["in range" ] @@ -386,8 +398,7 @@ def objectif_control(x,y): if rp_cmd_txtcount(txt, 2): return True else: - txt=["def mrp_avancer_mur():", "def mrp_avancer_mur() :", "def mrp_avancer_mur ():", "def mrp_avancer_mur () :"] # Présence de "def mrp_avancer_mur():" - if rp_cmd_txtcount(txt, 1): + if scene.objects['Commands']['functions'].count("mrp_avancer_mur")>=2: # Au moins 2 appels de "mrp_avancer_mur()" txt=["while" ] # Présence de "while" 1x if rp_cmd_txtcount(txt, 1): return True @@ -396,13 +407,12 @@ def objectif_control(x,y): if scene.objects['Points']['mission']==6: if [x,y] in scene.objects['Terrain']['map_aim']: # Cibles if [x,y] not in scene.objects['Terrain']['map_aim_hit']: # Cibles atteintes - rover_drill(x,y) - scene.objects['Terrain']['map_aim_hit'].append([x,y]) if len (scene.objects['Terrain']['map_aim_hit'])==10 : # Toutes les cibles atteintes return True + # Objectif pas atteint return False diff --git a/rp_pylint.py b/rp_pylint.py index 7da3d8b..11082c6 100644 --- a/rp_pylint.py +++ b/rp_pylint.py @@ -14,6 +14,8 @@ from pylint import run_pylint # print (sys.argv[0]) # print (sys.argv[1]) # run_pylint(argv=["--version"]) + +# Détection des erreurs run_pylint(argv=["--errors-only", sys.argv[1]]) # run_pylint(argv=["--disable=line-too-long", sys.argv[1]]) sys.exit(0)