Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions sensors/robotics/sensorhub-driver-puppypi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# [NAME]

Sensor adapter for [NAME].

## Configuration

Configuring the sensor requires:
Select ```Sensors``` from the left hand accordion control and right click for context sensitive menu in accordion control
- **Module Name:** A name for the instance of the driver
- **Serial Number:** The platforms serial number, or a unique identifier
- **Auto Start:** Check the box to start this module when OSH node is launched

Storage:
Select ```Storage``` from the left hand accordion control and right click for context sensitive menu in accordion control
Use a ```Real-Time Stream Storage Module``` providing the sensor module as the
- **Data Source ID:** Select the identifier for the storage module create in configuring sensor step,
use looking glass to select it from list of know sensor modules
- **Auto Start:** Check the box to start this module when OSH node is launched
- **Process Events:** Check the box if you want events to be stored as new records.

And then configure the
- **Storage Config** using a ```Perst Record Storage``` instance providing the
- **Storage Path** as the location where the OSH records are to be stored.

SOS Service:
Select ```Services``` from the left hand accordion control, then Offerings, then the **+**
symbol to add a new offering.
Provide the following:
- **Name:** A name for the offering
- **Description:** A description of the offering
- **StorageId:** Select the identifier for the storage module create in previous step,
use looking glass to select it from list of know storage modules
- **SensorId:** Select the identifier for the storage module create in configuring sensor step,
use looking glass to select it from list of know sensor modules
- **Enable:** Check the box to enable this offering

## Sample Requests

The following are a list of example requests and their respective responses.
The **IP ADDRESS** and **PORT** will need to be specified and point to the instance
of the OpenSensorHub node serving the data.

### [Observed Property] Request
- **HTTP**
- http://[IP ADDRESS]:[PORT]/sensorhub/sos?service=SOS&version=2.0&request=GetResult&offering=[URN]&observedProperty=[OBSERVED_PROPERTY]&temporalFilter=phenomenonTime,[START_TIME]/[END_TIME]&replaySpeed=1&responseFormat=application/json

Response:
```

```
38 changes: 38 additions & 0 deletions sensors/robotics/sensorhub-driver-puppypi/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
description = 'Puppy Pi Driver'
ext.details = "Driver for Puppy Pi outputs and controls"
version = '1.0.0'

dependencies {
implementation 'org.sensorhub:sensorhub-core:' + oshCoreVersion
// implementation project(':sensorhub-service-video')
testImplementation('junit:junit:4.13.1')
implementation project(':sensorhub-driver-videocam')
}

// exclude tests requiring connection to the sensor
// these have to be run manually
// If tests are to be excluded list them here as follows
// exclude '**/TestNameClass.class'
test {
useJUnit()
}

// add info to OSGi manifest
osgi {
manifest {
attributes ('Bundle-Vendor': 'Botts Inc')
attributes ('Bundle-Activator': 'com.sample.impl.sensor.puppypi.Activator')
}
}

// add info to maven pom
ext.pom >>= {
developers {
developer {
id 'pkhaisman'
name 'Philip Khaisman'
organization 'Botts Innovative Research, Inc.'
organizationUrl 'http://www.botts-inc.com'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sample.impl.sensor.puppypi;

import org.sensorhub.utils.OshBundleActivator;

public class Activator extends OshBundleActivator {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2020-2021 Botts Innovative Research, Inc. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/
package com.sample.impl.sensor.puppypi;

import org.sensorhub.api.config.DisplayInfo;
import org.sensorhub.api.sensor.SensorConfig;

/**
* Configuration settings for the {@link Sensor} driver exposed via the OpenSensorHub Admin panel.
* <p>
* Configuration settings take the form of
* <code>
* DisplayInfo(desc="Description of configuration field to show in UI")
* public Type configOption;
* </code>
* <p>
* Containing an annotation describing the setting and if applicable its range of values
* as well as a public access variable of the given Type
*
* @author your_name
* @since date
*/
public class Config extends SensorConfig {

/**
* The unique identifier for the configured sensor (or sensor platform).
*/
@DisplayInfo.Required
@DisplayInfo(desc = "Serial number or unique identifier")
public String serialNumber = "sensor001";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2020-2021 Botts Innovative Research, Inc. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/
package com.sample.impl.sensor.puppypi;

import org.sensorhub.api.module.IModule;
import org.sensorhub.api.module.IModuleProvider;
import org.sensorhub.api.module.ModuleConfig;
import org.sensorhub.impl.module.JarModuleProvider;

/**
* Descriptor classes provide access to informative data on the OpenSensorHub driver
*
* @author your_name
* @since date
*/
public class Descriptor extends JarModuleProvider implements IModuleProvider {

/**
* Retrieves the class implementing the OpenSensorHub interface necessary to
* perform SOS/SPS/SOS-T operations.
*
* @return The class used to interact with the sensor/sensor platform.
*/
public Class<? extends IModule<?>> getModuleClass() {

return Sensor.class;
}

/**
* Identifies the class used to configure this driver
*
* @return The java class used to exposing configuration settings for the driver.
*/
public Class<? extends ModuleConfig> getModuleConfigClass() {

return Config.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2020-2021 Botts Innovative Research, Inc. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/
package com.sample.impl.sensor.puppypi;

import com.sample.impl.sensor.puppypi.controls.MovementControl;
import com.sample.impl.sensor.puppypi.outputs.BatteryOutput;
import com.sample.impl.sensor.puppypi.outputs.PositionOutput;
import com.sample.impl.sensor.puppypi.outputs.VideoOutput;
import org.sensorhub.api.common.SensorHubException;
import org.sensorhub.impl.sensor.AbstractSensorModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Sensor driver providing sensor description, output registration, initialization and shutdown of driver and outputs.
*
* @author your_name
* @since date
*/
public class Sensor extends AbstractSensorModule<Config> {

private static final Logger logger = LoggerFactory.getLogger(Sensor.class);

BatteryOutput batteryOutput;
VideoOutput videoOutput;
PositionOutput positionOutput;
MovementControl movementControl;

@Override
public void doInit() throws SensorHubException {

super.doInit();

// Generate identifiers
// generateUniqueID("[URN]", config.serialNumber);
this.uniqueID = "urn:osh:sensor:puppypi"; // todo change to include serial number
generateXmlID("[XML-PREFIX]", config.serialNumber);

// Outputs
batteryOutput = new BatteryOutput(this);
videoOutput = new VideoOutput(this);
positionOutput = new PositionOutput(this);

addOutput(batteryOutput, false);
addOutput(videoOutput, false);
addOutput(positionOutput, false);

batteryOutput.doInit();
videoOutput.doInit();
positionOutput.doInit();

// Control streams
// movementControl = new MovementControl(this);
// addControlInput(movementControl);
// movementControl.doInit();
}

@Override
public void doStart() throws SensorHubException {

if (null != batteryOutput) {

// Allocate necessary resources and start outputs
// batteryOutput.doStart();
}

// TODO: Perform other startup procedures
}

@Override
public void doStop() throws SensorHubException {

if (null != batteryOutput) {

// batteryOutput.doStop();
}

// TODO: Perform other shutdown procedures
}

@Override
public boolean isConnected() {

// Determine if sensor is connected
// return batteryOutput.isAlive();
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/***************************** BEGIN LICENSE BLOCK ***************************
The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer is Botts Innovative Research Inc. Portions created by the Initial
Developer are Copyright (C) 2014 the Initial Developer. All Rights Reserved.
******************************* END LICENSE BLOCK ***************************/

package com.sample.impl.sensor.puppypi.controls;

import net.opengis.swe.v20.*;
import org.sensorhub.impl.sensor.AbstractSensorControl;
import org.sensorhub.api.command.CommandException;
import org.vast.swe.SWEConstants;
import org.vast.swe.SWEHelper;
import com.sample.impl.sensor.puppypi.Sensor;
import org.vast.swe.helper.GeoPosHelper;


public class MovementControl extends AbstractSensorControl<Sensor> {
private static final String SENSOR_CONTROL_NAME = "Puppy Pi Control";
private static final String SENSOR_CONTROL_LABEL = "puppy pi control";
private static final String SENSOR_CONTROL_DESCRIPTION = "Controls movement of the puppy pi";

DataComponent commandStruct;

public MovementControl(Sensor parentSensor) {
super("MovementControl", parentSensor);
}


@Override
public DataComponent getCommandDescription() {
return commandStruct;
}


public void doInit() {
GeoPosHelper sweFactory = new GeoPosHelper();

commandStruct = sweFactory.createVelocityVector("m/s")
.name("velocity")
.label("Velocity")
.definition(SWEHelper.getPropertyUri("PlatformVelocity"))
.description("xxx")
.refFrame(SWEConstants.REF_FRAME_ENU)
.build();
}

@Override
protected boolean execCommand(DataBlock command) {
DataComponent commandData = commandStruct.copy();
commandData.setData(command);

return true;
}
}
Loading
Loading