renamed format.go to sensordata.go
This commit is contained in:
parent
79325d9209
commit
f5f98ced5b
@ -9,19 +9,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*{
|
|
||||||
"smartphone": {
|
|
||||||
// hier daten von hyperimu
|
|
||||||
},
|
|
||||||
"serial": {
|
|
||||||
// hier Daten von M8U:
|
|
||||||
"timestamp": 37539672354
|
|
||||||
"position": [0, 0, 0],
|
|
||||||
"orientation": [0, 0, 0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
type sourceId string
|
type sourceId string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -81,7 +68,7 @@ func (s Sensordata) Consolidate2(n Sensordata) Sensordata {
|
|||||||
if n.Position == null.Position {
|
if n.Position == null.Position {
|
||||||
n.Position = s.Position
|
n.Position = s.Position
|
||||||
}
|
}
|
||||||
if n.Orientation == null.Orientation{
|
if n.Orientation == null.Orientation {
|
||||||
n.Orientation = s.Orientation
|
n.Orientation = s.Orientation
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
@ -144,10 +131,10 @@ func convertIPhoneSensorLog(jsonData []byte) (*Sensordata, error) {
|
|||||||
roll := gjson.Get(string(jsonData), "motionRoll").Float() * 180 / math.Pi
|
roll := gjson.Get(string(jsonData), "motionRoll").Float() * 180 / math.Pi
|
||||||
yaw := gjson.Get(string(jsonData), "motionYaw").Float() * 180 / math.Pi
|
yaw := gjson.Get(string(jsonData), "motionYaw").Float() * 180 / math.Pi
|
||||||
sd := &Sensordata{
|
sd := &Sensordata{
|
||||||
SourceId: SOURCE_TCP,
|
SourceId: SOURCE_TCP,
|
||||||
Timestamp: int64(timestamp * float64(time.Second)),
|
Timestamp: int64(timestamp * float64(time.Second)),
|
||||||
//Timestamp: time.Unix(0, prep.Timestamp * int64(time.Millisecond)),
|
//Timestamp: time.Unix(0, prep.Timestamp * int64(time.Millisecond)),
|
||||||
Position: [3]float64{lat, lon, alt},
|
Position: [3]float64{lat, lon, alt},
|
||||||
Orientation: [3]float64{pitch, roll, yaw},
|
Orientation: [3]float64{pitch, roll, yaw},
|
||||||
}
|
}
|
||||||
//log.Println(string(pretty.Pretty(jsonData)))
|
//log.Println(string(pretty.Pretty(jsonData)))
|
||||||
@ -155,7 +142,6 @@ func convertIPhoneSensorLog(jsonData []byte) (*Sensordata, error) {
|
|||||||
return sd, nil
|
return sd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func convertAndroidHyperImu(jsonData []byte) (*Sensordata, error) {
|
func convertAndroidHyperImu(jsonData []byte) (*Sensordata, error) {
|
||||||
timestamp := gjson.Get(string(jsonData), "Timestamp").Int()
|
timestamp := gjson.Get(string(jsonData), "Timestamp").Int()
|
||||||
lat := gjson.Get(string(jsonData), "GPS.0").Float()
|
lat := gjson.Get(string(jsonData), "GPS.0").Float()
|
||||||
@ -166,10 +152,10 @@ func convertAndroidHyperImu(jsonData []byte) (*Sensordata, error) {
|
|||||||
yaw := gjson.Get(string(jsonData), "orientation.2").Float()
|
yaw := gjson.Get(string(jsonData), "orientation.2").Float()
|
||||||
|
|
||||||
sd := &Sensordata{
|
sd := &Sensordata{
|
||||||
SourceId: SOURCE_TCP,
|
SourceId: SOURCE_TCP,
|
||||||
Timestamp: timestamp * int64(time.Millisecond),
|
Timestamp: timestamp * int64(time.Millisecond),
|
||||||
//Timestamp: time.Unix(0, prep.Timestamp * int64(time.Millisecond)),
|
//Timestamp: time.Unix(0, prep.Timestamp * int64(time.Millisecond)),
|
||||||
Position: [3]float64{lat, lon, alt},
|
Position: [3]float64{lat, lon, alt},
|
||||||
Orientation: [3]float64{pitch, roll, yaw},
|
Orientation: [3]float64{pitch, roll, yaw},
|
||||||
}
|
}
|
||||||
return sd, nil
|
return sd, nil
|
||||||
Loading…
Reference in New Issue
Block a user