-
Notifications
You must be signed in to change notification settings - Fork 111
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-4333] negative resolutions ignored in camera configs. #3811
[RSDK-4333] negative resolutions ignored in camera configs. #3811
Conversation
go.mod
Outdated
@@ -2,6 +2,8 @@ module go.viam.com/rdk | |||
|
|||
go 1.21 | |||
|
|||
toolchain go1.21.7 |
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.
revert before merge.
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.
Why was this needed?
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.
go 1.21 and further uses toolchains to manage the dependencies, running make lint-go sometimes adds this I've noticed. Abe is trying to figure out how to handle adding a toolchain to the go.mod file. Until then I'll remove the toolchain when it's added.
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.
go mod tidy
adds the toolchain directive to any go.mod file with go 1.21
or higher (golang/go#62409)
I think we rely strictly on go 1.21 now (we're using new libraries) and so it's okay to add this; any downstream projects that can't handle the toolchain
directive are already broken I suspect
would want to test locally on a mac to make sure it doesn't break
// Validate ensures all parts of the config are valid. | ||
func (c fileSourceConfig) Validate(path string) ([]string, error) { | ||
if c.CameraParameters.Width < 0 || c.CameraParameters.Height < 0 { | ||
return nil, fmt.Errorf(" webcam width %v, and height %v must be non-zero and positive", |
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.
CameraParameters are from the intrinsics right? Should we mention intrinsics explicitly in the error message?
Also should we change webcam
-> image_file cam
or something
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.
done, I'm struggling with the phrasing, which I copied from aligns. Do we like a specific phrasing more out of the possible error messages here?
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.
likely running make lint-go with my machine's go triggered the addition.
this was meant as a reply to go mod.
@@ -60,7 +60,6 @@ func init() { | |||
|
|||
// transformConfig specifies a stream and list of transforms to apply on images/pointclouds coming from a source camera. | |||
type transformConfig struct { | |||
resource.TriviallyValidateConfig |
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 was weird. We had a double implementation of Validate in pipeline, so I don't know which one it could have called, if it was deterministic at all.
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.
Golang moment
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.
LGTM! Sounds good to actually test with devices tho
@@ -60,7 +60,6 @@ func init() { | |||
|
|||
// transformConfig specifies a stream and list of transforms to apply on images/pointclouds coming from a source camera. | |||
type transformConfig struct { | |||
resource.TriviallyValidateConfig |
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.
Golang moment
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.
cool cool, just a small suggestion
func (cfg *Config) Validate(path string) ([]string, error) { | ||
if cfg.CameraParameters != nil { | ||
if cfg.CameraParameters.Height < 0 || cfg.CameraParameters.Width < 0 { | ||
return nil, fmt.Errorf( |
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.
[optional] errors.Errorf
does the same thing as fmt.Errorf
and you won't need to import a new 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.
That's part of "github.com/pkg/errors" not the standard "errors" go library (always gets me too). Not changing since that's a public archive.
We'll move away from the archived package in static.go eventually.
func (c fileSourceConfig) Validate(path string) ([]string, error) { | ||
if c.CameraParameters != nil { | ||
if c.CameraParameters.Width < 0 || c.CameraParameters.Height < 0 { | ||
return nil, fmt.Errorf( |
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.
same here for fmt vs errors package
0036a2c
to
b8f691d
Compare
Adds negative resolution validation checks to the camera drivers.
TODO: