<jupyter_start><jupyter_text>Basic robot movement A two wheel robot is the simplest robot you can build and offers easy control. The movement of the robot based on diferential speed between the two wheeels. When both of the wheel moving in the same direction with the same speed the robot move in straight line to that direction. If you want to rotate the robot just change the direction of the  opposite wheel of the direction you want to turn the robot.   Let's build that robot with visual controls ![two wheel](./images/2_wheel_metal.png) Build a two wheel robot with metal ball caster using the instructions and let's make it to move. First we need to import the proteas_lib and tell to Proteas where the motors are connected.<jupyter_code>import ipywidgets as widgets #With that import the user can create visual controls 
from proteas_lib import control
import time
control.start_lib()
motor_a = control.motor(17,27,22)
motor_b = control.motor(10,11,9)<jupyter_output><empty_output><jupyter_text>Using two sliders we can control the motors speed.<jupyter_code>m1 = widgets.IntSlider(value=50,min=0,max=100,step=1,description='Speed A:')
m2 = widgets.IntSlider(value=50,min=0,max=100,step=1,description='Speed B:')
display(m1,m2)<jupyter_output><empty_output><jupyter_text>Its time to add and some contols for the directions of the motors.<jupyter_code>m1d = widgets.RadioButtons(options=['forward', 'reverse'],value='forward',description='Direction A:')
m2d = widgets.RadioButtons(options=['forward', 'reverse'],value='forward',description='Direction B:')
display(m1d,m2d)<jupyter_output><empty_output><jupyter_text>Finally we need one more slider to control the total time of the movement.<jupyter_code>total_t  = widgets.IntSlider(value=1,min=0,max=60,step=1,description='Total time:')
display(total_t)<jupyter_output><empty_output><jupyter_text>Now its time to write the mainloop for the robot. Using the controls from before you can test the movement of the robot.<jupyter_code>print("Robot activated")
motor_a.set_speed(m1.value)
motor_b.set_speed(m2.value)
print("The robot will be move for {} seconds".format(total_t.value))
for i in range(1,total_t.value):
    motor_a.move(m1d.value)
    motor_b.move(m2d.value)
    time.sleep(1)
motor_a.stop()
motor_b.stop()
print("Robot deactivated")<jupyter_output>Robot activated
The robot will be move for 2 seconds
Robot deactivated<jupyter_text>For extra safety if the previous code failed or stoped by the user and the motors keep moving just run the following commands.<jupyter_code>motor_a.stop()
motor_b.stop()
control.clean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09247229652273596, 'fraction_numerical': 0.01757737867787543, 'mean_word_length': 6.745562130177515, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '479282', 'license': 'MIT', 'n_tokens_mistral': 852, 'n_tokens_neox': 815, 'n_words': 272, 'path': 'source/notebooks/Courses/Basic robot movement/Basic robot movement.ipynb', 'repo_name': 'eellak/gsoc2019-diyrobot', 'size': '2617'}