Printf-Test Assignment

a) Write the “Hello World” program so that it will print out “Hello World” in a different language (  or ) to help find translations.

  • Have your robot print something else of your choice.
  • Use %d and %x to have your robot write an integer in both decimal (base 10) and hexadecimal (base 16 ).

b) Run an example robot test program several times with low and high velocities.  How accurate and reliable is it in moving the robot?  [You will note that it doesn’t run well at low speeds with the Link controller.]  If you are interested mainly in the end position and orientation of the robot rather than the speed of movement, you might do better by varying the power to the motors and running them until they reach a desired rotational position, rather than at speed for a time increment.  Two motor functions can be used to move the Demobot until it reaches a position:  New functions are added to control position – clear_motor_position_counter(n) and get_motor_position_counter(n), where ‘n’ is the motor port number. [acronyms for these functions: cmpc(n) and gmpc(n) respectively, can be used to reduce typing]

How would you modify the example program to test under variable motor power and stop at a desired position?

Here is an example of A test program for variable power with ‘motor()’ cmd rather than variable speed under ‘mav()’ [cut & paste may not work for transfering < ‘ and ” > symbols]:

/*This program prints instructions and shows power for testing behavior on a Link-or Wallaby-controlled robot, and then allows further adjustment as the robot is run for 2500 ticks, note ‘display_printf’ is used only when a new value is generated in the repeating initialization loop. This is a template illustrating an initial print loop to test behavior with an adjustable variable.  3/13/2014- 2015; rev 11/9/2016 -tg*/

int  main()
  int power= 30 ;// declare a test variable; set initial level
  // for Link: set_b_button_text(“Up”); set_c_button_text(“Down”);
  display_clear(); //prepares display memory
  //print instructions
  display_printf(0,3,”Use the up(B) & down(C) keys: motors 0 &3, “);
  display_printf(0,4,“to adjust power.(‘-‘ is reverse)”);
  display_printf(0,5,“Press A to go!”);

  display_printf(2,6,“power: %d “,power);

      while(!a_button()) //adjust velocity until A button is pressed

        if(b_button() || c_button())


             if(b_button()) power=power+5;
             if(c_button()) power=power-5;
             if(power>100) power=100; //max forward power
             if(power<-100) power=-100; //max reverse power

             display_printf(2,6,”power: %d “,power);
             msleep(150) ;// allow display time to print

      } //end setup interaction loop

   while((get_motor_position_counter(0)<2500) &&   (get_motor_position_counter(0)>-2500))

     {msleep(5);}//wait for position count +/-
   ao(); // turn off motors when the desired position is reached
  } // end repeat loop

Run the program several times with low and high power levels.  How accurate and reliable is it in moving the robot?  Does it perform better  than the first test program?  If the robot doesn’t drive straight, how would you add a balancing factor to one motor command to improve its direction?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s