Fully working B1 ROS navigation on onboard cpu#620
Conversation
| self.stop_timer = threading.Timer(self.command_timeout, self._safety_stop) | ||
| self.stop_timer.daemon = True | ||
| self.stop_timer.start() |
There was a problem hiding this comment.
This creates a new thread every time a move is made. I think it would be better to reuse the thread, but that would me creating a custom timer.
Of course, since we're pressed for time, it should be okay for now. Maybe add a TODO: FIXME
There was a problem hiding this comment.
Yes good catch this is bad. Quickly fixing
b1f4569 to
b49dde0
Compare
b49dde0 to
776e13b
Compare
b47f96a to
b08cbfd
Compare
| def stop(self): | ||
| """Stop the connection and send stop commands.""" | ||
| # Cancel timer since we're explicitly stopping | ||
| if self.stop_timer: |
There was a problem hiding this comment.
self.stop_timer was removed. This will error.
|
|
||
| def cleanup(self): | ||
| """Clean up resources when module is destroyed.""" | ||
| if self.stop_timer: |
| self.stop_timer.cancel() | ||
|
|
||
| # Auto-stop after 0.5 seconds if no new commands | ||
| self.stop_timer = threading.Timer(self.cmd_vel_timeout, self.stop) |
There was a problem hiding this comment.
There's still a timer here.
There was a problem hiding this comment.
Weird that this is here in this branch its not in the rebase connection.py
| logger.debug(f"Converted to B1Command: {self._current_cmd}") | ||
|
|
||
| self.last_command_time = time.time() | ||
| self.timeout_active = False # Reset timeout state since we got a new command |
There was a problem hiding this comment.
This variable is modified both here and in the watchdog loop. You need with lock.
| if has_movement and self.current_mode not in (1, 2): | ||
| logger.info("Auto-switching to WALK mode for ROS control") | ||
| self.set_mode(2) | ||
| elif not has_movement and self.current_mode == 2: | ||
| logger.info("Auto-switching to IDLE mode (zero velocities)") | ||
| self.set_mode(0) |
There was a problem hiding this comment.
NITPICK: These magic numbers should be constants.
| self._current_cmd.lx = 0.0 | ||
| self._current_cmd.ly = 0.0 | ||
| self._current_cmd.rx = 0.0 | ||
| self._current_cmd.ry = 0.0 |
There was a problem hiding this comment.
self._current_cmd is now used in at least three threads. It needs a lock everywhere it's used.
|
Resolved by #626 |
No description provided.