ROBOTC.net forums
http://robotc.net/forums/

Robotic Arm
http://robotc.net/forums/viewtopic.php?f=11&t=9159
Page 1 of 1

Author:  denrya [ Wed Jul 30, 2014 9:50 am ]
Post subject:  Robotic Arm

Hello,
I am trying to create a Robotic Arm sequencer in RobotC. The robotic arm is made up of six servo motors, and I am able to drive the arm using the VEXnet controller. I would like to be able to drive the robot arm to a position and press a button on the controller to record that position. Once all of the positions have been recorded, I would like to be able to play them back. Is it possible to pull values directly from the servo motors and insert them into specific spots in the code? I am worried that variables will change from position to position, or clear when the program is closed and reopened. I am open to ideas. Thanks for the help!

Author:  JohnWatson [ Fri Aug 01, 2014 10:50 am ]
Post subject:  Re: Robotic Arm

There are two main issues that you are going to run into; grabbing multiple values for multiple arm joints (each at a different stage of movement), and storing those values for later retrieval.

For the first problem, I suggest taking a look into variable arrays. Without going into too much detail on how they work (there are a ton of tutorial guides available online that cover arrays, as they are standard in almost every programming language), you can make an array of x variables for each arm joint, where x is the number of movements you want to make:

Code:
int joint1[5] ={};
int joint2[5] = {};
int joint3[5] = {};


Once the variable arrays have been created, I suggest zeroing them out manually:

Code:
   for (int foo = 0; foo < 5; foo++)
   {
      joint1[foo] = 0;
      joint2[foo] = 0;
      joint3[foo] = 0;
   }


Then, you will have to decide how you want to tell the code to place new values into the variable arrays, how you want to use them in your code, etc. It's a bit of an advanced concept (the 'for loop' is something that you may not have seen before; it's the equivalent of the while loop shown below with the exception that the integer 'foo' is destroyed once the loop is over) but with some practice it should start to make sense.

Code:
int foo = 0;

while(foo < 5)
{
//Code to run
foo = foo + 1;
}

//Foo no longer exists once the loop is over


Now, as far as saving the values to the Cortex for use between resets; that may be a bit harder to do as there is currently no way to save a custom file to the Cortex's memory using ROBOTC. Instead, you may need to write the values to the Debug Stream and save them in as computer file, then manually copy the values into the code later on (or hardcode the values into program). If you wanted to get very fancy, you could *possibly* make a script in the language of your choice (standard C, C++, Visual Basic, etc) that pulls the values automatically from the debug stream and saves them into a file, but that may be more work than what it's worth.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/