oDistance Object

Back to top of pageDescription:
 The oDistance Object manages a signed 8-Bit variable intended to be used as a URCP Distance value and that can be used in a virtual circuit.  As well as the value of the variable, status properties are also provided that can be used in a virtual circuit.

The oDistance Object has properties and methods that support the URCP Distance value.

URCP Distance values deal with Distances, Lengths, Proximities.  The common numbering system chosen for this is 64 steps per foot.  256 steps over a 4 foot range is used so that a single byte can represent a "Personal space" of 4 feet for a robot.  This gives a resolution down to better than one fifth of an inch or about one half of a centimeter.

The oDistance2 Object is composed of two bytes.  The second byte represents an extension to the first and can indicated distances of up to 512 feet.

Objects such as the oSonarDV and the oIRRange use URCP Distance values.

There are three main differences between this object and a standard Char variable. 

  1. This Object's Value property is an instance of the oValue Object which can be pointed to by a Virtual Circuit. 
  2. This Object maintains status bits which can be pointed to by Virtual Circuits.
  3. This Object is 1 byte larger in order to store the status information.
 The following table lists the size and availability of the oDistance Object.
 ObjectSizeDescriptionA1A2B1B2C1
oDistance2 BytesAn Object that manages a URCP distance value.xxx
oDistance23 BytesAn Object that manages a URCP distance value.xxx
Back to top of pageOperation:
 An oDistance Object variable stores a signed 8 or 16 Bit value in its Value property and maintains other values that represent the status of those 8 bits.

The Negative property indicates the Most-Significant-Bit of the value which is used to indicate when the value is a negative number.

The NonZero Property indicates if the value is not zero.

Back to top of pageProperties:

The following table lists the properties of the oDistance Object:

Property

Description

Value
The distance value.
Object Class: oValue Value Range: -32,768 to +32,767  or  -128 to -127
Data Type: Numeric Default Value: 0
ValueDescription
0No distance
32 
641 foot forward
96 
1272 feet forward
Negative
A value that indicates the Value property is less than zero.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Notes on virtual circuit usage: Not all implementations of the oDistance Object have a linkable Negative property.  While all instance of the oDistance Object that you create in your programs will have a linkable Negative property,  some of the ooPIC Objects create a custom oDistance Object instance that cannot.
NegativeDescription
0

The Value property is a Positive value.

1

The Value property is Negative Value.

NonZero
A value that indicates the Value property is more than or less than zero.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Notes on virtual circuit usage: Not all implementations of the oDistance Object have a linkable NonZero property.  While all instance of the oDistance Object that you create in your programs will have a linkable NonZero property,  some of the ooPIC Objects create a custom oDistance Object instance that cannot. 
NonZeroConstantDescription
0cvFalse

The Value property is zero.

1cvTrue

The Value property is not zero.

Data
The data for the Value property.
Object Class: oVar1 Value Range: 0 - 255
Data Type: Numeric Default Value: 0
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of pageExample:

The following examples use the oDistance Object as implemented in the oSonarDV object.
Visual Basic SyntaxC and Java Syntax
'This program reads an oSonarDV
'Object and outputs the distance
'on Scott Edwards LCD.

Dim A As New oSonarDV
Dim D As New oLCDSE

Sub Main()
  A.IOLineE = 31
  A.IOLineP = 30
  A.Operate = 1  
  D.IOLine = 16 
  Do  
    A.Operate.Pulse(1,1,250)
    D.Clear
    D.VString = Str$(A.Distance/64)
  Loop  
End Sub 
// This program reads an oSonarDV
// Object and outputs the distance
// on Scott Edwards LCD.

oSonarDV A = New oSonarDV;
oLCDSE D = New oLCDSE;

Void Main(Void){
  A.IOLineE = 31;
  A.IOLineP = 30;
  A.Operate = 1;
  D.IOLine = 16;
  Do{
    A.Operate.Pulse(1,1,250);
    D.Clear;
    D.VString = Str$(A.Distance/64)
  } While (1);
}
Basic Syntax 
'This program reads an oSonarDV
'Object and outputs the distance
'on Scott Edwards LCD.

A As oSonarDV(31,30,cvOn)
D As oLCDSE(16)

Do  
  A.Operate.Pulse(1,1,250)
  D.Clear
  D.VString = Str$(A.Distance/64)
Loop
 

Back to top of pageRelated Items:

 The following table lists objects that use the oDistance Object.
 ObjectDescriptionA1A2B1B2C1
oIRRangeReads a Sharp GP2D12 IR ranging module.xxx
oSonarDVReads a Devantech SRF04 Ultrasonic Range Finder.xxx
oSonarPLReads a Polaroid 6500 sonar ranging module.xxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oHeadingManages a URCP Heading value.xxx
oPowerManages a URCP Power value.xxx
Back to top of pageVersion History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.