Working on a voice control robot: Arduino, TS900 chassis, and 298n motor controllers

I used an arduino to control the motor controller for now. I plan to upgrade to a Raspberry pi 4 to control the motors and also run the speech recognition program pocket sphinx from Carnegie Mellon University. I have the speech recognition working as in “robot go forward” on a raspberry pi 3 but it takes around 5 seconds after saying it to recognize that’s what I said. I hope the raspberry pi 4 is quicker. The motor controller circuit is called 298N. With arduino there is a new programming language to use but it’s pretty simple. With Raspberry pi 3 and 4 you can use python.

I bought the chassis from Amazon:

gazechimp Obstacle Avoidance 4-Drive Rc Robot Tank Car Chassis Shock Absorption Car

You can get it at a better price somewhere else now. When I bought it, it was $160. The chassis includes 4 motors, but not the motor controller.Edit or delete this

motor controller link: Qunqi L298N Motor Drive Controller Board Module Dual H Bridge DC Stepper For Arduino

raspberry pi 4 link: https://www.amazon.com/…/ref=ppx_yo_dt_b_asin_title_o00…

DIY Speech Recognition using Raspberry PI & CMU Sphinx

This article is good but it doesn’t mention downloading, building and installing pocketsphinx, only sphinxbase.

https://medium.com/@ranjanprj/for-some-time-now-i-have-been-thinking-really-hard-to-build-a-diy-study-aid-for-children-which-uses-17ce90e72f43

I got it working after following the additional instructions here:

https://cmusphinx.github.io/wiki/tutorialpocketsphinx/

Networking with Retrofit

6.1 Retrofit basics

Retrofit (https://square.github.io/retrofit) is a library written by Square, which makes working with HTTP(S) APIs a breeze.

You define an interface in Kotlin, which specifies the REST connection to the server.  REST is a way to communicate with servers in an idiomatic way. You can then use this interface and a class you create of the HTTP response, to get back a Kotlin object, which you can then use in your code.

One example of REST is performing a GET request for a list of items.  Another would be performing a DELETE on an item object.

6.2 Retrofit set up

In your build.gradle, in the app folder, in the dependencies section, place the following:

implementation ‘com.squareup.retrofit2:retrofit:(insert latest version)

You can find the latest version by visiting this page:

https://github.com/square/retrofit/releases

In a Kotlin file put the following code in a file called MyService:

interface MyService {

  @GET(“users/{user}/items”)

  fun listItems(@Path(“user”) String user): Call<List<Item>>

}

You can set up and retrieve data in the following way:

val retrofit= new Retrofit.Builder()

.baseUrl(“https://api.example.com/”)

    .build();

val service = retrofit.create(MyService.class);

val items = service.listItems(“john”);

Although this is quick and easy, it isn’t the only option for data transfer in Kotlin. You could also use only OKHttp (https://square.github.io/okhttp/) to interact with REST services and get back a response string and then parse the JSON manually, or Picasso (https://square.github.io/picasso/ ) to load images into ImageViews easily. Picasso and OKHttp can be used in conjunction with Retrofit.

6.2 Retrofit Interceptors

In case you want to see what connections are being made behind the scenes, you can add an interceptor to Retrofit.  You can also use interceptors to add global headers to your request.

Register an interceptor by calling addInterceptor() on OkHttpClient.Builder:

val client = OkHttpClient.Builder()

       .addInterceptor(LoggingInterceptor())

       .build()

After configuring your OKHttp client, you can tell Retrofit to use that client:

val retrofit = Retrofit.Builder()

       .baseUrl(“https://api.example.com/”)

       .client(client)

       .build()

In a new Kotlin file called LoggingInterceptor.kt place the following code. 

class LoggingInterceptor : Interceptor {

  

   val TAG = “LoggingInterceptor”

  

   @Throws(IOException::class)

   override fun intercept(chain: Interceptor.Chain): Response {

       val request = chain.request()

       val t1 = System.nanoTime()

       Log.i(TAG,

           String.format(

               “Sending request %s on %s%n%s”,

               request.url(), chain.connection(), request.headers()

           )

       )

       val response = chain.proceed(request)

       val t2 = System.nanoTime()

       Log.i(TAG,

           String.format(

               “Received response for %s in %.1fms%n%s”,

               response.request().url(), (t2 – t1) / 1e6, response.headers()

           )

       )

       return response

   }

}

Now your responses will include the URL and time it took to receive the response.

Navy Confirms UFO Videos Posted by Blink 182 Rocker Are Real and Should Not Have Been Released