From 38d30e9719a7c70bcfcfbb8c680ce68a22f2afa8 Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Wed, 18 Mar 2026 13:18:25 +0000 Subject: [PATCH 1/7] add state management for debug_ticket_size Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index 4d0541f..2381e58 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -802,6 +802,7 @@ struct App { search_memory: Vec, negotiation_history: Vec, name_map: HashMap, + debug_ticket_size: usize, debug_step_count: u64, debug_node_selected: Option, negotiation_node_selected: Option, @@ -1470,6 +1471,7 @@ impl Application for App { debug_node_selected: None, negotiation_node_selected: None, next_robot_name_index: 0, + debug_ticket_size: 10, }; if app.canvas.program.layers.2.agents.is_empty() { @@ -1779,6 +1781,14 @@ impl Application for App { self.canvas.cache.clear(); } } + Message::IncDebugTicketSize => { + self.debug_ticket_size += 1; + } + Message::DecDebugTicketSize => { + if self.debug_ticket_size > 1 { + self.debug_ticket_size -= 1; + } + } } Command::none() @@ -2119,6 +2129,8 @@ enum Message { SelectNegotiationNode(usize), StepProgress, Tick, + IncDebugTicketSize, + DecDebugTicketSize, } fn main() -> iced::Result { From 4b9cf826e4773350a52729fcae56d3fecc6777d8 Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Wed, 18 Mar 2026 13:29:12 +0000 Subject: [PATCH 2/7] added UI Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index 2381e58..984bc38 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -797,6 +797,8 @@ struct App { show_details: KeyToggler, search: Option<(f64, Search, QueueLengthLimit>)>, step_progress: button::State, + increase_debug_ticket_size: button::State, + decrease_debug_ticket_size: button::State, debug_planner_on: bool, debug_negotiation_on: bool, search_memory: Vec, @@ -1462,6 +1464,8 @@ impl Application for App { show_details: KeyToggler::for_key(keyboard::KeyCode::LAlt), search: None, step_progress: button::State::new(), + decrease_debug_ticket_size: button::State::new(), + increase_debug_ticket_size: button::State::new(), debug_planner_on: false, debug_negotiation_on: false, search_memory: Default::default(), @@ -1983,6 +1987,24 @@ impl Application for App { .on_press(Message::StepProgress), ) .push(iced::Space::with_width(Length::Units(16))) + .push( + Button::new( + &mut self.decrease_debug_ticket_size, + Text::new("-"), + ) + .on_press(Message::DecDebugTicketSize), + ) + .push(iced::Space::with_width(Length::Units(8))) + .push(Text::new(format!("Debug Paths: {}", &self.debug_ticket_size))) + .push(iced::Space::with_width(Length::Units(8))) + .push( + Button::new( + &mut self.increase_debug_ticket_size, + Text::new("+"), + ) + .on_press(Message::IncDebugTicketSize), + ) + .push(iced::Space::with_width(Length::Units(16))) .push(Text::new(format!("Steps: {}", self.debug_step_count))) .push(iced::Space::with_width(Length::Units(16))) .push(Text::new(format!( From 33349f38fd39dfa7774355e6952b1ed1f76d9521 Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Wed, 18 Mar 2026 13:33:44 +0000 Subject: [PATCH 3/7] made the code use the new state Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index 984bc38..234400d 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -986,7 +986,7 @@ impl App { .collect(); // TODO(@mxgrey): Make the number to take configurable - for ticket in self.search_memory.iter().take(10) { + for ticket in self.search_memory.iter().take(self.debug_ticket_size) { if let Some(mt) = search .memory() .0 From 03fef14ebafb42be796ebe05019947e097f2532f Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Wed, 18 Mar 2026 13:37:06 +0000 Subject: [PATCH 4/7] put the buttons together to make it look better Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index 234400d..5a4f123 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -1987,6 +1987,8 @@ impl Application for App { .on_press(Message::StepProgress), ) .push(iced::Space::with_width(Length::Units(16))) + .push(Text::new(format!("Debug Paths: {}", &self.debug_ticket_size))) + .push(iced::Space::with_width(Length::Units(8))) .push( Button::new( &mut self.decrease_debug_ticket_size, @@ -1995,8 +1997,6 @@ impl Application for App { .on_press(Message::DecDebugTicketSize), ) .push(iced::Space::with_width(Length::Units(8))) - .push(Text::new(format!("Debug Paths: {}", &self.debug_ticket_size))) - .push(iced::Space::with_width(Length::Units(8))) .push( Button::new( &mut self.increase_debug_ticket_size, From 984216162d6d1bf0a379141816a5171c0b80c887 Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Wed, 18 Mar 2026 19:44:47 +0000 Subject: [PATCH 5/7] split function, removed TODO and added clearing of trajectories Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 51 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index 5a4f123..bc0523f 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -973,9 +973,32 @@ impl App { } fn step_progress(&mut self) { + self.debug_step_count += 1; + self.draw_search_paths(); + // step towards solution here if let Some((radius, search)) = &mut self.search { - self.debug_step_count += 1; + if let SearchStatus::Solved(solution) = search.step().unwrap() { + println!("Queue length: {}", search.memory().queue_length()); + println!("Solution: {:#?}", solution); + self.canvas.program.layers.3.solutions.clear(); + self.canvas.program.layers.3.solutions.extend( + solution + .make_trajectory() + .unwrap() + .map(|t| (*radius, t.trajectory)) + .into_iter(), + ); + self.debug_node_selected = None; + self.search = None; + self.canvas.cache.clear(); + } else { + println!("Queue length: {}", search.memory().queue_length()); + } + } + } + fn draw_search_paths(&mut self) { + if let Some((radius, search)) = &mut self.search { self.search_memory = search .memory() .0 @@ -985,7 +1008,8 @@ impl App { .map(|n| n.0.clone()) .collect(); - // TODO(@mxgrey): Make the number to take configurable + self.canvas.program.layers.3.searches.clear(); + for ticket in self.search_memory.iter().take(self.debug_ticket_size) { if let Some(mt) = search .memory() @@ -1004,25 +1028,8 @@ impl App { .push((*radius, mt.trajectory)); } } - - if let SearchStatus::Solved(solution) = search.step().unwrap() { - println!("Queue length: {}", search.memory().queue_length()); - println!("Solution: {:#?}", solution); - self.canvas.program.layers.3.solutions.clear(); - self.canvas.program.layers.3.solutions.extend( - solution - .make_trajectory() - .unwrap() - .map(|t| (*radius, t.trajectory)) - .into_iter(), - ); - self.debug_node_selected = None; - self.search = None; - } else { - println!("Queue length: {}", search.memory().queue_length()); - if let Some(selection) = self.debug_node_selected { - self.select_search_node(selection); - } + if let Some(selection) = self.debug_node_selected { + self.select_search_node(selection); } self.canvas.cache.clear(); @@ -1787,10 +1794,12 @@ impl Application for App { } Message::IncDebugTicketSize => { self.debug_ticket_size += 1; + self.draw_search_paths(); } Message::DecDebugTicketSize => { if self.debug_ticket_size > 1 { self.debug_ticket_size -= 1; + self.draw_search_paths(); } } } From 19be2ab1366a89179e93420172410db68f3da18b Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Thu, 19 Mar 2026 08:26:15 +0000 Subject: [PATCH 6/7] switched from button to slider Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 41 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index bc0523f..301c7c3 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -786,6 +786,7 @@ struct App { agent_radius_slider: slider::State, agent_speed_slider: slider::State, agent_spin_slider: slider::State, + debug_ticket_size_slider: slider::State, add_agent_button: button::State, remove_agent_button: button::State, pick_agent_state: pick_list::State, @@ -797,14 +798,12 @@ struct App { show_details: KeyToggler, search: Option<(f64, Search, QueueLengthLimit>)>, step_progress: button::State, - increase_debug_ticket_size: button::State, - decrease_debug_ticket_size: button::State, debug_planner_on: bool, debug_negotiation_on: bool, search_memory: Vec, negotiation_history: Vec, name_map: HashMap, - debug_ticket_size: usize, + debug_ticket_size: u32, debug_step_count: u64, debug_node_selected: Option, negotiation_node_selected: Option, @@ -1010,7 +1009,7 @@ impl App { self.canvas.program.layers.3.searches.clear(); - for ticket in self.search_memory.iter().take(self.debug_ticket_size) { + for ticket in self.search_memory.iter().take(self.debug_ticket_size as usize) { if let Some(mt) = search .memory() .0 @@ -1460,6 +1459,7 @@ impl Application for App { agent_radius_slider: slider::State::new(), agent_speed_slider: slider::State::new(), agent_spin_slider: slider::State::new(), + debug_ticket_size_slider: slider::State::new(), add_agent_button: button::State::new(), remove_agent_button: button::State::new(), pick_agent_state: pick_list::State::new(), @@ -1471,8 +1471,6 @@ impl Application for App { show_details: KeyToggler::for_key(keyboard::KeyCode::LAlt), search: None, step_progress: button::State::new(), - decrease_debug_ticket_size: button::State::new(), - increase_debug_ticket_size: button::State::new(), debug_planner_on: false, debug_negotiation_on: false, search_memory: Default::default(), @@ -1792,16 +1790,10 @@ impl Application for App { self.canvas.cache.clear(); } } - Message::IncDebugTicketSize => { - self.debug_ticket_size += 1; + Message::ChangeDebugTicketSize(value) => { + self.debug_ticket_size = value; self.draw_search_paths(); } - Message::DecDebugTicketSize => { - if self.debug_ticket_size > 1 { - self.debug_ticket_size -= 1; - self.draw_search_paths(); - } - } } Command::none() @@ -1999,19 +1991,13 @@ impl Application for App { .push(Text::new(format!("Debug Paths: {}", &self.debug_ticket_size))) .push(iced::Space::with_width(Length::Units(8))) .push( - Button::new( - &mut self.decrease_debug_ticket_size, - Text::new("-"), - ) - .on_press(Message::DecDebugTicketSize), - ) - .push(iced::Space::with_width(Length::Units(8))) - .push( - Button::new( - &mut self.increase_debug_ticket_size, - Text::new("+"), + Slider::new( + &mut self.debug_ticket_size_slider, + 1..=100, + self.debug_ticket_size, + Message::ChangeDebugTicketSize, ) - .on_press(Message::IncDebugTicketSize), + .width(Length::Units(40)), ) .push(iced::Space::with_width(Length::Units(16))) .push(Text::new(format!("Steps: {}", self.debug_step_count))) @@ -2160,8 +2146,7 @@ enum Message { SelectNegotiationNode(usize), StepProgress, Tick, - IncDebugTicketSize, - DecDebugTicketSize, + ChangeDebugTicketSize(u32), } fn main() -> iced::Result { From 6b7a81ff86755659ce5eabb9111d946b7179daa7 Mon Sep 17 00:00:00 2001 From: uday-kalyan-s Date: Thu, 19 Mar 2026 09:07:03 +0000 Subject: [PATCH 7/7] vertically aligned slider Signed-off-by: uday-kalyan-s --- mapf-viz/examples/grid.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mapf-viz/examples/grid.rs b/mapf-viz/examples/grid.rs index 301c7c3..f2fdba5 100644 --- a/mapf-viz/examples/grid.rs +++ b/mapf-viz/examples/grid.rs @@ -1988,16 +1988,20 @@ impl Application for App { .on_press(Message::StepProgress), ) .push(iced::Space::with_width(Length::Units(16))) - .push(Text::new(format!("Debug Paths: {}", &self.debug_ticket_size))) - .push(iced::Space::with_width(Length::Units(8))) .push( - Slider::new( - &mut self.debug_ticket_size_slider, - 1..=100, - self.debug_ticket_size, - Message::ChangeDebugTicketSize, - ) - .width(Length::Units(40)), + Column::new() + .push(Text::new(format!("Debug Paths: {}", &self.debug_ticket_size))) + .push(iced::Space::with_height(Length::Units(2))) + .push( + Slider::new( + &mut self.debug_ticket_size_slider, + 1..=100, + self.debug_ticket_size, + Message::ChangeDebugTicketSize, + ) + .width(Length::Units(120)), + ) + .align_items(Alignment::Center), ) .push(iced::Space::with_width(Length::Units(16))) .push(Text::new(format!("Steps: {}", self.debug_step_count)))