-
Notifications
You must be signed in to change notification settings - Fork 52
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
fix: Modify pan tilt function by getting pan/tilt range dynamically #181
fix: Modify pan tilt function by getting pan/tilt range dynamically #181
Conversation
Signed-off-by: preethi-satishcandra <[email protected]>
Signed-off-by: preethi-satishcandra <[email protected]>
} `json:"PanTilt"` | ||
} `json:"PTZPosition"` | ||
Token string `json:"Token"` | ||
} `json:"Preset"` | ||
} | ||
|
||
type GetPTZConfigurationsResponse struct { | ||
PTZConfiguration []struct { | ||
DefaultAbsolutePantTiltPositionSpace string `json:"DefaultAbsolutePantTiltPositionSpace"` |
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.
should this be 'DefaultAbsolutePanTiltPositionSpace'?
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.
Its a typo from the onvif specification end - https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl
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.
yeah there are actually a decent amount of typos in the specs. its suprising.
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.
besides my comment, looks good
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.
1 fix and 1 suggestion
left := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.XRange.Min | ||
right := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.XRange.Max | ||
up := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.YRange.Max | ||
down := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.YRange.Min |
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.
panTiltOffset
should actually be multiplied by the range and not the min/max, like so:
left := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.XRange.Min | |
right := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.XRange.Max | |
up := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.YRange.Max | |
down := panTiltOffset * ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.YRange.Min | |
xRange := ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.XRange.Max - ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.XRange.Min | |
right := panTiltOffset * xRange | |
left := -right | |
yRange := ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.YRange.Max - ptzConfigs.PTZConfiguration[0].PanTiltLimits.Range.YRange.Min | |
up := panTiltOffset * yRange | |
down := -up |
@@ -257,6 +254,19 @@ func (app *CameraManagementApp) ptzRoute(w http.ResponseWriter, req *http.Reques | |||
var res dtosCommon.BaseResponse | |||
var err error | |||
|
|||
// Get pan/tilt x,y range for a particular device | |||
ptzConfigs, err := app.getPTZConfiguration(deviceName) |
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 would be nice to have some caching mechanism where this only queries the camera if it has not queried it before. lazy-load style. Could be as simple as a map<deviceName, Response> and a mutex.
Signed-off-by: preethi-satishcandra <[email protected]>
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.
Looks good. Small comments.
defer app.panTiltMutex.Unlock() | ||
val, exists := app.panTiltMap[deviceName] | ||
if !exists { | ||
fmt.Println("Device does not exist") |
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.
we can probably remove this print
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.
Had just added for some testing :-) will remove
func (app *CameraManagementApp) getPanTiltRange(deviceName string) (PanTiltRange, error) { | ||
app.panTiltMutex.Lock() | ||
defer app.panTiltMutex.Unlock() | ||
val, exists := app.panTiltMap[deviceName] |
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 would probably call val
as panTiltRange
instead, and then return panTiltRange
on line 329, and on line 322, change panTiltRange :=
to panTiltRange =
, and remove the return on line 327. the code will fall out the if and return through one path.
Signed-off-by: preethi-satishcandra <[email protected]>
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!
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
Signed-off-by: Bryon Nevis <[email protected]> Signed-off-by: Bryon Nevis <[email protected]> fix: remove duplicated path from query uri (edgexfoundry#182) Signed-off-by: Anthony Casagrande <[email protected]> fix: Modify pan tilt function by getting pan/tilt range dynamically (edgexfoundry#181) * fix: Get pan/tilt values dynamically Signed-off-by: preethi-satishcandra <[email protected]> feat: support for usb cameras and onvif zoom functionality in camera mgmt app (edgexfoundry#184) Signed-off-by: Anthony Casagrande <[email protected]> Signed-off-by: Christian Darr <[email protected]> Signed-off-by: Brian Osburn <[email protected]> Co-authored-by: Brian Osburn <[email protected]> Co-authored-by: Christian Darr <[email protected]> feat: updated app service with target type Signed-off-by: brianointel <[email protected]> feat: added code for pipeline function Signed-off-by: brianointel <[email protected]> feat: template code for funtion pipelines by topic Signed-off-by: brianointel <[email protected]> feat: added initial event handler Signed-off-by: brianointel <[email protected]> feat: more device messagebus progress Signed-off-by: brianointel <[email protected]> feat: message bus code Signed-off-by: Brian Osburn <[email protected]> feat: messagebus progress Signed-off-by: Brian Osburn <[email protected]> feat: created defaultpipelinefunction Signed-off-by: Brian Osburn <[email protected]> feat: try to start pipelines on startup Signed-off-by: brianointel <[email protected]> feat: small changes Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: added config params Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: handle device delete event to stop pipeline also some minor refactoring Signed-off-by: Anthony Casagrande <[email protected]>
* feat: Update device service example for Levski Signed-off-by: Leonard Goodell <[email protected]> build: Update HELM Chart to Levski released images (edgexfoundry#140) Signed-off-by: Leonard Goodell <[email protected]> Signed-off-by: Leonard Goodell <[email protected]> feat: added support for shared and non-shared volumes Close edgexfoundry#92 Signed-off-by: Kyle Morton <[email protected]> fix: EdgeX UI in kubernetes was not binding container network IF Signed-off-by: Bryon Nevis <[email protected]> feat: Added support for onvif and usb camera Closes edgexfoundry#107 Signed-off-by: Kyle Morton <[email protected]> feat: Added support for modbus-simulator Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for ds-mqtt and mqtt-broker Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for ds-modbus Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for ds-bacnet Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for ds-snmp Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for ds-rfid-llrp Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for ds-gpio Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for asc-mqtt and asc-httpexport Signed-off-by: Kyle Morton <[email protected]> feat: Add support in helm for asc-sample, asc-metrics, and as-llrp Signed-off-by: Kyle Morton <[email protected]> fix: Updated device-onvif-camera and device-usb-camera directory and volume (edgexfoundry#156) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> fix: added service for edgex-ui (edgexfoundry#162) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> feat: Added support for nats (edgexfoundry#163) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> fix: Updated health checks to appropriate protocol (edgexfoundry#164) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> fix: added kuiper-connections and kuipers-sources volumes (edgexfoundry#165) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> fix: Correct addConsulRoles list (edgexfoundry#166) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> feat: Support optional hostPort binding (edgexfoundry#167) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> feat: Expose services on a per-service basis (edgexfoundry#169) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> fix: Added container port names (edgexfoundry#170) Signed-off-by: Kyle Morton <[email protected]> Signed-off-by: Kyle Morton <[email protected]> Co-authored-by: Kyle Morton <[email protected]> feat!: Remove system-mgmt-agent (deprecated) (edgexfoundry#175) BREAKING CHANGE: Remove system-mgmt-agent (deprectated) Signed-off-by: Bryon Nevis <[email protected]> Signed-off-by: Bryon Nevis <[email protected]> docs: add link to camera app example video Signed-off-by: Anthony Casagrande <[email protected]> feat: Add Helm security scanners (edgexfoundry#174) Signed-off-by: Bryon Nevis <[email protected]> Signed-off-by: Bryon Nevis <[email protected]> fix: remove duplicated path from query uri (edgexfoundry#182) Signed-off-by: Anthony Casagrande <[email protected]> fix: Modify pan tilt function by getting pan/tilt range dynamically (edgexfoundry#181) * fix: Get pan/tilt values dynamically Signed-off-by: preethi-satishcandra <[email protected]> feat: support for usb cameras and onvif zoom functionality in camera mgmt app (edgexfoundry#184) Signed-off-by: Anthony Casagrande <[email protected]> Signed-off-by: Christian Darr <[email protected]> Signed-off-by: Brian Osburn <[email protected]> Co-authored-by: Brian Osburn <[email protected]> Co-authored-by: Christian Darr <[email protected]> feat: updated app service with target type Signed-off-by: brianointel <[email protected]> feat: added code for pipeline function Signed-off-by: brianointel <[email protected]> feat: template code for funtion pipelines by topic Signed-off-by: brianointel <[email protected]> feat: added initial event handler Signed-off-by: brianointel <[email protected]> feat: more device messagebus progress Signed-off-by: brianointel <[email protected]> feat: message bus code Signed-off-by: Brian Osburn <[email protected]> feat: messagebus progress Signed-off-by: Brian Osburn <[email protected]> feat: created defaultpipelinefunction Signed-off-by: Brian Osburn <[email protected]> feat: try to start pipelines on startup Signed-off-by: brianointel <[email protected]> feat: small changes Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: added config params Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: handle device delete event to stop pipeline Signed-off-by: brianointel <[email protected]> also some minor refactoring Signed-off-by: Anthony Casagrande <[email protected]> fix: pr updates Signed-off-by: Brian Osburn <[email protected]> refactor: fix imports from merge Signed-off-by: Anthony Casagrande <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> fix: updated funtion name Signed-off-by: Brian Osburn <[email protected]> feat: Add Helm security scanners (edgexfoundry#174) Signed-off-by: Bryon Nevis <[email protected]> Signed-off-by: Bryon Nevis <[email protected]> fix: remove duplicated path from query uri (edgexfoundry#182) Signed-off-by: Anthony Casagrande <[email protected]> fix: Modify pan tilt function by getting pan/tilt range dynamically (edgexfoundry#181) * fix: Get pan/tilt values dynamically Signed-off-by: preethi-satishcandra <[email protected]> feat: support for usb cameras and onvif zoom functionality in camera mgmt app (edgexfoundry#184) Signed-off-by: Anthony Casagrande <[email protected]> Signed-off-by: Christian Darr <[email protected]> Signed-off-by: Brian Osburn <[email protected]> Co-authored-by: Brian Osburn <[email protected]> Co-authored-by: Christian Darr <[email protected]> feat: updated app service with target type Signed-off-by: brianointel <[email protected]> feat: added code for pipeline function Signed-off-by: brianointel <[email protected]> feat: template code for funtion pipelines by topic Signed-off-by: brianointel <[email protected]> feat: added initial event handler Signed-off-by: brianointel <[email protected]> feat: more device messagebus progress Signed-off-by: brianointel <[email protected]> feat: message bus code Signed-off-by: Brian Osburn <[email protected]> feat: messagebus progress Signed-off-by: Brian Osburn <[email protected]> feat: created defaultpipelinefunction Signed-off-by: Brian Osburn <[email protected]> feat: try to start pipelines on startup Signed-off-by: Brian Osburn <[email protected]> feat: small changes Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: added config params Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> feat: handle device delete event to stop pipeline also some minor refactoring Signed-off-by: Anthony Casagrande <[email protected]> fix: pr updates Signed-off-by: Brian Osburn <[email protected]> refactor: fix imports from merge Signed-off-by: Anthony Casagrande <[email protected]> feat: pr updates Signed-off-by: Brian Osburn <[email protected]> fix: updated funtion name Signed-off-by: Brian Osburn <[email protected]> fix: corrected error message placement Signed-off-by: brianointel <[email protected]>
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-examples/blob/main/.github/Contributing.md
PR Checklist
Please check if your PR fulfills the following requirements:
Testing Instructions