Skip to content

[RSDK-8749] add FakeServo, servo data capture #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2025

Conversation

mattjperez
Copy link
Member

@mattjperez mattjperez commented May 27, 2025

verified on app by enabling data collection, and making a FakeServo with the following attribute

{
  "fake_position": 10
}

@mattjperez mattjperez requested a review from gvaradarajan May 27, 2025 15:02
@mattjperez mattjperez requested a review from a team as a code owner May 27, 2025 15:02
Copy link
Member

@gvaradarajan gvaradarajan left a comment

Choose a reason for hiding this comment

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

LGTM

#[derive(DoCommand)]
pub struct FakeServo {
pos: u32,
pow: u32,
Copy link
Member

Choose a reason for hiding this comment

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

is pow meaningful to include? It never appears to change

Copy link
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

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

Code looks fine, though the FakeServo has some somewhat inconsistent behavior. I don't know if we expect fakes to be even at all a little realistic, so maybe it doesn't matter.

Ok(self.pow > 0)
}
fn stop(&mut self) -> Result<(), super::actuator::ActuatorError> {
self.pos = 0;
Copy link
Member

Choose a reason for hiding this comment

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

If the stop method set pow to 0, then it would also resolve the comment above about pow never changing. But, it isn't clear to me that 0 pow is actually the stopped state for a servo?

#[cfg(feature = "builtin-components")]
impl Actuator for FakeServo {
fn is_moving(&mut self) -> Result<bool, super::actuator::ActuatorError> {
Ok(self.pow > 0)
Copy link
Member

Choose a reason for hiding this comment

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

The fake servo moves to a new position instantaneously, so, is it ever moving? But pow is always 1, so it will also always be moving, even if no move_to was ever called.

@mattjperez
Copy link
Member Author

mattjperez commented May 29, 2025

@acmorrow updated the FakeServo to mimic rdk's fake behavior

I had originally based it off of our FakeMotor implementation, since there it also implements Actuator

Copy link
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

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

LGTM

@mattjperez mattjperez merged commit 23c0887 into viamrobotics:main May 29, 2025
6 checks passed
@mattjperez mattjperez deleted the rsdk-8749-data-capture-servo branch May 29, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants