Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Claw-test.h
00001 #ifndef CLAW_TEST_H 00002 #define CLAW_TEST_H 00003 00004 /** 00005 * \brief Check that Claw object goes to correct position when moved 00006 * 00007 * \returns true if all the tests passed 00008 */ 00009 bool Claw_test_movement() 00010 { 00011 // Initialise Claw object with a winch width of 12 00012 Claw claw; 00013 claw.init(12); 00014 00015 // Set the position to 42,15 00016 Vector2D initial_pos = {42, 15}; 00017 claw.set_pos(initial_pos); 00018 00019 // Read the position 00020 Vector2D read_pos_1 = claw.get_pos(); 00021 printf("%f, %f\n", read_pos_1.x, read_pos_1.y); 00022 00023 // Set the velocity to 1 00024 float velocity = 1.0; 00025 claw.set_velocity(velocity); 00026 00027 // Update the position 00028 Vector2D winch_pos = {35,9}; 00029 claw.update(winch_pos); 00030 00031 // Read the position 00032 Vector2D read_pos_2 = claw.get_pos(); 00033 printf("%f, %f\n", read_pos_2.x, read_pos_2.y); 00034 00035 // Now check that both the positions are as expected 00036 bool success_flag = true; 00037 00038 // Fail the test if the initial position is wrong 00039 if (read_pos_1.x != 42 || read_pos_1.y != 15) { 00040 success_flag = false; 00041 } 00042 00043 // Fail the test if the final position is wrong 00044 if (read_pos_2.x != 41 || read_pos_2.y != 16) { 00045 success_flag = false; 00046 } 00047 return success_flag; 00048 } 00049 #endif
Generated on Sat Jul 16 2022 10:18:04 by
1.7.2