Project Goals

The goal of the project was to create a device that could climb, move vertically up, on the pipe.

Mechanical Part:

-Built from Lego, including motors and sensors.

-Keeps given position on the pipe.

-Move up on pipe with a specific diameter.

-Stops near bottom/upper part of the pipe.

-Follows hand up and down.

Software Part:

-C programming language with Husarion/Lego libraries.

-The microcontroller is a Husarion RoboCore.

-Raspberry Pi 1 to create access point n order to control robot on distance.

-Must take the input from the sensor and decide where it should stop.

-Measures heights of its position on the pipe.

-Operating module: Manual, Automatic.

Manual module:

-Controlling from the computer by key commands such as tightens connecting part by decreasing its length, releases connecting part, makes robot to move up and stops all motors.

-Follows hand on the pipe.

Automatic module:

-Stops at bottom and up position of the pipe.

-Stops if not receives commands from Raspberry Pi.

-Holds given position.

Design:

The robot is made up of 3 motors, 1 ultrasonic sensor and 1 RoboCORE connected by Lego briks. Two motors are used to rotate wheels which make robot move up on the pipe. The third motor is used to provide tension to increase friction between wheels and the pipe. Ultrasonic sensor used to measure the distance below robot.

Source code can be found below, as well as in attached files.

main.cpp

# include <hFramework.h> # include <stdio.h> # include <DistanceSensor.h> # include <vector> # include <ctype.h> # include <cmath> # include <Lego_Touch.h> using namespace hFramework; using namespace hModules; using namespace hSensors; int zmax = 170 ; int zmin = 15 ; void stop () { hMot1.setPower( 0 ); hMot3.setPower( 0 ); hMot6.setPower( 0 ); } int get_number () { char c = getchar(); int total = 0 ; std:: vector < int > numbers; while (c != 'c' ){ int digit; printf ( "%c" , c); digit = ( int ) c - '0' ; numbers.push_back(digit); c = getchar(); } for ( int i = 0 ; i < numbers.size(); i++){ printf ( "%d\r

" , numbers.at(i)); total += numbers.at(i) * pow ( 10 ,(numbers.size()-i- 1 )); } printf ( "%d\r

" , total); return total; } void go_to (DistanceSensor &sens, int height) { int dist = sens.getDistance(); if (dist < 0 ) return ; if ( abs (dist - height) > 10 ){ if (dist < height && dist < zmax){ hMot1.setPower( 1000 ); hMot3.setPower( 1000 ); } else if (dist > height && dist > zmin) { hMot1.setPower(- 200 ); hMot3.setPower(- 200 ); } else { stop(); } } else { stop(); } } void hMain ( void ) { sys.setLogDev(&Serial); DistanceSensor sens (hSens2.getBaseSens() ) ; while ( true ) { printf ( "read: " ); char c = getchar(); printf ( "%c" , c); if ( isalpha (c)){ printf ( "\r

ok\r

" ); } else { printf ( "\r

wrong command\r

" ); continue ; } printf ( "number: " ); int number = get_number(); if (c == 'p' ){ int dist = sens.getDistance(); if (dist == - 1 ){ continue ; } if (dist < zmax){ hMot1.setPower(number); hMot3.setPower(number); } else { hMot1.setPower( 0 ); hMot3.setPower( 0 ); } } else if (c == 'o') { int dist = sens.getDistance(); if (dist == - 1 ){ continue ; } if (dist > zmin){ hMot1.setPower(-number); hMot3.setPower(-number); } else { hMot1.setPower( 0 ); hMot3.setPower( 0 ); } } else if (c == 'w') { hMot6.setPower( 500 ); } else if (c == 's') { hMot6.setPower(- 500 ); } else if (c == 'm') { go_to(sens, number); } else if (c == 'q') { stop(); } else { stop(); } } }

CMakeList.txt