summaryrefslogtreecommitdiff
path: root/test/navigation/script/test-guidance.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/navigation/script/test-guidance.py')
-rwxr-xr-xtest/navigation/script/test-guidance.py106
1 files changed, 43 insertions, 63 deletions
diff --git a/test/navigation/script/test-guidance.py b/test/navigation/script/test-guidance.py
index be44295..74be6ac 100755
--- a/test/navigation/script/test-guidance.py
+++ b/test/navigation/script/test-guidance.py
@@ -6,6 +6,7 @@
* SPDX-License-Identifier: MPL-2.0
*
* \copyright Copyright (C) 2016, XS Embedded GmbH, PCA Peugeot Citroen
+* \copyright Copyright (C) 2017, PSA GROUP
*
* \file test-guidance.py
*
@@ -29,39 +30,19 @@
import dbus
import gobject
import dbus.mainloop.glib
-from collections import namedtuple,defaultdict
-from _dbus_bindings import Int32
-from PIL.GimpGradientFile import SEGMENTS
-from xml.dom.minidom import parse
import xml.dom.minidom
import argparse
import sys
import errno
import time
+import genivi
from dltTrigger import *
#import pdb
#pdb.set_trace()
-from pip import locations
-
#name of the test
test_name = "guidance"
-#constants as defined in the Navigation API
-GENIVI_NAVIGATIONCORE_LATITUDE = 0x00a0
-GENIVI_NAVIGATIONCORE_LONGITUDE = 0x00a1
-GENIVI_NAVIGATIONCORE_TOTAL_TIME = 0x018e
-GENIVI_NAVIGATIONCORE_TOTAL_DISTANCE = 0x018f
-GENIVI_NAVIGATIONCORE_ROAD_NAME = 0x0147
-GENIVI_NAVIGATIONCORE_START_LATITUDE = 0x0141
-GENIVI_NAVIGATIONCORE_END_LATITUDE = 0x0142
-GENIVI_NAVIGATIONCORE_START_LONGITUDE = 0x0143
-GENIVI_NAVIGATIONCORE_END_LONGITUDE = 0x0144
-GENIVI_NAVIGATIONCORE_DISTANCE = 0x0148
-GENIVI_NAVIGATIONCORE_TIME = 0x0149
-GENIVI_NAVIGATIONCORE_SPEED = 0x00a4
-GENIVI_NAVIGATIONCORE_ACTIVE = 0x0060
-
#constants used into the script
TIME_OUT = 10000
HORIZONTAL_SIZE = 800
@@ -72,36 +53,36 @@ ZOOM_GUIDANCE = 2
#add signal receivers
def routing_routeCalculationProgressUpdate_handler(routeHandle, status, percentage):
- print 'Route Calculation: ' + str(int(percentage)) + ' %'
+ print ('Route Calculation: ' + str(int(percentage)) + ' %')
def routing_routeCalculationSuccessful_handler(routeHandle,unfullfilledPreferences):
global g_guidance_active
- print 'Route Calculation Successfull: ' + str(routeHandle)
+ print ('Route Calculation Successfull: ' + str(routeHandle))
#get route overview
- overview = g_routing_interface.GetRouteOverview(dbus.UInt32(g_route_handle),dbus.Array([dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_DISTANCE),dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_TIME)]))
+ overview = g_routing_interface.GetRouteOverview(dbus.UInt32(g_route_handle),dbus.Array([dbus.Int32(genivi.TOTAL_DISTANCE),dbus.Int32(genivi.TOTAL_TIME)]))
#retrieve distance
- totalDistance = dbus.Struct(overview[dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_DISTANCE)])
- print 'Total Distance: ' + str(totalDistance[1]/1000) + ' km'
- totalTime = dbus.Struct(overview[dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_TIME)])
+ totalDistance = dbus.Struct(overview[dbus.Int32(genivi.TOTAL_DISTANCE)])
+ print ('Total Distance: ' + str(totalDistance[1]/1000) + ' km')
+ totalTime = dbus.Struct(overview[dbus.Int32(genivi.TOTAL_TIME)])
m, s = divmod(totalTime[1], 60)
h, m = divmod(m, 60)
- print "Total Time: %d:%02d:%02d" % (h, m, s)
+ print ("Total Time: %d:%02d:%02d" % (h, m, s))
#get route segments GetRouteSegments(const uint32_t& routeHandle, const int16_t& detailLevel, const std::vector< DBusCommonAPIEnumeration >& valuesToReturn, const uint32_t& numberOfSegments, const uint32_t& offset, uint32_t& totalNumberOfSegments, std::vector< std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > >& routeSegments)
- valuesToReturn = [dbus.Int32(GENIVI_NAVIGATIONCORE_ROAD_NAME),
- dbus.Int32(GENIVI_NAVIGATIONCORE_START_LATITUDE),
- dbus.Int32(GENIVI_NAVIGATIONCORE_END_LATITUDE),
- dbus.Int32(GENIVI_NAVIGATIONCORE_START_LONGITUDE),
- dbus.Int32(GENIVI_NAVIGATIONCORE_END_LONGITUDE),
- dbus.Int32(GENIVI_NAVIGATIONCORE_DISTANCE),
- dbus.Int32(GENIVI_NAVIGATIONCORE_TIME),
- dbus.Int32(GENIVI_NAVIGATIONCORE_SPEED)]
+ valuesToReturn = [dbus.Int32(genivi.ROAD_NAME),
+ dbus.Int32(genivi.START_LATITUDE),
+ dbus.Int32(genivi.END_LATITUDE),
+ dbus.Int32(genivi.START_LONGITUDE),
+ dbus.Int32(genivi.END_LONGITUDE),
+ dbus.Int32(genivi.DISTANCE),
+ dbus.Int32(genivi.TIME),
+ dbus.Int32(genivi.SPEED)]
numberOfSegments = NUMBER_OF_SEGMENTS
detailLevel = 0
offset = 0
ret = g_routing_interface.GetRouteSegments(dbus.UInt32(g_route_handle),dbus.Int16(detailLevel),dbus.Array(valuesToReturn),dbus.UInt32(numberOfSegments),dbus.UInt32(offset))
- print "Total number of segments: " + str(ret[0])
+ print ("Total number of segments: " + str(ret[0]) )
#len(ret[1]) is size
- #ret[1][0][GENIVI_NAVIGATIONCORE_START_LATITUDE] is the start latitude
+ #ret[1][0][genivi.START_LATITUDE] is the start latitude
g_guidance_active = True
# pdb.set_trace()
display_route(routeHandle)
@@ -110,9 +91,9 @@ def routing_routeCalculationSuccessful_handler(routeHandle,unfullfilledPreferenc
def session_sessionDeleted_handler(sessionHandle):
print('Session handle deleted: '+str(sessionHandle))
if sessionHandle == g_navigationcore_session_handle:
- print 'Test PASSED'
+ print ('Test PASSED')
else:
- print 'Test FAILED'
+ print ('Test FAILED')
exit()
def routing_routeDeleted_handler(routeHandle):
@@ -121,7 +102,7 @@ def routing_routeDeleted_handler(routeHandle):
def guidance_guidanceStatusChanged_handler(guidanceStatus,routeHandle):
global g_guidance_active
print('Guidance status changed: '+str(guidanceStatus))
- if guidanceStatus != GENIVI_NAVIGATIONCORE_ACTIVE and g_guidance_active == True:
+ if guidanceStatus != genivi.ACTIVE and g_guidance_active == True:
g_guidance_active = False
route = g_current_route + 1
if route < routes.length:
@@ -132,26 +113,25 @@ def guidance_guidanceStatusChanged_handler(guidanceStatus,routeHandle):
g_navigationcore_session_interface.DeleteSession(dbus.UInt32(g_navigationcore_session_handle))
def guidance_positionOnRouteChanged_handler(offsetOnRoute):
- print "Offset on route: " +str(offsetOnRoute)
+ print ("Offset on route: " +str(offsetOnRoute))
def guidance_maneuverChanged_handler(maneuver):
- print "Maneuver: " +str(maneuver)
+ print ("Maneuver: " +str(maneuver))
ret = g_guidance_interface.GetDestinationInformation()
- print "Travel time: " +str(ret[1])
+ print ("Travel time: " +str(ret[1]))
ret = g_guidance_interface.GetManeuversList(dbus.UInt16(10),dbus.UInt32(0))
- print "Number of maneuvers: " +str(ret[1])
- print "Next road to turn: " +str(ret[2][0][4])
+ print ("Number of maneuvers: " +str(ret[1]))
+ print ("Next road to turn: " +str(ret[2][0][4]))
g_mapmatchedposition_interface.SetSimulationMode(dbus.UInt32(g_navigationcore_session_handle),dbus.Boolean(False))
g_guidance_interface.StopGuidance(dbus.UInt32(g_navigationcore_session_handle))
def mapmatchedposition_simulationStatusChanged_handler(simulationStatus):
- print "Simulation status: " +str(simulationStatus)
+ print ("Simulation status: " +str(simulationStatus))
-#timeout
def timeout():
- print 'Timeout Expired'
- print '\nTest FAILED'
+ print ('Timeout Expired')
+ print ('\nTest FAILED')
exit()
def exit():
@@ -187,25 +167,25 @@ def launch_route_calculation(route):
global g_routing_interface
global g_navigationcore_session_handle
g_current_route = route
- print 'Route name: '+routes[g_current_route].getElementsByTagName("name")[0].childNodes[0].data
+ print ('Route name: '+routes[g_current_route].getElementsByTagName("name")[0].childNodes[0].data)
#get route handle
ret = g_routing_interface.CreateRoute(dbus.UInt32(g_navigationcore_session_handle))
g_route_handle=ret[1]
routes[g_current_route].getElementsByTagName("handle")[0].childNodes[0].data = g_route_handle
- print 'Route handle: ' + str(g_route_handle)
+ print ('Route handle: ' + str(g_route_handle))
start = routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data
dest = routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data
- print 'Calculating route from \
-'+start+'(' + str(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][0]) + ',' + str(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][1]) + ') to \
-'+dest+'(' + str(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][0]) + ',' + str(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][1]) + ')'
+ print ('Calculating route from \
+ '+start+'(' + str(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][0]) + ',' + str(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][1]) + ') to \
+ '+dest+'(' + str(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][0]) + ',' + str(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][1]) + ')' )
#set waypoints
waypointDoubleCapiType = 0x03
g_routing_interface.SetWaypoints(dbus.UInt32(g_navigationcore_session_handle), \
dbus.UInt32(g_route_handle), \
dbus.Boolean(0), \
dbus.Array([ \
- dbus.Dictionary({dbus.Int32(GENIVI_NAVIGATIONCORE_LATITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][0])]),dbus.Int32(GENIVI_NAVIGATIONCORE_LONGITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][1])])}), \
- dbus.Dictionary({dbus.Int32(GENIVI_NAVIGATIONCORE_LATITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][0])]),dbus.Int32(GENIVI_NAVIGATIONCORE_LONGITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][1])])}) \
+ dbus.Dictionary({dbus.Int32(genivi.LATITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][0])]),dbus.Int32(genivi.LONGITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("start")[0].childNodes[0].data][1])])}), \
+ dbus.Dictionary({dbus.Int32(genivi.LATITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][0])]),dbus.Int32(genivi.LONGITUDE):dbus.Struct([dbus.Byte(waypointDoubleCapiType),dbus.Double(locations[routes[g_current_route].getElementsByTagName("destination")[0].childNodes[0].data][1])])}) \
]) \
)
@@ -221,13 +201,13 @@ def createMapView():
#get mapviewer session handle
ret = g_mapviewer_session_interface.CreateSession(dbus.String('test mapviewer'))
g_mapviewer_sessionhandle=ret[1]
- print 'Mapviewer session handle: ' + str(g_mapviewer_sessionhandle)
+ print ('Mapviewer session handle: ' + str(g_mapviewer_sessionhandle))
g_mapviewer_sessionstatus = g_mapviewer_session_interface.GetSessionStatus(dbus.UInt32(g_mapviewer_sessionhandle));
- print 'Mapviewer session status: ' + str(g_mapviewer_sessionstatus)
+ print ('Mapviewer session status: ' + str(g_mapviewer_sessionstatus))
g_mapviewer_sessionlist = g_mapviewer_session_interface.GetAllSessions();
- print 'Mapviewer active sessions = ' + str(len(g_mapviewer_sessionlist))
+ print ('Mapviewer active sessions = ' + str(len(g_mapviewer_sessionlist)))
#get mapviewer handle
ret = g_mapviewercontrol_interface.CreateMapViewInstance( \
@@ -236,11 +216,11 @@ def createMapView():
dbus.Int32(MAIN_MAP))
g_mapviewer_maphandle=ret[1]
- print 'MapView handle: ' + str(g_mapviewer_maphandle)
+ print ('MapView handle: ' + str(g_mapviewer_maphandle))
time.sleep(2)
- print 'Stop following the car position'
+ print ('Stop following the car position')
g_mapviewercontrol_interface.SetFollowCarMode( \
dbus.UInt32(g_mapviewer_sessionhandle), \
dbus.UInt32(g_mapviewer_maphandle), \
@@ -345,7 +325,7 @@ g_mapmatchedposition_interface = dbus.Interface(g_mapmatchedposition_obj, dbus_i
#get navigationcore session handle
ret = g_navigationcore_session_handle = g_navigationcore_session_interface.CreateSession(dbus.String("test guidance"))
g_navigationcore_session_handle=ret[1]
-print 'Navigation core session handle: ' + str(g_navigationcore_session_handle)
+print ('Navigation core session handle: ' + str(g_navigationcore_session_handle))
createMapView()