Need Help In Programming

2 replies [Last post]
Title: NooBot
Joined: 02/13/2011
BotPoints: 3
User offline. Last seen 12 years 16 weeks ago.

Hey, I'm Phenix870 and I'm a new programmer. I've signed up with my school in a robotics competition in my region and I so far I've found out only how to make the robot talk but i wanna learn how to make it move. Can someone please help?? (BTW I'm usins KISS-C, if anyone would like to know).

KIPR Matthew
KIPR Matthew's picture
Title: KIPR Staff
Joined: 06/04/2009
BotPoints: 154
User offline. Last seen 5 years 39 weeks ago.

Well there is a lot of information to cover in that area. Basic movements are accomplished by driving motors attached to something (usually wheels).

The most basic form of driving is with two direct drive wheels, one on the left and one on the right. This is the way the iRobot Create is designed. If you are scratch building robot, I suggest following a similar course with two motors connected to two wheels, one on each side of the robot.

From this basic set up we can drive in several configurations:

both forward: drives the robot forward
both backward: drives to robot backward
one forward and one backward: drives the robot in a tight circle
both forward at different speeds: drives forward in an arc

If you are driving a scratch built you can just use the MAV(motor, speed); function in KISS-C, where motor is the port it is plugged into and the speed is the speed of the motor in tics per second (~1100 tics per 1 motor revolution). Just call the two motor calls right after each other. There will be a small delay between turning the motors o, but it will be so short of time for our purposes they com on at the same time. Follow the list above to figure out how to drive the motors to go where you want.

A simple motor program to drive the robot straight forward for 5 seconds:

int main(){
mav(0,1000); //turn on motor port 0
mav(3,1000); //turn on motor port 3
sleep(5); //wait for 5 seconds
ao(); // turn off the motors

There is a little more that goes into driving the Create, but here is the same program written for a Create and CBC:

int main(){
create_connect(); //connect to the Create
sleep(.1); //wait for connection to be established
create_drive_straight(300); //drive straight at 300 mm/sec
sleep(5); //wait for 5 seconds
create_stop(); //stop the motors
create_disconnect(); //release communications

Hope this gets you headed in the right direction.

Join the Botball folding at home team!
Team 87314 "Botball"

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
BotPoints: 1168
User offline. Last seen 8 years 2 weeks ago.

Matt basically covered everything, but as an aside, next time you stop by the Botballer's Chat to ask a question, please wait longer than 16 seconds for an answer before getting frustrated and leaving. Pipeep and I were both present in the chat when you asked this question there, and had you waited a couple minutes, you likely would have gotten an answer, as is stated on both the Botballer's Chat web page and in the chat topic.

-Jeremy Rand
President, Botball Youth Advisory Council

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS