- LiFePO4 Speicher Test         
Ergebnis 1 bis 8 von 8

Thema: programmierung

  1. #1
    Neuer Benutzer Öfters hier
    Registriert seit
    08.10.2009
    Ort
    ettingshausen
    Alter
    26
    Beiträge
    15

    programmierung

    Anzeige

    Praxistest und DIY Projekte
    hallo erstmal

    hab einen rp6 und wollte fragen was ich bei der änderung von datei 1 falsch mache?

    Code:
    /* 
     * ****************************************************************************
     * RP6 ROBOT SYSTEM - ROBOT BASE EXAMPLES
     * ****************************************************************************
     * Example: Movement 1
     * Author(s): Dominik S. Herwald
     * ****************************************************************************
     * Description:
     * This Example Program shows how to control the Motors.
     *
     * The RP6 moves in a circle. Provide enough of free space, please!
     * If it hits an obstacle it will stop the motors and two LEDs will start 
     * to blink.
     * It will stay in this state and wait until you restart the program!
     *
     * ############################################################################
     * #+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+
     * 
     * ATTENTION: THE ROBOT MOVES AROUND IN THIS EXAMPLE! PLEASE PROVIDE ABOUT
     * 1m x 1m OR MORE FREE SPACE FOR THE ROBOT! 
     *
     * >>> DO NOT FORGET TO REMOVE THE FLAT CABLE CONNECTION TO THE USB INTERFACE
     * BEFORE YOU START THIS PROGRAM BY PRESSING THE START BUTTON ON THE ROBOT!
     *
     * (don't remove the USB Interface from the PC - only remove the flat cable
     * connection between the Interface and the Robot!)
     *
     * #+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+
     * ############################################################################
     * ****************************************************************************
     */
    
    /*****************************************************************************/
    // Includes:
    
    #include "RP6RobotBaseLib.h" 	// The RP6 Robot Base Library. 
    								// Always needs to be included!
    
    /**
     * Here we react on any obstacle that we may hit. 
     * If any of the bumpers detects an obstacle, we stop the motors and start
     * Stopwatch1 which controls a small blink LED routine.
     */
    void bumpersStateChanged(void)
    {
    	if(bumper_left || bumper_right) 
    	
            changeDirection(BWD);
    
            Move 300mm backwards at "MOVE_SPEED":
    		move(MOVE_SPEED, BWD, DIST_MM(300);
            }
    
            
    		
    	
    }
    
    /**
     * This function checks Stopwatch1 all the time. If stopwatch 1 is
     * not running, the function does not do anything. As soon as the
     * stopwatch is started, two LEDs begin to blink!
     */
    void blink(void)
    {
    	if(getStopwatch1() > 500) // 500ms
    	{
    		statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... 
    		statusLEDs.LED5 = !statusLEDs.LED5;
    		updateStatusLEDs();
    		setStopwatch1(0);
    	}
    }
    
    /*****************************************************************************/
    // Main:
    
    int main(void)
    {
    	initRobotBase();
    	setLEDs(0b111111);
    	mSleep(1500);
    	setLEDs(0b100001);
    
    	// Set Bumpers state changed event handler:
    	BUMPERS_setStateChangedHandler(bumpersStateChanged);
    
    	
    	powerON(); 	// Turn Encoders, Motor Current Sensors 
    				// (and ACS IR Receiver and PWRON LED) on.
    				// ATTENTION: Automatic Motor control will not work without this!
    	
    	// -------------------------
    	// With the following two commands, the RP6 will start to move in a circle.
    	// We simply set the direction to forwards:
    	
    	changeDirection(FWD);
    
        // and afterwards we set the speed of the left and right motors to different 
    	// values (80 for left, and 30 for right in this example):
    	
    	moveAtSpeed(50,50);  
     
    	// The function 
    	// void moveAtSpeed(uint8_t desired_speed_left, uint8_t desired_speed_right)
    	// sets the desired speeds. The automatic motor control will try to maintain
    	// this speed even if the motors get blocked or the robot has to move up a
    	// ramp or drive over a small obstacle. 
    	// At least this will be the case if you always call task_RP6System() frequently
    	// out of the main loop!
    	// Maximum speed is 200. And if you execute the command:
    	// moveAtSpeed(0,0);
    	// the Robot will stop and turn motors off.
    	// Values below 8 will not work properly as this is just too slow to regulate
    	// accurately. 
    	// ATTENTION: If you use high speeds all the time, this will result in shorter
    	// gears and motors lifetime. It is recommended to use only speed values
    	// between 10 and 160! It is no problem to use 200 for some seconds, but 
    	// you should not let the Robot drive at such high speed all the time!
    
    	// Main loop:
    	while(true) 
    	{
    		// If we hit an obstacle, the bumperStateChanged Handler will start
    		// Stopwatch 1 and then this task will let two LEDs blink:
    		blink();
    	
    		// In the main loop we need to call task_RP6System() all the time! 
    		// This function calls the Motor control functions that automatically
    		// regulate the motor speed:
    		
    		task_RP6System();
    	}
    	return 0;
    }
    wollte eigentlich nur eine bestimmte distanz rüchwärts fahren also 300 mm
    aber er fährt dauerhaft rückwärts


    danke für eure hilfe

    jonas

  2. #2
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    04.03.2010
    Beiträge
    205
    Versuchs mal mit diesem kleinen Code (leichter Verständlich) :
    Code:
    #include "RP6RobotBaseLib.h"
    int main(void)
    {
    initRobotBase();
    powerON();
    move(60, FWD, DIST_MM(30), true);
    }
    Nichts existiert durch sich allein!
    Bild hier  

  3. #3
    shedepe
    Gast
    @jonasspieker
    Wie kommt du darauf dass der RP6 bei deinem Code 300mm rückwärts fahren sollte ?
    Du sagst dem RP6 doch nur er soll bedei motoren mit dem Speed 50 bewegen aber nich wie weit.
    Außerdem, steht FWD nicht für forwards, wenn du rückwärts fahren willst müsstest du dann doch anstelle von FWD, BWD verwenden !

  4. #4
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    04.03.2010
    Beiträge
    205
    Ich dachte immer FWD steht für forward!?
    Nichts existiert durch sich allein!
    Bild hier  

  5. #5
    Erfahrener Benutzer Fleißiges Mitglied
    Registriert seit
    28.04.2009
    Ort
    Wörgl
    Alter
    28
    Beiträge
    175
    Hi,

    FWD steht für forward,
    BWD steht für backwards.

    lg
    Michi

  6. #6
    shedepe
    Gast
    Na also, aber ihr habt beide in eurem Code FWD, wenn du nun jedoch rückwärts fahren willst

    PS. Ich hab mich vllt mit:
    Außerdem, steht FWD nicht für forwards, wenn du rückwärts fahren willst müsstest du dann doch anstelle von FWD, BWD verwenden !
    etwas undeutlich ausgedrückt.
    "Steht FWD nicht für forwards" war quasi als rethorische Frage gemeint

  7. #7
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    04.03.2010
    Beiträge
    205
    Ich habe mich mit dem Code-Beispiel auch nicht genau auf die Frage bezogen. Aber ich denke, dass jder halbwegs begabte das FWD an seine Bedürfnisse anpassen kann.
    Nichts existiert durch sich allein!
    Bild hier  

  8. #8
    Neuer Benutzer Öfters hier
    Registriert seit
    08.10.2009
    Ort
    ettingshausen
    Alter
    26
    Beiträge
    15
    ups
    ich meint ja auch vorwärts net rückwärts
    srrrrrrrryyyyy

    danke für eure hilfe

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

MultiPlus Wechselrichter Insel und Nulleinspeisung Conrad