/
EstimatorStates.gen.go
171 lines (143 loc) · 5.93 KB
/
EstimatorStates.gen.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
This file is part of rclgo
Copyright © 2021 Technology Innovation Institute, United Arab Emirates
Licensed under the Apache License, Version 2.0 (the "License");
http://www.apache.org/licenses/LICENSE-2.0
*/
/*
THIS FILE IS AUTOGENERATED BY 'rclgo-gen generate'
*/
package px4_msgs_msg
import (
"unsafe"
"github.com/TIERS/rclgo/pkg/rclgo/types"
"github.com/TIERS/rclgo/pkg/rclgo/typemap"
primitives "github.com/TIERS/rclgo/pkg/rclgo/primitives"
)
/*
#cgo LDFLAGS: -L/opt/ros/foxy/lib -Wl,-rpath=/opt/ros/foxy/lib -lrcl -lrosidl_runtime_c -lrosidl_typesupport_c -lrcutils -lrmw_implementation
#cgo LDFLAGS: -lpx4_msgs__rosidl_typesupport_c -lpx4_msgs__rosidl_generator_c
#cgo CFLAGS: -I/opt/ros/foxy/include
#include <rosidl_runtime_c/message_type_support_struct.h>
#include <px4_msgs/msg/estimator_states.h>
*/
import "C"
func init() {
typemap.RegisterMessage("px4_msgs/EstimatorStates", EstimatorStatesTypeSupport)
}
// Do not create instances of this type directly. Always use NewEstimatorStates
// function instead.
type EstimatorStates struct {
Timestamp uint64 `yaml:"timestamp"`// time since system start (microseconds)
TimestampSample uint64 `yaml:"timestamp_sample"`// the timestamp of the raw data (microseconds)
States [24]float32 `yaml:"states"`// Internal filter states
NStates uint8 `yaml:"n_states"`// Number of states effectively used
Covariances [24]float32 `yaml:"covariances"`// Diagonal Elements of Covariance Matrix
}
// NewEstimatorStates creates a new EstimatorStates with default values.
func NewEstimatorStates() *EstimatorStates {
self := EstimatorStates{}
self.SetDefaults()
return &self
}
func (t *EstimatorStates) Clone() *EstimatorStates {
c := &EstimatorStates{}
c.Timestamp = t.Timestamp
c.TimestampSample = t.TimestampSample
c.States = t.States
c.NStates = t.NStates
c.Covariances = t.Covariances
return c
}
func (t *EstimatorStates) CloneMsg() types.Message {
return t.Clone()
}
func (t *EstimatorStates) SetDefaults() {
t.Timestamp = 0
t.TimestampSample = 0
t.States = [24]float32{}
t.NStates = 0
t.Covariances = [24]float32{}
}
// CloneEstimatorStatesSlice clones src to dst by calling Clone for each element in
// src. Panics if len(dst) < len(src).
func CloneEstimatorStatesSlice(dst, src []EstimatorStates) {
for i := range src {
dst[i] = *src[i].Clone()
}
}
// Modifying this variable is undefined behavior.
var EstimatorStatesTypeSupport types.MessageTypeSupport = _EstimatorStatesTypeSupport{}
type _EstimatorStatesTypeSupport struct{}
func (t _EstimatorStatesTypeSupport) New() types.Message {
return NewEstimatorStates()
}
func (t _EstimatorStatesTypeSupport) PrepareMemory() unsafe.Pointer { //returns *C.px4_msgs__msg__EstimatorStates
return (unsafe.Pointer)(C.px4_msgs__msg__EstimatorStates__create())
}
func (t _EstimatorStatesTypeSupport) ReleaseMemory(pointer_to_free unsafe.Pointer) {
C.px4_msgs__msg__EstimatorStates__destroy((*C.px4_msgs__msg__EstimatorStates)(pointer_to_free))
}
func (t _EstimatorStatesTypeSupport) AsCStruct(dst unsafe.Pointer, msg types.Message) {
m := msg.(*EstimatorStates)
mem := (*C.px4_msgs__msg__EstimatorStates)(dst)
mem.timestamp = C.uint64_t(m.Timestamp)
mem.timestamp_sample = C.uint64_t(m.TimestampSample)
cSlice_states := mem.states[:]
primitives.Float32__Array_to_C(*(*[]primitives.CFloat32)(unsafe.Pointer(&cSlice_states)), m.States[:])
mem.n_states = C.uint8_t(m.NStates)
cSlice_covariances := mem.covariances[:]
primitives.Float32__Array_to_C(*(*[]primitives.CFloat32)(unsafe.Pointer(&cSlice_covariances)), m.Covariances[:])
}
func (t _EstimatorStatesTypeSupport) AsGoStruct(msg types.Message, ros2_message_buffer unsafe.Pointer) {
m := msg.(*EstimatorStates)
mem := (*C.px4_msgs__msg__EstimatorStates)(ros2_message_buffer)
m.Timestamp = uint64(mem.timestamp)
m.TimestampSample = uint64(mem.timestamp_sample)
cSlice_states := mem.states[:]
primitives.Float32__Array_to_Go(m.States[:], *(*[]primitives.CFloat32)(unsafe.Pointer(&cSlice_states)))
m.NStates = uint8(mem.n_states)
cSlice_covariances := mem.covariances[:]
primitives.Float32__Array_to_Go(m.Covariances[:], *(*[]primitives.CFloat32)(unsafe.Pointer(&cSlice_covariances)))
}
func (t _EstimatorStatesTypeSupport) TypeSupport() unsafe.Pointer {
return unsafe.Pointer(C.rosidl_typesupport_c__get_message_type_support_handle__px4_msgs__msg__EstimatorStates())
}
type CEstimatorStates = C.px4_msgs__msg__EstimatorStates
type CEstimatorStates__Sequence = C.px4_msgs__msg__EstimatorStates__Sequence
func EstimatorStates__Sequence_to_Go(goSlice *[]EstimatorStates, cSlice CEstimatorStates__Sequence) {
if cSlice.size == 0 {
return
}
*goSlice = make([]EstimatorStates, int64(cSlice.size))
for i := 0; i < int(cSlice.size); i++ {
cIdx := (*C.px4_msgs__msg__EstimatorStates__Sequence)(unsafe.Pointer(
uintptr(unsafe.Pointer(cSlice.data)) + (C.sizeof_struct_px4_msgs__msg__EstimatorStates * uintptr(i)),
))
EstimatorStatesTypeSupport.AsGoStruct(&(*goSlice)[i], unsafe.Pointer(cIdx))
}
}
func EstimatorStates__Sequence_to_C(cSlice *CEstimatorStates__Sequence, goSlice []EstimatorStates) {
if len(goSlice) == 0 {
return
}
cSlice.data = (*C.px4_msgs__msg__EstimatorStates)(C.malloc((C.size_t)(C.sizeof_struct_px4_msgs__msg__EstimatorStates * uintptr(len(goSlice)))))
cSlice.capacity = C.size_t(len(goSlice))
cSlice.size = cSlice.capacity
for i, v := range goSlice {
cIdx := (*C.px4_msgs__msg__EstimatorStates)(unsafe.Pointer(
uintptr(unsafe.Pointer(cSlice.data)) + (C.sizeof_struct_px4_msgs__msg__EstimatorStates * uintptr(i)),
))
EstimatorStatesTypeSupport.AsCStruct(unsafe.Pointer(cIdx), &v)
}
}
func EstimatorStates__Array_to_Go(goSlice []EstimatorStates, cSlice []CEstimatorStates) {
for i := 0; i < len(cSlice); i++ {
EstimatorStatesTypeSupport.AsGoStruct(&goSlice[i], unsafe.Pointer(&cSlice[i]))
}
}
func EstimatorStates__Array_to_C(cSlice []CEstimatorStates, goSlice []EstimatorStates) {
for i := 0; i < len(goSlice); i++ {
EstimatorStatesTypeSupport.AsCStruct(unsafe.Pointer(&cSlice[i]), &goSlice[i])
}
}