Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1
Send Topic Print
Learning C (Read 1189 times)
roboz
YaBB Newbies
*




Posts: 20
Learning C
02/13/09 at 8:58am
 
I am new to programming, but would like to start writing some simple programs for the srv.  Can anyone recommend a beginner's book, website, or general advice on how to start?  Maybe there is something right here on this website I can start with?
Thanks
 
Back to top
 
 
  IP Logged
shawnjgoff
Full Member
***


an electrical
engineer in the
making

Posts: 132
Re: Learning C
Reply #1 - 02/13/09 at 9:04am
 
I thinks the scratch project is a great introduction to programming. It teaches general ideas such as variables, comparisons, control structures without requiring you to learn special words or syntax. Once you get the idea of how to control things using those concepts, you can jump into any language by learning exactly how to declare variables and use for loops and if/then statements for that specific language.
Back to top
 
 
WWW   IP Logged
admin
YaBB Administrator
*****




Posts: 3675
Re: Learning C
Reply #2 - 02/13/09 at 9:52am
 
The C interpreter in the SRV1 isn't a bad starting point.  There are some basic syntax rules you need to observe (declaration of a main() function, use of semicolors and curly brackets, etc), but we can help walk you through those.
 
A good starting point would be to print out the list of built-in C functions from
    http://www.surveyor.com/SRV_protocol.html
 
Some of these primitives, such as int, char, for, if, else, while .. are part of the language, and the rest are functions we defined for interfacing to the SRV1,  such as input, print, delay, motors, laser, rand, range, blob, color, etc.
 
A really simple program that just drives the robot forward for 1 second, turns right, then drives forward in the new direction would look like this -  
 
main() {
    motors(50, 50);
    delay(1000);
    motors(50, -50);
    delay(500);
    motors(50, 50);
    delay(1000);
    motors(0, 0);
}
 
So it drives forward for 1000 millisecs (1 second), spins right for 500 millisecs (left motor forward, right motor reverse), then drives forward again for 1000 millisecs.
 
We can make this more complex, but this is a good starting point.
 
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
brown
YaBB Newbies
*




Posts: 25
Re: Learning C
Reply #3 - 02/19/09 at 8:04pm
 
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print