Skip to content

Instantly share code, notes, and snippets.

View mizutori's full-sized avatar

Takamitsu Mizutori mizutori

View GitHub Profile
"trigger": {
"queryPatterns": [
"move ($GoDirection:go_direction)? ($Speed:speed)? for $SchemaOrg_Number:number seconds",
"move ($GoDirection:go_direction)? for $SchemaOrg_Number:number seconds ($Speed:speed)?",
"go ($GoDirection:go_direction)? ($Speed:speed)? for $SchemaOrg_Number:number seconds",
"go ($GoDirection:go_direction)? for $SchemaOrg_Number:number seconds ($Speed:speed)?"
]
}
{
"manifest": {
"displayName": "Moving Google Home",
"invocationName": "Moving Google Home",
"category": "PRODUCTIVITY"
},
"actions": [
{
"name": "com.goldrushcomputing.actions.Move",
"availability": {
/* Battery Consumption */
private BroadcastReceiver batteryInfoReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context ctxt, Intent intent) {
int batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
float batteryLevelScaled = batteryLevel / (float)scale;
/* Kalman Filter */
float Qvalue;
long locationTimeInMillis = (long)(location.getElapsedRealtimeNanos() / 1000000);
long elapsedTimeInMillis = locationTimeInMillis - runStartTimeInMillis;
if(currentSpeed == 0.0f){
Qvalue = 3.0f; //3 meters per second
}else{
Qvalue = currentSpeed; // meters per second
private long getLocationAge(Location newLocation){
long locationAge;
if(android.os.Build.VERSION.SDK_INT >= 17) {
long currentTimeInMilli = (long)(SystemClock.elapsedRealtimeNanos() / 1000000);
long locationTimeInMilli = (long)(newLocation.getElapsedRealtimeNanos() / 1000000);
locationAge = currentTimeInMilli - locationTimeInMilli;
}else{
locationAge = System.currentTimeMillis() - newLocation.getTime();
}
return locationAge;
private boolean filterAndAddLocation(Location location){
long age = getLocationAge(location);
if(age > 10 * 1000){ //more than 10 seconds
Log.d(TAG, "Location is old");
oldLocationList.add(location);
return false;
}
public void onLocationChanged(final Location newLocation) {
Log.d(TAG, "(" + newLocation.getLatitude() + "," + newLocation.getLongitude() + ")");
gpsCount++;
if(isLogging){
//locationList.add(newLocation);
filterAndAddLocation(newLocation);
}
private void zoomMapTo(Location location) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
try {
map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17.5f));
} catch (Exception e) {
e.printStackTrace();
}
}
private void addPolyline() {
ArrayList<Location> locationList = locationService.locationList;
if (locationList.size() == 2) {
Location fromLocation = locationList.get(0);
Location toLocation = locationList.get(1);
LatLng from = new LatLng(((fromLocation.getLatitude())),
((fromLocation.getLongitude())));
@Override
public void onLocationChanged(final Location newLocation) {
Log.d(TAG, "(" + newLocation.getLatitude() + "," + newLocation.getLongitude() + ")");
if(isLogging){
locationList.add(newLocation);
}
Intent intent = new Intent("LocationUpdated");
intent.putExtra("location", newLocation);