-
Notifications
You must be signed in to change notification settings - Fork 110
/
properties.go
46 lines (42 loc) · 1.79 KB
/
properties.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package movementsensor
import pb "go.viam.com/api/component/movementsensor/v1"
// Properties is a structure representing features
// of a movementsensor.
// The order is in terms of order of derivatives in time
// with position, orientation, compassheading at the top (zeroth derivative)
// linear and angular velocities next (first derivative)
// linear acceleration last (second derivative).
type Properties struct {
PositionSupported bool
OrientationSupported bool
CompassHeadingSupported bool
LinearVelocitySupported bool
AngularVelocitySupported bool
LinearAccelerationSupported bool
}
// ProtoFeaturesToProperties takes a GetPropertiesResponse and returns
// an equivalent Properties struct.
func ProtoFeaturesToProperties(resp *pb.GetPropertiesResponse) *Properties {
return &Properties{
PositionSupported: resp.PositionSupported,
OrientationSupported: resp.OrientationSupported,
CompassHeadingSupported: resp.CompassHeadingSupported,
LinearVelocitySupported: resp.LinearVelocitySupported,
AngularVelocitySupported: resp.AngularVelocitySupported,
LinearAccelerationSupported: resp.LinearAccelerationSupported,
}
}
// PropertiesToProtoResponse takes a properties struct and converts it
// to a GetPropertiesResponse.
func PropertiesToProtoResponse(
features *Properties,
) (*pb.GetPropertiesResponse, error) {
return &pb.GetPropertiesResponse{
PositionSupported: features.PositionSupported,
OrientationSupported: features.OrientationSupported,
CompassHeadingSupported: features.CompassHeadingSupported,
LinearVelocitySupported: features.LinearVelocitySupported,
AngularVelocitySupported: features.AngularVelocitySupported,
LinearAccelerationSupported: features.LinearAccelerationSupported,
}, nil
}