openpilot
openpilot copied to clipboard
ui/map: roundabout icon fix
Should now show the correct roundabout/rotary entry/exit icon. This uses the existing rhd logic to mirror the icons. This is not a great solution if someone is driving a lhd car in rhd traffic and vise versa. In this case it would not display the icon.
Also its possible to have a 0 degree roundabout which requires another icon like this:
For now I have just used the existing 'direction_roundabout.png' icon renamed to 'direction_roundabout_right_0.png'.
resolves: https://github.com/commaai/openpilot/issues/25480
Also this needs to be tested better. I just tried a simulated lhd 90 and a rhd 270.
I've created a new icon for 0 degrees which matches the current style
Can you open a PR for the cereal addition too?
Can you open a PR for the cereal addition too?
done https://github.com/commaai/cereal/pull/526
I don't think it can get much better than what I have here with 5 lines of easy to read code
Gonna bump this since this is still a problem. I really don't see how my solution would interfere with the model since I am not affecting it at all. This is only adjusting how the manuevers are displayed which is all that needs to be done. Doing it in navd is the wrong way to do it for many reasons.
This PR has had no activity for 30 days. It will be automatically closed in 7 days if there is no activity.
So this PR is mostly blocked by a lack of a good way to test this. Can you come up with a good way to test this and other related changes?
@adeebshihadeh might be good to make a general UI state controller. Would also be useful for the UI screenshot compare CI tool.
The way I tested it before was replaying a route that had a roundabout which is inconvenient.
All i am really willing to do at this point is prove that changing the degrees modifier displays the correct icon as the mapbox API specifies here:
Making a proper test is kind of a big job and considering it's been broken since nav icons were added... whatever.
I made a little test script to set the modifier and took some screenshots with left and right hand drive.
Note that I used mapbox api responses copied from the API playground and used the parse_banner_instructions function just like navd.py does. I then overwrote the degrees value and sent the modified instruction to the UI.
LHD Screenshots
RHD Screenshots
RHD:
Test Script
I had to modify the UI code to actually get it to show the map all the time. Also had to remove some UI code for llk math. if you want to run it, make sure the first banner instruction is a roundabout or modify the script to search for roundabouts. I spent as little time as possible to make it work for my testing.from openpilot.common.api import Api
import cereal.messaging as messaging
import time
from openpilot.selfdrive.navd.tests.test_map_renderer import LOCATION1, LOCATION2, gen_llk
from openpilot.selfdrive.navd.helpers import parse_banner_instructions, coordinate_from_param
import json
from common.params import Params
import copy
resp = json.loads(LHD)
resp = json.loads(RHD)
instructions = []
for i, step_i in enumerate(resp['routes'][0]['legs'][0]['steps']):
if 'bannerInstructions' in step_i:
banners = parse_banner_instructions(step_i['bannerInstructions'], 100)
instructions.append(banners)
break # get one only and fake the rest
def simulate_instructions():
for i in range(0,36):
new = copy.copy(instructions[0])
new['maneuverDegrees'] = 10*i
instructions.append(new)
class NavigationIconTest():
def __init__(self) -> None:
self.params = Params()
pm = messaging.PubMaster(['pandaStates', 'deviceState', 'navInstruction', 'navRoute', 'modelV2', 'controlsState', 'liveLocationKalman', 'managerState'])
pandaStates = messaging.new_message('pandaStates',size=1)
pandaStates.pandaStates[0] = {"pandaType": "tres",
"ignitionLine": True}
manager = messaging.new_message('managerState', valid=True)
manager.managerState.processes = [{'name': "ui",
'pid': 1,
'running': True,
}]
llk = messaging.new_message('liveLocationKalman', valid=True)
llk.liveLocationKalman.positionGeodetic = {'value': [*LOCATION1, 0], 'std': [0., 0., 0.], 'valid': True}
llk.liveLocationKalman.calibratedOrientationNED = {'value': [0., 0., 0.], 'std': [0., 0., 0.], 'valid': True}
llk.liveLocationKalman.status = 'valid'
device_dat = messaging.new_message('deviceState', valid=True)
self.instruction_dat = messaging.new_message('navInstruction', valid=True)
route_dat = messaging.new_message('navRoute', valid=True)
cs = messaging.new_message('controlsState', valid=True)
cs.controlsState.enabled = True
model_dat = messaging.new_message('modelV2', valid=True)
model_dat.modelV2.navEnabled = True
device_dat.deviceState.started = True
simulate_instructions()
self.params.put_bool("IsRhdDetected", False)
for i in self.banner_gen():
pm.send('managerState', manager)
pm.send('pandaStates', pandaStates)
pm.send('deviceState', device_dat)
pm.send('navRoute', route_dat)
pm.send('navInstruction', self.instruction_dat)
pm.send('modelV2', model_dat)
pm.send('controlsState', cs)
pm.send("liveLocationKalman",llk)
time.sleep(.1)
def banner_gen(self):
for banner in instructions:
if banner is not None:
for k,v in banner.items():
setattr(self.instruction_dat.navInstruction, k, v)
yield
if __name__ == "__main__":
NavigationIconTest()
This PR has had no activity for 30 days. It will be automatically closed in 7 days if there is no activity.