Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 54 additions & 22 deletions mapf-viz/examples/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
Expand All @@ -802,6 +803,7 @@ struct App {
search_memory: Vec<TreeTicket>,
negotiation_history: Vec<NegotiationNode>,
name_map: HashMap<usize, String>,
debug_ticket_size: u32,
debug_step_count: u64,
debug_node_selected: Option<usize>,
negotiation_node_selected: Option<usize>,
Expand Down Expand Up @@ -970,9 +972,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
Expand All @@ -982,8 +1007,9 @@ impl App {
.map(|n| n.0.clone())
.collect();

// TODO(@mxgrey): Make the number to take configurable
for ticket in self.search_memory.iter().take(10) {
self.canvas.program.layers.3.searches.clear();

for ticket in self.search_memory.iter().take(self.debug_ticket_size as usize) {
if let Some(mt) = search
.memory()
.0
Expand All @@ -1001,25 +1027,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();
Expand Down Expand Up @@ -1450,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(),
Expand All @@ -1470,6 +1480,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() {
Expand Down Expand Up @@ -1779,6 +1790,10 @@ impl Application for App {
self.canvas.cache.clear();
}
}
Message::ChangeDebugTicketSize(value) => {
self.debug_ticket_size = value;
self.draw_search_paths();
}
}

Command::none()
Expand Down Expand Up @@ -1973,6 +1988,22 @@ impl Application for App {
.on_press(Message::StepProgress),
)
.push(iced::Space::with_width(Length::Units(16)))
.push(
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),
)
Comment on lines +1991 to +2005
Copy link
Contributor

@mxgrey mxgrey Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While trying this out I found it a bit tedious to repeatedly click the - or + to change the count. I wonder if we could change this to a text input that gets interpreted as a number. It would be better to do a NumberInput, but we're currently relying on a fork of iced, so I suspect this more recent version of iced_aw will be incompatible (edited) without a considerable amount of work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh right yeah that seems like a much better option. I'l switch over to that then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxgrey I'm running into a version dependency issue on all versions of iced_aw > 0.5 :(

error: failed to select a version for `web-sys`.
    ... required by package `wgpu v0.16.0`
    ... which satisfies dependency `wgpu = "^0.16"` of package `iced_wgpu v0.11.0`
    ... which satisfies dependency `iced_wgpu = "^0.11"` of package `iced_renderer v0.1.0`
    ... which satisfies dependency `iced_renderer = "^0.1"` of package `iced_widget v0.1.1`
    ... which satisfies dependency `iced_widget = "^0.1.1"` of package `iced_aw v0.6.0 (https://github.com/iced-rs/iced_aw?tag=v0.6.0#12c3bc0e)`
    ... which satisfies git dependency `iced_aw` of package `mapf-viz v0.3.0 (/home/uday/gsoc/fork/mapf/mapf-viz)`
versions that meet the requirements `^0.3.61` are: 0.3.91, 0.3.90, 0.3.89, 0.3.88, 0.3.87, 0.3.86, 0.3.85, 0.3.84, 0.3.83, 0.3.82, 0.3.81, 0.3.80, 0.3.79, 0.3.78, 0.3.77, 0.3.76, 0.3.75, 0.3.74, 0.3.73, 0.3.72, 0.3.70, 0.3.69, 0.3.68, 0.3.67, 0.3.66, 0.3.65, 0.3.64, 0.3.63, 0.3.62, 0.3.61

all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.57`
    ... which satisfies dependency `web-sys = "^0.3.46"` (locked to 0.3.57) of package `rfd v0.12.1`
    ... which satisfies dependency `rfd = "^0.12"` (locked to 0.12.1) of package `mapf-viz v0.3.0 (/home/uday/gsoc/fork/mapf/mapf-viz)`

failed to select a version for `web-sys` which could resolve this conflict

and updating rfd gives

error: failed to select a version for `web-sys`.
    ... required by package `wgpu v0.12.0`
    ... which satisfies dependency `wgpu = "^0.12"` of package `iced_wgpu v0.4.0 (https://github.com/mxgrey/iced?branch=asymmetric_scale#036769a9)`
    ... which satisfies git dependency `iced_wgpu` (locked to 0.4.0) of package `iced v0.3.0 (https://github.com/mxgrey/iced?branch=asymmetric_scale#036769a9)`
    ... which satisfies git dependency `iced` (locked to 0.3.0) of package `mapf-viz v0.3.0 (/home/uday/gsoc/fork/mapf/mapf-viz)`
versions that meet the requirements `^0.3.53` are: 0.3.57, 0.3.91, 0.3.90, 0.3.89, 0.3.88, 0.3.87, 0.3.86, 0.3.85, 0.3.84, 0.3.83, 0.3.82, 0.3.81, 0.3.80, 0.3.79, 0.3.78, 0.3.77, 0.3.76, 0.3.75, 0.3.74, 0.3.73, 0.3.72, 0.3.70, 0.3.69, 0.3.68, 0.3.67, 0.3.66, 0.3.65, 0.3.64, 0.3.63, 0.3.62, 0.3.61, 0.3.60, 0.3.59, 0.3.58, 0.3.56, 0.3.55, 0.3.54, 0.3.53

package `wgpu` depends on `web-sys` with feature `GpuBufferUsage` but `web-sys` does not have that feature.
 package `web-sys` does have feature `GpuBufferUsage`


all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.77`
    ... which satisfies dependency `web-sys = "^0.3.53"` of package `wgpu v0.12.0`
    ... which satisfies dependency `wgpu = "^0.12"` of package `iced_wgpu v0.4.0 (https://github.com/mxgrey/iced?branch=asymmetric_scale#036769a9)`
    ... which satisfies git dependency `iced_wgpu` (locked to 0.4.0) of package `iced v0.3.0 (https://github.com/mxgrey/iced?branch=asymmetric_scale#036769a9)`
    ... which satisfies git dependency `iced` (locked to 0.3.0) of package `mapf-viz v0.3.0 (/home/uday/gsoc/fork/mapf/mapf-viz)`

failed to select a version for `web-sys` which could resolve this conflict

Should I just move on with the v0.5 iced_aw? It does support number_input but its been through a lot of bug fixes in each version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running into a version dependency issue on all versions of iced_aw > 0.5 :(

I'm so sorry, there was a typo in my earlier comment which I've edited to correct. I was expecting the newer versions of iced_aw to be incompatible due to our fork, and that's exactly what you've found 😭

Should I just move on with the v0.5 iced_aw? It does support number_input but its been through a lot of bug fixes in each version

If you're able to find any version of iced_aw that has number_input and is compatible with the fork we use, that would be fantastic. I'm definitely not expecting the newest version of iced_aw to work without us doing a major overhaul of our fork of iced and probably other dependency migrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh lolll. Thats alright! I'l just switch over to 0.5 then. it seems to be exactly what we are looking for

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe as a last resort we could use a slider that ranges from 1 to 100 or 1000. It's certainly not ideal, but it's a significant improvement over the previous fixed value of 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp. I guess it's a bit hard to control, but I doubt anyone's looking to set a fine-grained value of this. Anyways, can you pls check the latest commit once to see if it's fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A problem I'm noticing with the slider is that the text to its left will change size while sliding, which changes the spatial range of the sliding bar and creates an unstable feedback loop:

slider_problems.mp4

Moving the slider by a single pixel can make the numerical value jump around wildly. Instead of this side-by-side approach we should place the slider under the text, like you see for the other numerical sliders in the app:

image

That way when the slider changes the displayed number, it's not also changing the space of the slider itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh rightt yeah fairss that's true. I thought the issue was a glitch in the iced library 💀 . I'll change that bit over to a vertical layout then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp. Now it works much better thanks!!
image
Although it doesnt look the best asthetically 😅 , but im not sure if theres any other option

.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!(
Expand Down Expand Up @@ -2119,6 +2150,7 @@ enum Message {
SelectNegotiationNode(usize),
StepProgress,
Tick,
ChangeDebugTicketSize(u32),
}

fn main() -> iced::Result {
Expand Down
Loading