Posts

Software_Video streaming services

Image
This is the last part of the first phase. With this part completed we can control the cub while being able to see through its camera (probably even cameras) connected to the cub's raspberry pi. First I was going to use VLC for streaming the camera video but aside from an annoying 3-5 seconds delay, I did not have any easy access to individual frames for further possessing, so I decided to write a simple service for it using python, flask, and Open-CV.  The webcam used on the cub First I wrote a simple web server running on cub raspberry waiting for requests from the client-side, capturing a frame and responding with the captured frame when receiving a get request. Then I also added some meta-data to the returned data, representing frame dimensions and channels to make it easier to decode the frame automatically which happens on the client-side. Soon I realized I need to be able to change both dimensions and channels of the frames from the client-side and added some meta-data regard...

Software_Joystick service

Image
As mentioned before in this phase, before making it autonomous I am going to use a joystick to control the cub. This is what I am currently using: Logitech Extreme 3D PRO There are many ways to get the output from these devices. There are lots of libraries and we can even read the data directly from the device which is not flexible. For this purpose I am going to use SFML which is basically a lightweight 2D game engine and I have some experiences using it. The way this library is usually used is through the game loop, the loop that goes on and on through the entire period of the game, each time returning all of the events regarding mouse, keyboard, joystick, etc in the context of the game window. Since we don't need the game window and the game loop we should use the other way.  We are going to use it using the update function manually and subsequently checking for the joystick events.  To make the code more open-close I used observer/observable pattern. There is a class calle...

Software_Servo/Motor controller service

Image
I am going to cover both Servo and Motor controller services in this post since they are quite similar internally and have similar functionalities. Starting with the servo controller service, its responsibilities are to find the servo control unit port by sending the "query" command and assessing the response, connect to the servo_ctrl queue, connect to the servo controller through serial, read incoming messages from the servo_ctrl queue and to send them to the controller unit using serial. It also has a separate thread constantly checking to see if the port is still accessible and to stop the service throwing an exception if it is not, and a simple mechanism for stopping the service if a few consecutive commands send to the controller were missed (a simple implementation of the leaky bucket counter pattern). As you can see: servo_controller_service   this part consists of serial command, responsible for sending commands through serial to controller, which has a serial connec...

Software_Architecture

Image
My initial goal is to build a remotely controllable robot able to roam around the house and interact with my pets through voice or video (despite the fact that don't have any for the time being). I want to be able to see the environment through the camera of the robot while controlling it. The next phase would be to change and improve the controlling mechanism, controlling it via voice command, maybe using brain waves to control it and finally using AI and image processing to make it at least partially autonomous . Finally adding other controllable components to the house environment and making them able to interact with each other. Although it might seem like a very high-level description, but I am going to try to extract the actual requirements (architecturally significant requirements) from it. First there is the obvious need for acceptable mobility on a presumably slightly uneven floor, which is more or less addressed by the physical structure of the cub mentioned in the previo...

Electronics_Motor controller (hardware and firmware)

Image
 As mentioned before changing the original brushed DC motor with a gear-box brushed DC motor eliminated the need for controlling the rotation speed. The max speed is low and it does not really make sense to lower it. So to just changing the direction will suffice. More in DC motors I designed a simple part for it to be able to control the motor direction or to turn it off using serial:   Arduino nano   One channel relay control module x2 LM2596S DC-DC 4.5-40V Adjustable Step Down Power Supply Module   DC motor rotation control The functionality is simple. There are two relays that can have 4 states overall: 00 the motor is off 11 the motor is off 10 the direction is x 01 the direction is ~x  The assembled part is like this: The rotation controller Relays Final part   the source for the controller firmware can be found here: serial_motor_rotation_controller  It is a small and highly readable piece of code and does not need much elaboration. It reads ...

Electronics_Servo controller (hardware and firmware)

Image
We need to control multiple servo motors in this project. For example steering system is directly hooked into a servo, or possibly for a camera that we are going to need to rotate, etc. A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.  More on servomotors   The type of servos I am going to use are mostly Futaba s3003 . I have assembled a controller for multiple (up to 15) servos. Using Arduino, I have wrote a small simple program to control them using serial. The devices I have user for this part are: IIC servo controller (which is a replica of Adafruit PCA9685 PWM servo driver) Arduino nano LM2596S DC-DC 4.5-40V Adjustable Step Down Power Supply Module  The circuit is easy t...

Mechanics_Chassis

Image
  A chassis is the load-bearing framework of an artificial object, which structurally supports the object in its construction and function. More on chassis   Chassis    For this part I used a couple of metal plates and a few spacers to build a chassis and fix front and rear parts: Metal plates  First I fixed all parts on a one piece plate, but then I decided to make it more flexible and give the chassis a bit of freedom so that front and rear parts be able to turn around the same axis independently. I used a wheel like this: I fixed front and rear on two separate plates, removed the plastic wheel and used it to connect two plates. Connection between two plates   So this is the final chassis:    Completed chassis Underneath and so this form is possible now:  After all, obviously this way of fixing two parts is in no way vital and even may cause problems and be changed later.   Arash Ardeshiri June 30 2021  '