simple_controller.c

This example is discussed in A simple controller.

00001 /* The main libbot header */
00002 #include <devbot/core/bot.h>
00003 
00004 /* Header for accessing BotServoMotor devices */
00005 #include <devbot/servomotor.h>
00006 
00007 /* Header for accessing the active sensor board */
00008 #include <devbot/driver/sdp_aboard.h>
00009 
00010 int main(int argc, char** argv)
00011 {
00012     int value = 0, index = 0;
00013     /* Initialize the library */
00014     bot_initialize_from_file("simple_controller.config");
00015   
00016     /* Grab one of the motors and set it spinning */
00017     BotDevice *motor0 = bot_get_device("motor0");
00018     bot_servomotor_set_velocity(motor0, 2);
00019     
00020     /* Now we'll use an aboard-specific call to retrieve sensor values*/
00021     BotDevice *aboard = bot_get_device("aboard");
00022     for (index = 0; index < 7; index++) {
00023         value = sdp_aboard_get_sensor(aboard, index);
00024         g_message("Sensor %d reading: %d", index, value);
00025     }
00026 
00027     /* Shutdown the library */
00028     bot_shutdown();
00029     return 0;
00030 }

(c) 2006 Edinburgh Robotics Ltd.
Generated on Fri Feb 2 11:24:04 2007 for libbot by doxygen 1.5.1