A PX4 based camera pointer

locate.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. package pipoint
  16. import (
  17. "juju.net.nz/x/pipoint/param"
  18. )
  19. // LocateState runs initially to locate the base unit.
  20. type LocateState struct {
  21. name string
  22. pi *PiPoint
  23. }
  24. func (s *LocateState) Name() string {
  25. return "Locate"
  26. }
  27. // Update is called when a param is updated.
  28. func (s *LocateState) Update(param *param.Param) {
  29. switch param {
  30. case s.pi.neu:
  31. s.pi.rover.Set(param.Get())
  32. s.pi.base.Set(param.Get())
  33. s.pi.base.Finalise()
  34. case s.pi.attitude:
  35. s.pi.offset.Set(&Attitude{
  36. Yaw: s.pi.attitude.Get().(*Attitude).Yaw,
  37. })
  38. case s.pi.mark:
  39. s.pi.state.Inc()
  40. }
  41. }