Lego nxt self balancing robot tutorial


Using third-party modules 7. Sharp distance sensor 7. MPU inertial mesurement unit. Following an object using your smartphone 1. Architecture of the system 1. Connect virtual robot elements to the cloud a. System structure Nodes Topics Services. Starting system step by step Starting system step by step - Example Starting system with roslaunch Starting system with roslaunch - Example.

Creating new package Write code for your first node Building your node Running your node Subscribing to topic Receiving parameters Publishing topic Calling the service Providing a service. Simple kinematics for mobile robot 3. Forward kinematics task 3. Controlling the motor Publishing the motion command for robot Converting motion command to motor drive signal Running motor controller Determining robot position Running motor controller with forward kinematics task.

Visual object recognition 4. Making decision with recognized object 4. Getting position of recognized object 4. Following the object 4. Running ROS on multiple machines 5. Coordinate frames tracking Publishing transformation Publisher for static transformations Visualizing transformation with rviz. Running the laser scanner Navigation and map building. Introduction Graph methods Occupancy grid methods. Common parameters for cost map Parameters for local cost map Parameters for global cost map Parameters for trajectory planner Launching path planning node Setting goal for trajectory planner.

I plan to use a pre-designed robot, and start my testing with a pre-designed control algorithm that has been tested.

I reviewed the documentation in the package, which includes the following:. Instead of using parts from the Engineering Lab, I decided to buy a new educational kit to supplement our inventory. Existing parts would have been sufficient, except for the special items noted below.

I placed an order, through the college, to purchase the following parts:. The Gyro Sensor is needed to sense rotational acceleration of the robot, which is required for autonomous correction of tipping.

I expect that the parts will arrive in approximately one week. The parts ordered in week 1 arrived on schedule. The assembly process was quite simple, taking only about 30 minutes to complete. The robot consists of two large drive wheels, two motors Ports B and C, one driving each wheel , an ultrasonic distance sensor Port 2 , a gyro sensor Port 4 , the NXT controller, and an assortment of standard LEGO pieces. The gyro sensor is mounted in an orientation that allows it to sense angular accelerations of the robot when tipping about its axles.

After assembling the robot, I shifted focus onto the programming environment. I had only used Simulink once or twice, and to a very limited extent, so I spent a couple of hours becoming familiar with creating and running basic Simulink models from standard blocks.

The installation is simple: This worked on the first try, so everything is ready for testing the robot in week 3. After two weeks of preparation work, I was finally ready to test the robot! First, I wanted to make sure that the ultrasonic sensor was working properly, and try to understand the numerical values provided by the sensor to the NXT. Using the NXT display to display the sensor reading, I confirmed that the sensor was working properly.

Instead of starting with wireless Bluetooth communication, I decided to first use the more reliable wired USB connection. In order to test communication, I built a very simple Simulink model, using a Switch, two Constants, and blocks from the Lego library installed last week. The algorithm powers both motors at a constant speed 50 , but only when the input from the ultrasonic sensor is greater than or equal to 20 cm.

Unfortunately, this did not work and I received an error message. After that change, the "Run" command worked. The NXT screen indicated that the program was running, but neither motor was turning, regardless of the distance between my hand and the ultrasonic sensor.

Then I realized that the ports were set incorrectly in my Simulink model. On the second attempt, I ran the model and it worked see video! When the desk is close to the sensor, the motors stop turning. This algorithm was actually running on the NXT, not on the computer. I verified this by unplugging the USB cable and running the program directly from the NXT using the orange and gray buttons.

Having confirmed operation with a simple model, it was time to try the self-balancing algorithm provided in the package described in Week 1. This model was significantly more complicated than the one I created. By double-clicking on each block, I explored the internal logic within the block. I gained a basic understanding of the control algorithm, but without grasping all of the details. To my amazement, it actually worked "as advertised". As shown in the video, the robot remains upright, even when perturbed.

Next week, I plan to try making the robot move while it remains balanced. I also plan to try using a wireless connection, instead of USB.

Compared to my original plan see above , I am ahead of schedule. Progress has been unexpectedly smooth through the first three weeks, giving me plenty of time to explore the capabilities and limitations of this robot's design hardware and software.

First, I wanted to make the robot move forward, backward, and turning while remaining upright.