Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose

Easily implement an Arcade style drive for a mobile robot.

When to use

If you have an Arcade styled drive system configuration, where a signal controls forward/backward motion and another one controls the rotation.

Where to use

In the void loop() part of your .ino file, since it’s a one time calculation that needs to be re-executed at short intervals.

Note

This function requires the use of the following functions at some point of your .ino file in order to work properly:

Returns

This function does not return a value once it has completed its tasks.

Main prototype and parameters

Objectif

Facilement ajouter un contôle style « arcade » à votre base de robot.

Quand l’utiliser

Si vous avez une base de robot en configuration « arcade », où un signal contrôle le mouvement avant/arrière et un second la rotation.

Où l’utiliser

Dans la section void loop() de votre fichier .ino, puisqu’il faut qu’elle soit appelée en boucle le plus rapidement possible.

Note

Cette fonction requiert l’utilisation des fonctions suivantes dans votre programme:

Valeur de retour

Cette fonction ne retourne aucune valeur après avoir exécuté ses tâches.

Prototype principal

static void CrcLib::MoveArcade(int8_t forwardChannel, int8_t yawChannel, unsigned char frontLeftMotor, unsigned char backLeftMotor, unsigned char frontRightMotor, unsigned char backRightMotor)

The following parameters must be passed to the function for it to work properlyLes paramètres suivants sont requis par la fonction:

  • forwardChannel: The speed value used to control the forward/backward motion. Must be of the La vitesse à laquelle le robot devrait avancer/reculer. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • yawChannel: The speed value used to control rotative motion. Must be of the La vitesse à laquelle robot devrait tourner. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • frontLeftMotor: The name of the PWM pin to wich is connected the front left motor. Must be of the type unsigned charLe port PWM auquel est connecté le moteur avant gauche.

  • backLeftMotor: The name of the PWM pin to wich is connected the back left motor. Must be of the type unsigned charLe port PWM auquel est connecté le moteur arrière gauche.

  • frontRightMotor: The name of the PWM pin to wich is connected the front right motor. Must be of the type unsigned char.

  • backRightMotor:The name of the PWM pin to wich is connected the back right motor. Must be of the type unsigned char.

Overloads

#1: Using only one motor per side
  • Le port PWM auquel est connecté le moteur avant droit.

  • backRightMotor: Le port PWM auquel est connecté le moteur arrière droit.

Overloads

#1: Un seul moteur par côté

static void CrcLib::MoveArcade(int8_t forwardChannel, int8_t yawChannel, unsigned char leftMotor, unsigned char rightMotor)

The following parameters must be passed to the function for it to work properlyLes paramètres suivants sont requis par la fonction:

  • forwardChannel: The speed value used to control the forward/backward motion. Must be of the La vitesse à laquelle le robot devrait avancer/reculer. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • yawChannel: The speed value used to control rotative motion. Must be of the La vitesse à laquelle robot devrait tourner. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • leftMotor.The name of the PWM pin to wich is connected the left motor. Must be of the type unsigned char.

  • rightMotor: The name of the PWM pin to wich is connected the right motor. Must be of the type unsigned char.

#2: Directly using remote controller joystick values, with 2 motors per side
  • : Le port PWM auquel est connecté le moteur gauche.

  • rightMotor: Le port PWM auquel est connecté le moteur droit.

#2: Utiliser directement les valeurs de la manettes, 2 moteurs par côté

static void CrcLib::MoveArcade(ANALOG forwardChannel, ANALOG yawChannel, unsigned char frontLeftMotor, unsigned char backLeftMotor, unsigned char frontRightMotor, unsigned char backRightMotor)

The following parameters must be passed to the function for it to work properly:

  • forwardChannel: The speed value used to control the forward/backward motion. Must be of the type ANALOG.

  • yawChannel: The speed value used to control rotative motion. Must be of the type ANALOG.

  • frontLeftMotor: The name of the PWM pin to wich is connected the front left motor. Must be of the type unsigned char.

  • backLeftMotor:The name of the PWM pin to wich is connected the back left motor. Must be of the type unsigned char.

  • frontRightMotor: The name of the PWM pin to wich is connected the front right motor. Must be of the type unsigned char.

  • backRightMotor:The name of the PWM pin to wich is connected the back right motor. Must be of the type unsigned char.

#3: Directly using remote controller joystick values, with only 1 motor per sideLes paramètres suivants sont requis par la fonction:

  • forwardChannel: Le « channel » de joystick à utiliser pour contrôler la vitesse avant/arrière. De type ANALOG (voir CrcLib: accéder aux boutons de la télécommande)

  • yawChannel: Le « channel » de joystick à utiliser pour contrôler la vitesse de rotation. De type ANALOG (voir CrcLib: accéder aux boutons de la télécommande )

  • frontLeftMotor: Le port PWM auquel est connecté le moteur avant gauche.

  • backLeftMotor: Le port PWM auquel est connecté le moteur arrière gauche.

  • frontRightMotor: Le port PWM auquel est connecté le moteur avant droit.

  • backRightMotor: Le port PWM auquel est connecté le moteur arrière droit.

#3: Utiliser directement les valeurs de la manettes, 1 seul moteur par côté

static void CrcLib::MoveArcade(ANALOG forwardChannel, ANALOG yawChannel, unsigned char leftMotor, unsigned char rightMotor)

The following parameters must be passed to the function for it to work properly:

  • forwardChannel: The speed value used to control the forward/backward motion. Must be of the type ANALOG.

  • yawChannel: The speed value used to control rotative motion. Must be of the type ANALOG.

  • leftMotor:he name of the PWM pin to wich is connected the left motor. Must be of the type unsigned char.

  • rightMotor: The name of the PWM pin to wich is connected the right motor. Must be of the type unsigned char.

Examples

Expandtitle#1 We want to control 2 power motors, part of an Arcade style drive system, controlled via motor controllers connected to PWM Port #1 and #2. We want the forward/backward movement to be directly controlled using the vertical axis of the left joystick and the rotative motion to be directly controlled using the horizontal axis of the right joystick on the remote controller connected via a CrcConnect module

Les paramètres suivants sont requis par la fonction:

Exemples

Expand
title#1 Nous souhaitons contrôler 2 moteurs de puissance faisant partie d'une base de style « tank » dirigée par des contrôleurs de moteur connectés aux ports PWM #1 et #2. Nous souhaitons que la vitesse avant/arrière et de rotation soit directement contrôlée respectivement par la position horizontale et verticale du joystick 1 de la manette connectée au CRCconnect.
Code Block
languagecpp
#include <CrcLib.h>

void setup() {
    CrcLib::Initialize();

    CrcLib::InitializePwmOutput(CRC_PWM_1);
    CrcLib::InitializePwmOutput(CRC_PWM_2);
    
    /* 
    TheReste restdu of your setup codecode d'initialisation
    ...
     */
}
void loop() {
    CrcLib::Update();

    CrcLib::MoveArcade(ANALOG::JOYSTICK1_Y, ANALOG::JOYSTICK2JOYSTICK1_X, CRC_PWM_1, CRC_PWM_2);
    
    /* 
    TheReste restde ofla yourboucle loopingprincipale
code     ...
    */
}

More on this function

There is sadly nothing more to be said about this function…

Related articles

Articles reliés

Filter by label (Content by label)
sorttitle
excerptTyperich content
cqllabel = "ar-crclib_funct_drive"