View unanswered posts | View active topics It is currently Mon Sep 15, 2014 11:03 pm






Reply to topic  [ 2 posts ] 
Robotic Arm 
Author Message
Rookie

Joined: Wed Jul 30, 2014 9:18 am
Posts: 5
Post 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!


Wed Jul 30, 2014 9:50 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 574
Post 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.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Aug 01, 2014 10:50 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.