Skip to content

Commit

Permalink
Change button behavior on task page
Browse files Browse the repository at this point in the history
Add new data over api
Update readme
  • Loading branch information
EinEinfach committed Apr 17, 2024
1 parent 9650bf0 commit 4758ad2
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CaSSAndRA/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

#Version:0.103.4 Fix issue with send message button
#Version:0.104.0 Change button behavior on task page, add new api values
# package imports
import os
import sys
Expand Down
5 changes: 4 additions & 1 deletion CaSSAndRA/src/backend/comm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def create_api_payload(self) -> None:

def create_robot_payload(self) -> None:
self.robotstate['status'] = robot.status
self.robotstate['dock reason'] = robot.dock_reason
self.robotstate['battery'] = robot.soc
self.robotstate['position'] = dict(x=robot.position_x, y=robot.position_y)
self.robotstate['target'] = dict(x=robot.target_x, y=robot.target_y)
Expand Down Expand Up @@ -75,8 +76,10 @@ def create_mow_parameters_payload(self) -> None:
self.mowparametersstate_json = json.dumps(self.mowparametersstate)

def create_map_payload(self) -> None:
self.mapstate['mowprogress idx'] = robot.mowprogress
self.mapstate['mowprogress distance'] = robot.mowprogress_distance
self.mapstate_json = json.dumps(self.mapstate)

def update_payload(self) -> None:
self.create_api_payload()
self.create_robot_payload()
Expand Down
2 changes: 1 addition & 1 deletion CaSSAndRA/src/backend/data/appdata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging
logger = logging.getLogger(__name__)

version = '0.103.4'
version = '0.104.0'
1 change: 0 additions & 1 deletion CaSSAndRA/src/components/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
BUTTONPLANMOWALL = 'button-plan-mow-all'
BUTTONSAVECURRENTTASK = 'button-save-current-task'
BUTTONPLANMOWSETTINGS = 'button-plan-mow-settings'
BUTTONCONFIRMSELECTION = 'button-confirm-selection'
BUTTONPLANCANCEL = 'button-plan-cancel'
BUTTONREMOVETASK = 'button-remove-task'
BUTTONSTARTSELECTEDTASKSORDER = 'button-start-selected-tasks-order'
Expand Down
4 changes: 2 additions & 2 deletions CaSSAndRA/src/components/state/buttongroupcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def perfom_cmd(n_clicks_bgo: int,
active_bma: bool,
active_bss: bool,
active_bgt: bool,
) -> list():
) -> list:

context = ctx.triggered_id
rover_state = robot.status
Expand Down Expand Up @@ -167,7 +167,7 @@ def update_button_disabled(n_intervals: int,
bss_disabled: bool,
bgt_disabled: bool,
bc_disabled: bool,
) -> list():
) -> list:
context = ctx.triggered_id

if current_map.perimeter.empty:
Expand Down
3 changes: 1 addition & 2 deletions CaSSAndRA/src/components/tasks/buttongroupcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from src.backend.data.roverdata import robot
from src.backend.data.mapdata import current_map

buttonplanmowall = dbc.Button(id=ids.BUTTONPLANMOWALL, size='lg', class_name='me-1 mt-1 bi bi-map-fill', disabled=False, title='plan mow all')
buttonplanmowall = dbc.Button(id=ids.BUTTONPLANMOWALL, size='lg', class_name='me-1 mt-1 bi bi-map-fill', disabled=False, title='calc task for selected area')
buttonmowsettings = dbc.Button(id=ids.BUTTONPLANMOWSETTINGS, size='lg', class_name='me-1 mt-1 bi bi-gear-fill', disabled=False, title='temporarly mow settings')
buttonconfirmselection = dbc.Button(id=ids.BUTTONCONFIRMSELECTION, size='lg', class_name='me-1 mt-1 bi bi-check-square-fill', disabled=False, title='confirm selection')
buttoncancel = dbc.Button(id=ids.BUTTONPLANCANCEL, size='lg', class_name='me-1 mt-1 bi bi-x-square-fill', disabled=False, title='cancel')

48 changes: 18 additions & 30 deletions CaSSAndRA/src/components/tasks/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@

@callback(Output(ids.TASKMAP, 'figure'),
[Input(ids.BUTTONPLANMOWALL, 'n_clicks'),
Input(ids.BUTTONCONFIRMSELECTION, 'n_clicks'),
Input(ids.BUTTONPLANCANCEL, 'n_clicks'),
Input(ids.MODALSAVECURRENTTASK, 'is_open'),
Input(ids.MODALREMOVETASK, 'is_open'),
Input(ids.DROPDOWNTASKSORDER, 'value'),
Input(ids.BUTTONREMOVETASK, 'n_clicks'),
State(ids.TASKMAP, 'selectedData'),])
State(ids.TASKMAP, 'selectedData'),
State(ids.TASKMAP, 'figure')
])
def update(bpma_nclicks: int,
bcs_nclicks: int,
bpc_nclicks: int,
save_is_open: bool,
remove_is_open: bool,
tasks_order: list,
brt_nclicks: int,
selecteddata: dict,
fig_state: dict,
) -> list:

traces = []
Expand All @@ -66,10 +67,22 @@ def update(bpma_nclicks: int,
context = ctx.triggered_id
context_triggered = ctx.triggered

#Create a task for whole map
#Create a task
if context == ids.BUTTONPLANMOWALL:# and buttonmowall:
current_task.preview = pd.DataFrame()
current_task.selected_perimeter = current_map.perimeter_polygon
if 'selections' in fig_state['layout'] and fig_state['layout']['selections'] != []:
current_task.selected_perimeter = map.selection(current_map.perimeter_polygon, selecteddata)
if 'lassoPoints' in selecteddata:
current_task.selection_type = 'lassoPoints'
current_task.selection = selecteddata['lassoPoints']
else:
current_task.selection_type = 'range'
current_task.selection = selecteddata['range']
else:
current_task.selected_perimeter = current_map.perimeter_polygon
current_task.selection_type = 'perimeter'
current_task.selection = {'X': [0], 'Y': [0]}
#current_task.selected_perimeter = current_map.perimeter_polygon
current_map.task_progress = 0
current_map.total_tasks = 1
current_map.calculating = True
Expand All @@ -78,31 +91,6 @@ def update(bpma_nclicks: int,
current_task.calc_route_preview(route)
current_map.calculating = False
current_task.parameters = pathplannercfgtask
current_task.selection_type = 'perimeter'
current_task.selection = {'X': [0], 'Y': [0]}

#Check interactions with graph and create a task for selected zone
if selecteddata == {'points':[]}: #Workaround for selected data, beacause after select selected data changing to {'poonts':[]} and triggering context_id
selecteddata = None
if context == ids.BUTTONCONFIRMSELECTION and selecteddata: #context_triggered[0]['prop_id'] == ids.TASKMAP+'.selectedData' and selecteddata:
current_task.preview = pd.DataFrame()
perimeter_preview = current_map.perimeter_polygon
current_task.selected_perimeter = map.selection(perimeter_preview, selecteddata)
if not current_task.selected_perimeter.is_empty:
current_map.task_progress = 0
current_map.total_tasks = 1
current_map.calculating = True
route = path.calc(current_task.selected_perimeter, pathplannercfgtask, rover_position)
if route:
current_task.calc_route_preview(route)
current_map.calculating = False
current_task.parameters = pathplannercfgtask
if 'lassoPoints' in selecteddata:
current_task.selection_type = 'lassoPoints'
current_task.selection = selecteddata['lassoPoints']
else:
current_task.selection_type = 'range'
current_task.selection = selecteddata['range']

#Remove preview if cancel button clicked
if context == ids.BUTTONPLANCANCEL and not current_task.preview.empty:
Expand Down
1 change: 0 additions & 1 deletion CaSSAndRA/src/pages/taskplanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def update_layout() -> html.Div:
[
buttongroupcontrol.buttonplanmowall,
buttongroupcontrol.buttonmowsettings,
buttongroupcontrol.buttonconfirmselection,
buttongroupcontrol.buttoncancel,
],
className='text-center p-1',
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,12 @@ Overview page can be called by clicking "CaSSAndRA" in the navbar. This is your
Click on "go home" button and confirm the action by clicking play button.

### Mow whole area
Click on "mow all" button. CaSSAndRA calculates the mowing paths according to your settings. Depending on the performance of your computer or the size of your map, the calculation may take some time. The calculated route appear green on the map. Click on play button to start mowing
Click on "mow all or selected area" button. CaSSAndRA calculates the mowing paths according to your settings. Depending on the performance of your computer or the size of your map, the calculation may take some time. The calculated route appear green on the map. Click on play button to start mowing

![using_app_mow](https://raw.githubusercontent.com/EinEinfach/CaSSAndRA/master/docs/using_app_mow.jpeg)

### Mow selected area
Click on "select zone to mow" button. Select "Lasso Select" or "Box Select" in the tool bar on top of the map. Then mark the desired area on the map. Depending on the performance of your computer or the size of your map, the calculation may take some time. The calculated routes appear green on the map. You can repeat the calculation for selected area. Change your mow settings and click "select zone to mow" again. The Lasso-Select selection and Box-Select selection can be removed by double click event if corespondent tool selected. Click on play button to start mowing
Select "Lasso Select" or "Box Select" in the tool bar on top of the map. Then mark the desired area on the map. And select "mow all or selected area" button. Depending on the performance of your computer or the size of your map, the calculation may take some time. The calculated routes appear green on the map. You can repeat the calculation for selected area. Change your mow settings and click "select zone to mow" again. The Lasso-Select selection and Box-Select selection can be removed by double click event if corespondent tool selected. Click on play button to start mowing

![using_app_mow_zone](https://raw.githubusercontent.com/EinEinfach/CaSSAndRA/master/docs/using_app_mow_zone.jpeg)

Expand Down
Binary file modified docs/using_app_mow.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/using_app_mow_zone.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/using_app_overview.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4758ad2

Please sign in to comment.