hobby lego, mindstorms, ev3

In this I made an introduction to building robots with Lego Mindstorms. In this post I will not develop my own robot but will build one of Lego’s creations: Track3r

Lego Track3r

Building

Instructions are quite simple and I was able to build in a few hours.

Lab in use

Connecting

I tested it with IR remote control and it works but I think the easiest and best way to control the robot is the iOS app.

To control the robot via app, first you need to have Bluetooth enabled both on your phone and EV3 brick:

After you install the app, connect it to the brick:

Once connected, selected the robot you want to control (Track3r in this case):

and the rest is just taking it to a test drive:

Conclusion

One problem I had was I ran out of batteries very quickly. EV3 brick take 6 AA batteries and I use rechargable batteries. After playing around with the robot for about half an hour I ran out of batteries. Unfortunately the design of the robot doesn’t take replacing batteries into account. It seems it would be a bit painful to remove the brick only to replace the batteries and put it back in. Well, there are other models I wanted to build anyway at least I have now more experience with building and controlling the pre-designed robots. I think the most fun is programming the brick so I will explore more of that in the future.

Resources

hobby lego, mindstorms, ev3, nxt-g, nxt

Lego Mindstorms EV3

Whenever I see my Lego Mindstorms kit on the shelf gathering dust I sigh then I tell myself one day I’ll find enough time to build soemthing with it again. That day was last weekend! This post is a collection of notes that I started taking when I started playing.

Terminology

I have 2 older bricks and one of the newer ones. At first glance the naming was a bit confusing. So to clarify there are 3 versions of the brick out there as outlines here.

  • The programmable bricks are all called Lego Mindstorms
  • The names of the versions are:
    • 1998: LEGO MINDSTORMS RCX
    • 2006: LEGO MINDSTORMS NXT
    • 2013: LEGO MINDSTORMS EV3
  • Also NXT has several sets:
    • LEGO MINDSTORMS NXT (8527)
    • LEGO MINDSTORMS NXT 2.0 (8547)
    • LEGO MINDSTORMS NXT Education Base Set (9797)

I have one of the education sets and one regular so I was getting confused about identifying which one was which as all the contents are mixed up at this point. The good news is shown in the same article that lists NXT sets:

  • The NXT Intelligent Brick is the same in all versions of the Mindstorms NXT sets.
  • The NXT motors are the same in all versions of the Mindstorms NXT sets. Each version has three of such motors

Since the brick is the heart and soul of the whole thing, it’s much easier to say that I have 2 NXT and 1 EV3 bricks.

Programming the brick

First, I downloaded the software and installed it:

Then plugged in the EV3 brick via USB cable:

Unfortunately, macoOS Catalina doesn’t seem to support programming yet. Even though it installs fine and sees the EV3 brick connected I couldn’t make it work. So I reverted to my Surface Pro 3 and tried Windows to do the job.

I guess this time it really worked as it asked me to upgrade firmware on the brick which I did.

After that I was able to start using NXT-G to develop my first program: An infinite loop of 2 motors moving forward

And the result is simple but good enough for the time being:

Resources

devopsaws codepipeline, git, aws_developer_tools_services

Introduction

This post is part of my mini-series about AWS Developer Tools Services

AWS CodePipeline

In the previous posts I was able to create a Git repository in CodeCommit, create a build and upload the artifacts to an S3 bucket using CodeBuild and deploy the artifacts to an EC2 instance. In this post I will use CodePipeline service to tie these steps together.

AWS CodePipeline is more like an umbrella service that it combines the the source, build and deploy steps together with some added benefits:

  • Ability to retry deployment: In CodeDeploy, if the deployment fails you have to create a new deployment manually but with Pipeline we have the option to retry the deployment which clones the failed deployment and runs the new one automatically.
  • Trigger build upon code changes: You can start builds manually or on schedule by creating triggers but you can not trigger a build when you push your code to the repository. CodePipeline handles this automatically.

Create a pipeline

Step 1: Give it a name

First step is to simply give the pipeline a name. CodePipeline can automatically create an IAM role with the required permissions. Required permissions are not really clear at this point as we haven’t connected any of the services yet. That’s why it’s very useful to keep the “Allow AWS CodePipeline to create a service role so it can be used with this new pipeline” checkbox ticked.

Step 2: Add source

Next, we choose the source provider. In this example, I will use CodeCommit. It also support Amazon ECR, Amazon S3 and GitHub.

At this stage, by using CloudWatch events we can automatically start the build. This option os provided because CodeCommit is an AWS service. If you choose GitHub as your provider you’ll see GitHub webhooks which do the same job.

Step 3: Add build

By default two build services are supported: CodeBuild and Jenkins. It’s easier to connect to CodeBuild as you just have to select your build project from the dropdown list:

You can also choose to skip this stage. If you are copying static assets from an S3 bucket for instance you wouldn’t need to build anything and would choose to skip this stage.

Step 4: Add deployment

At deployment stage, we have quite a few options:

As stated before, I will use the CodeDeploy deployment I created before:

Finally we review and create the pipeline.

Troubleshooting the pipeline

Even though my CodeBuild and CodeDeploy projects succeeded, running the CodePipeline at this point fails. The reason for this error is CodePipeline creates its own S3 bucket and CodeDeploy agent needs access to that bucket as well to be able to download the deployment artifacts. So I had to modify my policy as such:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:Get*",
        "s3:List*"
      ],
      "Resource": [
        "arn:aws:s3:::replace-with-your-s3-bucket-name/*",
        "arn:aws:s3:::aws-codedeploy-us-east-1/*",
        "arn:aws:s3:::codepipeline-us-east-1-XXXXXXXXXXX/*"
      ]
    }
  ]
}

See it in action

After fixing the policy I retried the deployment (which creates a new deployment, doesn’t actually retry the failed one)

Conclusion

In this mini-series, I investigated creating a full pipeline using AWS developer services. In future posts I will delve deeper into these services and start using other complementary services as well.

Resources