Recording vehicle change is working

This commit is contained in:
Piv
2020-04-25 16:29:12 +09:30
parent 1d2253dd18
commit b633fdea95
5 changed files with 39 additions and 12 deletions

View File

@@ -104,22 +104,23 @@ public class SimpleController extends AppCompatActivity implements SeekBar.OnSee
public void saveRecording(View view) {
grpcController.saveRecording();
}
public void record(View view) {
grpcController.record(recordSwitch.isSelected());
grpcController.record(recordSwitch.isChecked());
}
public void recordLidar(View view) {
StreamObserver<Empty> response = new StreamObserver<Empty>() {
@Override
public void onNext(Empty value) {
Toast.makeText(getApplicationContext(), "Started Recording Lidar", Toast.LENGTH_SHORT);
Toast.makeText(getApplicationContext(), "Started Recording Lidar", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Throwable t) {
Toast.makeText(getApplicationContext(), "Failed to set lidar recording", Toast.LENGTH_SHORT);
Toast.makeText(getApplicationContext(), "Failed to set lidar recording", Toast.LENGTH_SHORT).show();
}
@Override

View File

@@ -7,14 +7,17 @@
tools:context=".LIDAR.LidarTrackingController">
<org.vato.carcontroller.LIDAR.LidarView
android:id="@+id/lidarMap"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lidarMap"/>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="-45dp" />
<ImageView
android:id="@+id/imageView"
android:layout_width="37dp"
android:layout_height="21dp"
android:layout_width="96dp"
android:layout_height="89dp"
android:rotation="270"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
@@ -23,5 +26,13 @@
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_car" />
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -39,8 +39,10 @@ class VehicleRecordingDecorator:
return self._recording
@record.setter
def record(self, value):
self._recording = True
def record(self, value: bool):
if not value:
self._records = []
self._recording = value
@property
def throttle(self):
@@ -49,7 +51,8 @@ class VehicleRecordingDecorator:
@throttle.setter
def throttle(self, value):
if self._recording:
self._records.append(('t', value, str(datetime.datetime.now())))
self._records.append(
't,' + str(value) + ',' + datetime.datetime.now().isoformat(sep=' ', timespec='seconds'))
self._vehicle.throttle = value
@property
@@ -59,7 +62,8 @@ class VehicleRecordingDecorator:
@steering.setter
def steering(self, value):
if self._recording:
self._records.append(('s', value, str(datetime.datetime.now())))
self._records.append(
's,' + str(value) + ',' + datetime.datetime.now().isoformat(sep=' ', timespec='seconds'))
self._vehicle.steering = value
@property

View File

@@ -43,7 +43,16 @@ class LidarServicer(PersonTrackingServicer):
return empty.Empty()
def record(self, request, context):
self._lidar.record = True
# TODO: Fix this to not require
if request.value:
self.cache.start_cache()
else:
self.cache.stop_scanning()
self._lidar.record = request.value
return empty.Empty()
def save_lidar(self, request, context):
self._lidar.save_data(request.file)
return empty.Empty()
def onGroupsChanged(self, message):

View File

@@ -8,6 +8,7 @@ option java_outer_classname = "PersonTrackingProto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "car/control/motorService.proto";
message Int32Value{
int32 value = 1;
@@ -24,7 +25,6 @@ message PointScan{
}
service PersonTracking{
rpc set_tracking_group(Int32Value) returns (google.protobuf.Empty) {}
@@ -34,4 +34,6 @@ service PersonTracking{
rpc record(google.protobuf.BoolValue) returns (google.protobuf.Empty) {}
rpc save_lidar(MotorControl.SaveRequest) returns (google.protobuf.Empty) {}
}