This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:examples:sensor:lidar [2012/06/04 22:25] – heikopikner | en:examples:sensor:lidar [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| //Necessary knowledge: [HW] [[en: | //Necessary knowledge: [HW] [[en: | ||
| + | ===== Theory ===== | ||
| - | [{{ | + | [{{ : |
| - | + | ||
| - | + | ||
| - | ===== Theory ===== | + | |
| LIDAR (Light Detection and Ranging) is an optical remote sensing system which can measure the distance of a target by illuminating it with light. LIDAR technology is being used in Robotics for the perception of the environment as well as object classification. The ability of LIDAR technology to provide 2D elevation maps of the terrain, high precision distance to the ground, and approach velocity can enable safe landing of robotic and manned vehicles with a high degree of precision. | LIDAR (Light Detection and Ranging) is an optical remote sensing system which can measure the distance of a target by illuminating it with light. LIDAR technology is being used in Robotics for the perception of the environment as well as object classification. The ability of LIDAR technology to provide 2D elevation maps of the terrain, high precision distance to the ground, and approach velocity can enable safe landing of robotic and manned vehicles with a high degree of precision. | ||
| Line 72: | Line 70: | ||
| <code c> | <code c> | ||
| - | |||
| #include < | #include < | ||
| #include < | #include < | ||
| Line 79: | Line 76: | ||
| #include < | #include < | ||
| - | // | + | // Defining |
| - | // Determining | + | |
| - | // | + | |
| usart port = USART(0); | usart port = USART(0); | ||
| - | // | + | // Defining button |
| - | // Determining the pins of buttons. | + | |
| - | // | + | |
| pin button1 = PIN(C, 0); | pin button1 = PIN(C, 0); | ||
| pin button2 = PIN(C, 1); | pin button2 = PIN(C, 1); | ||
| - | |||
| - | // | ||
| // Initialize | // Initialize | ||
| - | // | ||
| static inline void init() | static inline void init() | ||
| { | { | ||
| Line 102: | Line 92: | ||
| // Set-up of the LCD. | // Set-up of the LCD. | ||
| lcd_gfx_init(); | lcd_gfx_init(); | ||
| - | + | // Cleaning the screen. | |
| - | // Cleaning the screen. | + | |
| lcd_gfx_clear(); | lcd_gfx_clear(); | ||
| - | + | // Switching on the background light. | |
| - | // Switching on the background light. | + | |
| lcd_gfx_backlight(true); | lcd_gfx_backlight(true); | ||
| - | + | // Displaying the name of the program. | |
| - | // Displaying the name of the program. | + | |
| lcd_gfx_goto_char_xy(3, | lcd_gfx_goto_char_xy(3, | ||
| lcd_gfx_write_string(" | lcd_gfx_write_string(" | ||
| Line 124: | Line 111: | ||
| } | } | ||
| - | // | ||
| // Main program | // Main program | ||
| - | // | ||
| int main(void) | int main(void) | ||
| { | { | ||
| - | unsigned char new_value1, old_value1 = 0, new_value2, | + | unsigned char new_value1, new_value2, old_value1 = 0, old_value2 = 0; |
| - | old_value2 = 0; | + | |
| char c; | char c; | ||
| Line 143: | Line 127: | ||
| while (1) | while (1) | ||
| { | { | ||
| - | |||
| // Reads buttons states | // Reads buttons states | ||
| new_value1 = pin_get_debounced_value(button1); | new_value1 = pin_get_debounced_value(button1); | ||
| Line 166: | Line 149: | ||
| if((!new_value2) && (old_value2)) | if((!new_value2) && (old_value2)) | ||
| { | { | ||
| - | //Send " | + | //Send "0x 02 00 02 00 20 25 35 08" to stop scanning. |
| - | + | ||
| usart_send_char(port, | usart_send_char(port, | ||
| usart_send_char(port, | usart_send_char(port, | ||
| Line 176: | Line 158: | ||
| usart_send_char(port, | usart_send_char(port, | ||
| usart_send_char(port, | usart_send_char(port, | ||
| - | |||
| } | } | ||
| - | |||
| // Remembers the last keys values. | // Remembers the last keys values. | ||
| old_value1 = new_value1; | old_value1 = new_value1; | ||
| old_value2 = new_value2; | old_value2 = new_value2; | ||
| - | |||
| // Try to read serial port | // Try to read serial port | ||
| if (usart_try_read_char(port, | if (usart_try_read_char(port, | ||
| { | { | ||
| - | //Find a header "0x 02 81 D6 02 B0 69 41". Very basic package start search. | + | // Find a header "0x 02 81 D6 02 B0 69 41" |
| + | // Very basic package start search. | ||
| if(c == 0x02) i++; | if(c == 0x02) i++; | ||
| if(c == 0x81) i++; | if(c == 0x81) i++; | ||
| Line 196: | Line 176: | ||
| if(c == 0x69) i++; | if(c == 0x69) i++; | ||
| if(c == 0x41) i++; | if(c == 0x41) i++; | ||
| - | |||
| //If there is an header | //If there is an header | ||
| Line 213: | Line 192: | ||
| i=0; | i=0; | ||
| } | } | ||
| - | |||
| } | } | ||
| - | |||
| } | } | ||
| } | } | ||
| - | |||
| - | |||
| - | |||
| - | |||
| </ | </ | ||