Skip to content

Commit

Permalink
Update data structure to align with new message format
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Larssor authored and odsod committed Sep 8, 2019
1 parent ee27c17 commit 356b599
Show file tree
Hide file tree
Showing 11 changed files with 1,274 additions and 5,090 deletions.
18 changes: 9 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ type UDPConn interface {

// Client is a VLP-16 client.
type Client struct {
conn UDPConn
senderAddr *net.UDPAddr
buf [lengthOfPacket]byte
packet Packet
sphericalPointCloud SphericalPointCloud
conn UDPConn
senderAddr *net.UDPAddr
buf [lengthOfPacket]byte
packet Packet
pointCloud PointCloud
}

// NewClient returns a new VLP-16 client with the provided UDP connection.
Expand All @@ -44,7 +44,7 @@ func (c *Client) Receive(ctx context.Context) error {
return xerrors.Errorf("VLP-16 client: receive: unexpected packet length: %d (expected %d)", n, lengthOfPacket)
}
c.packet.unmarshal(&c.buf)
c.sphericalPointCloud.UnmarshalPacket(&c.packet)
c.pointCloud.UnmarshalPacket(&c.packet)
return nil
}

Expand All @@ -63,9 +63,9 @@ func (c *Client) Packet() *Packet {
return &c.packet
}

// Packet returns the last received VLP-16 packet decoded as a spherical point cloud.
func (c *Client) SphericalPointCloud() *SphericalPointCloud {
return &c.sphericalPointCloud
// PointCloud returns the point cloud representation of the last received packet.
func (c *Client) PointCloud() *PointCloud {
return &c.pointCloud
}

// Close the client's underlying UDP connection.
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ func TestClient_Receive(t *testing.T) {
require.NoError(t, client.Receive(ctx))
require.Equal(t, exampleData, client.RawPacket())
require.Equal(t, examplePacket(), client.Packet())
require.Equal(t, exampleSphericalPointCloud(), client.SphericalPointCloud())
requirePointCloudEqual(t, exampleSphericalPointCloud(), client.PointCloud())
}
Loading

0 comments on commit 356b599

Please sign in to comment.