-
Notifications
You must be signed in to change notification settings - Fork 113
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
RSDK-6282 [part 1]: add PID values to the gpio motor config #3435
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
77f3e14
use PID values from config for encoded motor
martha-johnston 283ec2d
set tuning to false
martha-johnston 252959e
helper function for sum block
martha-johnston 2575381
fix issue of using two motors at once
martha-johnston d99b787
remove blockIndex
martha-johnston 3a0538d
Merge branch 'viamrobotics:main' into rsdk-6282
martha-johnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ import ( | |
"go.viam.com/rdk/components/board" | ||
"go.viam.com/rdk/components/encoder" | ||
"go.viam.com/rdk/components/motor" | ||
"go.viam.com/rdk/control" | ||
"go.viam.com/rdk/logging" | ||
"go.viam.com/rdk/resource" | ||
) | ||
|
@@ -101,19 +100,26 @@ func (conf *PinConfig) MotorType(path string) (MotorType, error) { | |
return motorType, nil | ||
} | ||
|
||
// PIDConfig contains the PID values that are accessible from controlled component configs. | ||
type motorPIDConfig struct { | ||
P float64 `json:"p"` | ||
I float64 `json:"i"` | ||
D float64 `json:"d"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love this struct <3 |
||
} | ||
|
||
// Config describes the configuration of a motor. | ||
type Config struct { | ||
Pins PinConfig `json:"pins"` | ||
BoardName string `json:"board"` | ||
MinPowerPct float64 `json:"min_power_pct,omitempty"` // min power percentage to allow for this motor default is 0.0 | ||
MaxPowerPct float64 `json:"max_power_pct,omitempty"` // max power percentage to allow for this motor (0.06 - 1.0) | ||
PWMFreq uint `json:"pwm_freq,omitempty"` | ||
DirectionFlip bool `json:"dir_flip,omitempty"` // Flip the direction of the signal sent if there is a Dir pin | ||
ControlLoop control.Config `json:"control_config,omitempty"` // Optional control loop | ||
Encoder string `json:"encoder,omitempty"` // name of encoder | ||
RampRate float64 `json:"ramp_rate,omitempty"` // how fast to ramp power to motor when using rpm control | ||
MaxRPM float64 `json:"max_rpm,omitempty"` | ||
TicksPerRotation int `json:"ticks_per_rotation,omitempty"` | ||
Pins PinConfig `json:"pins"` | ||
BoardName string `json:"board"` | ||
MinPowerPct float64 `json:"min_power_pct,omitempty"` // min power percentage to allow for this motor default is 0.0 | ||
MaxPowerPct float64 `json:"max_power_pct,omitempty"` // max power percentage to allow for this motor (0.06 - 1.0) | ||
PWMFreq uint `json:"pwm_freq,omitempty"` | ||
DirectionFlip bool `json:"dir_flip,omitempty"` // Flip the direction of the signal sent if there is a Dir pin | ||
Encoder string `json:"encoder,omitempty"` // name of encoder | ||
RampRate float64 `json:"ramp_rate,omitempty"` // how fast to ramp power to motor when using rpm control | ||
MaxRPM float64 `json:"max_rpm,omitempty"` | ||
TicksPerRotation int `json:"ticks_per_rotation,omitempty"` | ||
ControlParameters *motorPIDConfig `json:"control_parameters,omitempty"` | ||
} | ||
|
||
// Validate ensures all parts of the config are valid. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this background context canceled by anything in the loop? Or will it continue returning nil and blocking on a done call in the controls package?
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 don't think it's canceled by anything... I'm not sure it's necessary to even have a context for this function
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.
this function should be removed in a future pr