-
Notifications
You must be signed in to change notification settings - Fork 110
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
Added per-motor control to Thunderscope diagnostics #3401
base: master
Are you sure you want to change the base?
Conversation
this looks pretty cool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Looked really good when you tested it out on Saturday.
src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
Outdated
Show resolved
Hide resolved
src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
Outdated
Show resolved
Hide resolved
src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
Outdated
Show resolved
Hide resolved
src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
Show resolved
Hide resolved
src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
Outdated
Show resolved
Hide resolved
…r-motor # Conflicts: # src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
if not self.drive_mode == DriveMode.VELOCITY: | ||
motor_control.ClearField("direct_per_wheel_control") | ||
motor_control.direct_velocity_drive.velocity.x_component_meters = ( | ||
self.x_velocity_slider.value() | ||
) | ||
motor_control.direct_velocity_drive.velocity.y_component_meters = ( | ||
self.y_velocity_slider.value() | ||
) | ||
motor_control.direct_velocity_drive.angular_velocity.radians_per_second = ( | ||
self.angular_velocity_slider.value() | ||
) | ||
else: | ||
motor_control.ClearField("direct_velocity_control") | ||
motor_control.direct_per_wheel_drive.front_left_wheel_velocity = ( | ||
self.front_left_motor_slider.value() | ||
) | ||
motor_control.direct_per_wheel_drive.front_right_wheel_velocity = ( | ||
self.front_right_motor_slider.value() | ||
) | ||
motor_control.direct_per_wheel_drive.back_left_wheel_velocity = ( | ||
self.back_left_motor_slider.value() | ||
) | ||
motor_control.direct_per_wheel_drive.back_right_wheel_velocity = ( | ||
self.back_right_motor_slider.value() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why structure it this way?
why not if self.drive_mode == DriveMode.MOTOR
to avoid that confusing not
if you are handling the else
case here as well?
so
if self.drive_mode == DriveMode.MOTOR
...
else:
self.drive_mode = DriveMode.VELOCITY | ||
self.use_direct_velocity.setChecked(True) | ||
self.toggle_drive_mode(DriveMode.VELOCITY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you could replace this with self.use_direct_velocity.click()
since it is attached with the QtSignal to toggle_drive_mode
src/software/thunderscope/robot_diagnostics/drive_and_dribbler_widget.py
Show resolved
Hide resolved
motor_control.direct_per_wheel_drive.front_left_wheel_velocity = ( | ||
self.front_left_motor_slider.value() | ||
) | ||
motor_control.direct_per_wheel_drive.front_right_wheel_velocity = ( | ||
self.front_right_motor_slider.value() | ||
) | ||
motor_control.direct_per_wheel_drive.back_left_wheel_velocity = ( | ||
self.back_left_motor_slider.value() | ||
) | ||
motor_control.direct_per_wheel_drive.back_right_wheel_velocity = ( | ||
self.back_right_motor_slider.value() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be motor_control.direct_per_wheel_control.front_left_wheel_velocity
, etc.
Currently, this line errors out when you run it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work! left some feedback for you to munch on.
def disconnect_dribbler_sliders(self) -> None: | ||
self.dribbler_speed_rpm_slider.valueChanged.disconnect() | ||
|
||
def disconnect_motor_sliders(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add some function docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, one more nit from me!
Description
Added per motor control as a set of radio buttons in thunderscope diagnostic. Direct velocity and per motor control will switch depending on which radio button is pressed. The two control widgets will not appear at the same time, since both inputs are not allowed at the same time. Pressing the button for per-motor control will shut off direct-velocity control and reset those sliders, then switch the widget for per-motor control. Vice versa also applies.
Testing Done
It was tested on a robot in the mezz. Test was made on all sliders of direct-velocity, switching to per-motor without using reset, changing sliders on per-motor, and switching back to direct-velocity. Back-and-forth was done twice. The robot did all the commands it was told to on all motors. It was also tested using print() on the terminal.
Resolved Issues
resolves #3320
Length Justification and Key Files to Review
Key file: drive_and_dribbler_widget.py (relates to primitive.cpp, but primitive was not edited)
Added a function for switching between direct velocity and per motor control mode. Changed the organization of the reset_motor functions to split them up so that each could be run individually instead of having to reset all. I removed the function for enabling the motors, as it was unused (there was no way to use it via the UI).
Review Checklist
.h
file) should have a javadoc style comment at the start of them. For examples, see the functions defined inthunderbots/software/geom
. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.TODO
(or similar) statements should either be completed or associated with a github issueThe current max speed for per-motor speeds is the same variable in tbots_cpp.create2021RobotConstants() called robot_max_speed_m_per_s.