|Page 1 of 1|
|Author:||denrya [ Wed Jul 30, 2014 9:50 am ]|
|Post subject:||Robotic Arm|
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:
Once the variable arrays have been created, I suggest zeroing them out manually:
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.
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