Braiteoir Gyro#

Réamhrá#

Úsáidtear an rang gyro chun treo agus gluaiseacht rothlach an róbait a thomhas, rud a ligeann dó treoshuíomh a rianú le himeacht ama.

Tógálaí Ranga#

gyro(
  triport::port &port);

Scriostóir Ranga#

Scriosann sé an réad gyro agus scaoileann sé acmhainní gaolmhara.

virtual ~gyro();

Paraiméadair#

Paraiméadar

Cineál

Cur síos

port

triport::port &

An Port 3-Sreang a bhfuil an Braiteoir Gyro ceangailte leis, scríofa mar Brain.ThreeWirePort.X nó ExpanderName.X, áit a seasann X do litir an phoirt (mar shampla, Brain.ThreeWirePort.A nó Expander1.A).

Sampla#

// Create a gyro instance in Port A
gyro GyroA = gyro(Brain.ThreeWirePort.A);

Feidhmeanna na mBall#

Áirítear leis an rang gyro na feidhmeanna ball seo a leanas:

  • calibrate — Calabraíonn sé an gyro le haghaidh rianú treorach cobhsaí.

  • setHeading — Socraíonn sé seo treo an ghiro.

  • setRotation — Socraíonn sé luach rothlaithe reatha an ghiro.

  • heading — Tugann sé seo ceannteideal an ghiro ar ais.

  • rotation — Tugann sé seo rothlú an ghiro ar ais.

Sula nglaotar ar aon fheidhmeanna gyro ball, ní mór sampla gyro a chruthú, mar a thaispeántar thíos:

/* This constructor is required when using VS Code.
Gyro Sensor configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create a gyro instance in Port A
gyro GyroA = gyro(Brain.ThreeWirePort.A);

calibrate#

Calabraíonn sé an Braiteoir Gyro.

Available Functions
void calibrate(
  int32_t value = 0 );

Parameters

Paraiméadair

Cineál

Cur síos

value

int32_t

An t-am i soicindí a chaithfear ag calabrú. Is é 0 an réamhshocrú.

Return Values

Ní thugann an fheidhm seo luach ar ais.

Notes
  • Níor cheart glaoch ar calibrate ach amháin nuair nach bhfuil an braiteoir ag bogadh.

Examples
// Start calibration with the calibration time set to 3 seconds.
GyroA.calibrate(3);

setHeading#

Socraíonn sé treo an Braiteora Gyro go luach sonrach.

Available Functions
void setHeading(
  double        value,
  rotationUnits units );

Paraiméadair

Cineál

Cur síos

value

double

An luach le húsáid don cheannteideal nua.

units

rotationUnits

An t-aonad a léiríonn an treo:

  • degrees
  • turns
Return Values

Ní thugann an fheidhm seo luach ar ais.

setRotation#

Socraíonn sé rothlú an Braiteora Gyro go luach sonrach.

Available Functions
void setRotation(
  double        value,
  rotationUnits units );

Parameters

Paraiméadair

Cineál

Cur síos

value

double

An luach le húsáid don luach rothlaithe nua.

units

rotationUnits

An t-aonad a léiríonn luach an rothlaithe:

  • degrees
  • turns
Return Values

Ní thugann an fheidhm seo luach ar ais.

heading#

Tugann sé seo treo reatha an Braiteora Gyro ar ais.

Available Functions
double heading(
  rotationUnits units = degrees );

Parameters

Paraiméadar

Cineál

Cur síos

units

rotationUnits

An t-aonad a léiríonn an treo:

  • degrees (réamhshocraithe)
  • turns
Return Values

Tugann sé double ar ais a léiríonn treo reatha an Braiteora Gyro sna haonaid shonraithe, ag socrú degrees mar réamhshocrú.

Examples
// Get the current heading for the Gyro.
double value = GyroA.heading();
Brain.Screen.print(value);

rotation#

Tugann sé rothlú reatha an Braiteora Gyro ar ais.

Available Functions
double rotation(
  rotationUnits units = degrees );

Parameters

Paraiméadar

Cineál

Cur síos

units

rotationUnits

An t-aonad a léiríonn an luach rothlaithe:

  • degrees (réamhshocraithe)
  • turns
Return Values

Tugann sé double ar ais a léiríonn luach rothlaithe reatha an Braiteora Gyro sna haonaid shonraithe, ag socrú degrees mar réamhshocrú.

Examples
// Get the current rotation for the Gyro.
double value = GyroA.rotation();
Brain.Screen.print(value);