Announcement

Collapse
No announcement yet.

How do I ......?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I ......?

    I am fairly new to this robotics stuff and I try to keep ahead of my Civil Air Patrol Cadets as we progress through the VEX IQ system. I need some help please.

    How do I program (using RobotC Graphical) the ClawBot to perform two or more functions simultaneously?

    For example: I want the touch LED to flash at the same time the bot is moving.
    Example: I want the robot to "beep" when it goes into reverse.

    I can get the LED to flash, but not at the same time as movement.
    I can get the bot to "beep", but I need advice on how to integrate the commands to get the "beep" while moving in reverse.

    Any help and guidance is appreciated.

    Kim Nicholas

  • #2
    Can you post your code?

    Comment


    • #3
      Assuming I did it correctly, attached is a screen shot of what I have so far. I can get the LED to flash OR I get the arcade settings to work. I want the LED to flash WHILE the bot moves.
      What is the secret sauce?

      Comment


      • #4
        Here is a better image.

        Comment


        • #5
          Not sure I can completely help, but you have two different repeat(forever) loops in series. If you run the program it will never see the second repeat loop. All commands must exist in the same repeat(forever) loop.

          It might be possible to set a variable to getJoystick D and then test for less than 0 to play a sound, all inside the loop.

          Commands would look like:

          Variable[Value] used first to set the Variable "Joy"

          Joy = getJoystickValue(ChD);
          if (Joy , < 0) {playSound(soundWrongWay);}

          See attached for Graphical RobotC example to include in your repeat(forever) loop.

          Comment


          • #6
            ROBOTC Graphical is not really ideal for this. In the text version of the language, it is easy for 2 reasons. First, you have tasks so you can use a task to handle your reverse beeper. Secondly, you have more commands for the touch LED, one of which allows you to give the LED a blink time:

            setTouchLEDBlinkTime(touchLED, X, Y) where X is the on time and Y is the off time. When you turn the LED on, it will handle it's own blink cycles.

            I can create you a basic example in ROBOTC text if you'd like?

            Comment


            • #7
              This can be done roughly like how you're doing it. You don't have to switch over away from RobotC Graphical. The problem with the two repeat(forever) loops pointed out above is important. You want one repeat(forever) loop. Erase the second loop. Make a variable to record a time (lastRecordedTime below). Make another variable to record which color you're on (basically, values 1, 2, and 3 or similar) (colorMarker below). Inside the first loop throw in a single if statement in addition to your arcade and arm controls. This would be the pseudocode:

              if(getTimerValue() > lastRecordedTime + 0.5){
              if(colorMarker == 1) {
              SetTouchLEDColor(Yellow);
              colorMarker = 2;
              }
              else if(colorMarker == 2) {
              SetTouchLEDColor(Orange);
              colorMarker = 3;
              }
              else {
              SetTouchLEDColor(Blue);
              colorMarker = 1;
              }
              lastRecordedTime = getTimerValue();
              }

              Now the code will keep checking the time (getTimerValue()) as well as the joystick as it loops around. If enough time has passed since the last change, it will change the light to the next color, update which color will follow, and update the timer to check against the timer again.

              Comment


              • #8
                Originally posted by calvc01 View Post
                ROBOTC Graphical is not really ideal for this. In the text version of the language, it is easy for 2 reasons. First, you have tasks so you can use a task to handle your reverse beeper. Secondly, you have more commands for the touch LED, one of which allows you to give the LED a blink time:

                setTouchLEDBlinkTime(touchLED, X, Y) where X is the on time and Y is the off time. When you turn the LED on, it will handle it's own blink cycles.

                I can create you a basic example in ROBOTC text if you'd like?
                OK... I have used this for a while and I never saw the setTouchLEDBlinkTime command... When I google it I can find a page but with no links. I have gone through a comprehensive list of the graphical commands, where is there a comprehensive list of the text commands? I don't mind a big list.

                Comment


                • #9
                  I found something saying there was a loss of data during a server upgrade. Here is a link for this setTouchLEDBlinkTime command:

                  http://help.robotc.net/Sandbox/Zende...DBlinkTime.htm

                  The one for setTouchLEDFade is similar:

                  http://help.robotc.net/Sandbox/Zende...uchLEDFade.htm

                  But I haven't found the path to them, and they don't have links backward. But I was able to get a whole pile of links to various commands with the LED using this search on Google:

                  robotc TouchLED site:help.robotc.net

                  I'm sure just a few replacements for "TouchLED" would provide quite a few commands.

                  Comment


                  • #10
                    No idea how I came across it in the first place sankeydd , I am sure I must have read it inthe help file at some point!

                    You can browse through the Includes folder in the installation directory to find any other hidden gems :-)

                    Comment


                    • #11
                      I did see it when I switched back to text... I usually use graphical with my kids. I will look around!

                      Comment

                      Working...
                      X