C# Класс AForge.Robotics.TeRK.Qwerk.Servos

Provides access to Qwerk's servos' controllers.

The class allows to manipulate Qwerk's servos. The total number of available servos equals to Servos.Count.

Each servo has logical and physical positions, which may or may not be equal. Both positions may vary in the [0, 255] range. Physical and logical positions are equal, when servo's physical moving bound (range) is set to [0, 255] (see SetBound). In this case setting servo's logical position with SetPosition method results in servo's physical moving in the [0, 255] range. However, of physical bound is set to [10, 20], for example, then physically the servo will move only in this range. But logical position is still may be set in [0, 255] range, which is mapped to physical range.

Sample usage:

// get Qwerk's servos service Qwerk.Servos servos = qwerk.GetServosService( ); // stop all servos servos.StopServos( ); // set 0th servo's bounds servos.SetBound( 0, new IntRange( 10, 100 ) ); // set servo's position servos.SetPosition( 0, 50 ); // ... // get 0th servo's position int currentPosition = servos.GetPosition( 0 );
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetBound ( int servo ) : IntRange

Get bounds for the specified servo.

GetBounds ( ) : AForge.IntRange[]

Get bounds of all servos.

GetPosition ( int servo ) : int

Get current position of a single servo.

GetPositions ( ) : int[]

Get current positions of all servos.

Servos ( AForge.Robotics.TeRK.Qwerk qwerk )

Initializes a new instance of the Qwerk.Servos class.

SetBound ( int servo, IntRange bound ) : void

Set bounds for the specified servo.

The method sets servo's physical bounds in which it may move. See documentation to Qwerk.Servos for clarification.

SetBounds ( bool mask, IntRange bounds ) : void

Set bounds for specified servos.

The method sets servos' physical bounds in which they may move. See documentation to Qwerk.Servos for clarification.

SetPosition ( int servo, int position ) : int

Set position of a single servo.

The method sets position of single Qwerk's servo, which index is specified. It is preferred to use SetPositions for setting positions of multiple servos, which does it at once.

SetPositions ( bool mask, int positions ) : int[]

Set positions of specified servos.

The mask and positions arrays specify which Qwerk's servo's state should be updated. If value of the mask array is set to , then corresponding servo's state is changed to the state, which is specified in positions array.

StopServo ( int servo ) : int

Stop specified servo.

StopServos ( ) : int[]

Stop all servos.

StopServos ( bool mask ) : int[]

Stop specified servos.

The mask array specifies which Qwerk's servo need to be stopped. If value of the mask array is set to , then corresponding servo is stopped.

Приватные методы

Метод Описание
CreateCommand ( ) : TeRK.ServoCommand

Описание методов

GetBound() публичный метод

Get bounds for the specified servo.
Invalid servo is specified. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public GetBound ( int servo ) : IntRange
servo int Servo to get bounds for, [0, ).
Результат AForge.IntRange

GetBounds() публичный метод

Get bounds of all servos.
No connection to Qwerk or its service. Connestion to Qwerk is lost.
public GetBounds ( ) : AForge.IntRange[]
Результат AForge.IntRange[]

GetPosition() публичный метод

Get current position of a single servo.
Invalid servo is specified. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public GetPosition ( int servo ) : int
servo int Servo to get position for, [0, ).
Результат int

GetPositions() публичный метод

Get current positions of all servos.
No connection to Qwerk or its service. Connestion to Qwerk is lost.
public GetPositions ( ) : int[]
Результат int[]

Servos() публичный метод

Initializes a new instance of the Qwerk.Servos class.
The passed reference to object is not connected to /// Qwerk board. Failed connecting to the requested service. Failed accessing to the requested service.
public Servos ( AForge.Robotics.TeRK.Qwerk qwerk )
qwerk AForge.Robotics.TeRK.Qwerk Reference to object, which is connected to Qwerk board.

SetBound() публичный метод

Set bounds for the specified servo.

The method sets servo's physical bounds in which it may move. See documentation to Qwerk.Servos for clarification.

Invalid servo is specified. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public SetBound ( int servo, IntRange bound ) : void
servo int Servo to set bounds for, [0, ).
bound AForge.IntRange Bounds to set for the specified servo.
Результат void

SetBounds() публичный метод

Set bounds for specified servos.

The method sets servos' physical bounds in which they may move. See documentation to Qwerk.Servos for clarification.

Incorrect length of , /// or array. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public SetBounds ( bool mask, IntRange bounds ) : void
mask bool Mask array specifying which servos need to be set.
bounds AForge.IntRange Array of servos' bounds. Each bound may be in [0, 255] range.
Результат void

SetPosition() публичный метод

Set position of a single servo.

The method sets position of single Qwerk's servo, which index is specified. It is preferred to use SetPositions for setting positions of multiple servos, which does it at once.

Invalid servo is specified. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public SetPosition ( int servo, int position ) : int
servo int Servo to set position for, [0, ).
position int Position to set for the specified servo, [0, 255].
Результат int

SetPositions() публичный метод

Set positions of specified servos.

The mask and positions arrays specify which Qwerk's servo's state should be updated. If value of the mask array is set to , then corresponding servo's state is changed to the state, which is specified in positions array.

Incorrect length of or /// array. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public SetPositions ( bool mask, int positions ) : int[]
mask bool Mask array specifying which servos need to be set.
positions int Array of servos' positions to set. Each position is in [0, 255] range.
Результат int[]

StopServo() публичный метод

Stop specified servo.
Invalid servo is specified. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public StopServo ( int servo ) : int
servo int Servo to stop, [0, ).
Результат int

StopServos() публичный метод

Stop all servos.
No connection to Qwerk or its service. Connestion to Qwerk is lost.
public StopServos ( ) : int[]
Результат int[]

StopServos() публичный метод

Stop specified servos.

The mask array specifies which Qwerk's servo need to be stopped. If value of the mask array is set to , then corresponding servo is stopped.

Incorrect length of array. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public StopServos ( bool mask ) : int[]
mask bool Mask array specifying which servos need to stop.
Результат int[]