FIx Slam protos

This commit is contained in:
Piv
2020-02-05 22:16:23 +10:30
parent 89a7572fde
commit 2c8f61e8a6
7 changed files with 35 additions and 18 deletions

View File

@@ -41,7 +41,6 @@ protobuf {
} }
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

View File

@@ -33,7 +33,6 @@ public class LidarView extends SurfaceView implements Runnable {
@Override @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) { protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh);
} }
@Override @Override

View File

@@ -7,6 +7,9 @@ import android.view.SurfaceView;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import com.example.carcontroller.SlamScan;
import com.google.protobuf.InvalidProtocolBufferException;
import org.zeromq.SocketType; import org.zeromq.SocketType;
import org.zeromq.ZContext; import org.zeromq.ZContext;
import org.zeromq.ZMQ; import org.zeromq.ZMQ;
@@ -43,17 +46,23 @@ public class SlamView extends SurfaceView implements Runnable {
@Override @Override
public void run() { public void run() {
// Receive map from zmq and update appropriately. // Receive map from zmq and update appropriately.
try (ZMQ.Socket socket = context.createSocket(SocketType.SUB)) { try (ZMQ.Socket socket = context.createSocket(SocketType.PAIR)) {
socket.connect("tcp://" + host + ":" + port); socket.connect("tcp://" + host + ":" + port);
socket.send("Hi");
while (!Thread.currentThread().isInterrupted()) { while (!Thread.currentThread().isInterrupted()) {
byte[] map = socket.recv(); byte[] map = socket.recv();
SlamScan scan = SlamScan.parseFrom(map);
for (Byte b : scan.getMap()) {
}
} }
} catch (InvalidProtocolBufferException e) {
System.out.println("Invalid map found");
} }
} }
public void stop(){ public void stop() {
// Use grpc to tell the loader to stop. Interrupt the loader thread as well. // Use grpc to tell the loader to stop. Interrupt the loader thread as well.
mapThread.interrupt(); mapThread.interrupt();
} }

View File

@@ -0,0 +1,11 @@
syntax = "proto3";
package persontracking;
option java_multiple_files = true;
option java_package = "com.example.carcontroller";
option java_outer_classname = "EmptyProto";
message Empty{
}

View File

@@ -1,5 +1,11 @@
syntax = "proto3"; syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.example.carcontroller";
option java_outer_classname = "SlamControllerProto";
import "Empty.proto";
message SlamDetails { message SlamDetails {
int32 map_size_pixels = 1; int32 map_size_pixels = 1;
int32 map_size_meters = 2; int32 map_size_meters = 2;
@@ -20,12 +26,8 @@ message SlamScan{
SlamLocation location = 2; SlamLocation location = 2;
} }
message Empty{
}
service SlamControl { service SlamControl {
rpc start_map_streaming(SlamDetails) returns (Empty) {} rpc start_map_streaming(SlamDetails) returns (persontracking.Empty) {}
rpc stop_streaming(Empty) returns (Empty) {} rpc stop_streaming(persontracking.Empty) returns (persontracking.Empty) {}
} }

View File

@@ -6,15 +6,12 @@ option java_multiple_files = true;
option java_package = "com.example.carcontroller"; option java_package = "com.example.carcontroller";
option java_outer_classname = "PersonTrackingProto"; option java_outer_classname = "PersonTrackingProto";
import "Empty.proto";
message Int32Value{ message Int32Value{
int32 value = 1; int32 value = 1;
} }
message Empty{
}
message Point{ message Point{
double angle = 1; double angle = 1;
int32 distance = 2; int32 distance = 2;
@@ -26,9 +23,9 @@ message PointScan{
} }
service PersonTracking{ service PersonTracking{
rpc set_tracking_group(Int32Value) returns (Empty) {} rpc set_tracking_group(Int32Value) returns (persontracking.Empty) {}
rpc stop_tracking(Empty) returns (Empty) {} rpc stop_tracking(persontracking.Empty) returns (persontracking.Empty) {}
rpc get_scan_data(Empty) returns (PointScan) {} rpc get_scan_data(persontracking.Empty) returns (PointScan) {}
} }

View File

@@ -6,7 +6,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong