File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -345,10 +345,27 @@ impl UrdfViewerApp {
345345 self . remove_frame_markers ( window) ;
346346 // update urdf_robot
347347 reload_fn ( & mut self . urdf_robot ) ;
348-
349348 // update robot based on new urdf_robot
350349 let urdf_robot = self . urdf_robot . get ( ) ;
350+
351+ let previous_joint_positions: Vec < _ > = self
352+ . robot
353+ . iter_joints ( )
354+ . map ( |j| ( j. name . clone ( ) , j. joint_position ( ) . unwrap ( ) ) )
355+ . collect ( ) ;
351356 self . robot = urdf_robot. into ( ) ;
357+
358+ // restore joint positions
359+ let mut joint_positions = self . robot . joint_positions ( ) ;
360+ for ( name, pos) in previous_joint_positions {
361+ if let Some ( index) = self . robot . iter_joints ( ) . position ( |j| j. name == name) {
362+ joint_positions[ index] = pos;
363+ }
364+ }
365+ self . robot
366+ . set_joint_positions ( & joint_positions)
367+ . unwrap_or ( ( ) ) ;
368+
352369 self . input_path = PathBuf :: from ( & self . urdf_robot . path ) ;
353370 let end_link_names = if self . input_end_link_names . is_empty ( ) {
354371 self . robot
You can’t perform that action at this time.
0 commit comments