Hurdles for robot building Nepal- Part 1 – Finding the motor

Published by:

During the college days the robotics was done with wiper motor( motor used in the wiper of a car).That was the only feasible motor available in the market.On those days,we used to hear about brushed motor, brushless motor, servo motor and many more but then we did not got chance to see those.At the first International event we participated, we could see those all motors.

This incident is focused on challenging robotics of 54.5 kg.This robot is for fighting purpose of one-t0-one fight.For this the first thing will be motor of high torque and high RPM.And again the big problem in Nepali market.The motor are being found here for robotics but not that would hold 54.5 kg. Again we went back to old school time.Hunt for motor started and no possible motor was to be found and then suddenly electric scooter came in mind.The motor used in electric scooter is DC motor and we know it carries weight so it do got torque and as well as it runs so it do got high RPM so this motor is kind of motor we needed.

The very first e-bike company we visited was Terra Motors in DurbarMarg. The chief technician of that company showed us the motor used in Japanese electric scooter.The motor we saw there was a out-runner motor but we were searching for in-runner motor (out runner motor has shaft fixed and rotating body whereas in runner motor has fixed body and shaft rotating).We went to second hand bike shop to look after motor and we saw starter motor (motor that is used to start the motorcycle after self start is pressed).

DC Motor Found in Nepal

  1. Electric scooter out-runner motor : The diameter of motor was 40 cm, the breadth was 25 cm and the weight was around 8 kg.Power from 350 Watt to 800 Watt.
  2. Electric scooter in-runner motor : Diameter 15 cm, breadth 25cm and weight 7 kg.Power 2500 watt
  3. Electric Cycle out-runner motor: The diameter of motor was around 15 cm, the breadth was 15 cm and the weight was 6 kg.Power from 250 Watt to 350 Watt.
  4. Starter In-runner Motor : 6 cm diameter, 10 cm length and shaft length 3 cm.Low torque and High rpm without gear.
  5. Wiper In-runner Motor : 10 cm diameter, 10 cm length and shaft length 4 cm.High torque and Low rpm
  6. DC motors: small size of 4 cm length, 3 cm diameter and RPM vary Torque vary.

 

Model and Database seeding on Laravel 5

Published by:

feaure-laravel-neupane-com-np

The models on laravel 5 are not inside ” app/models ” rather its directly under “app” with its name. If you have installed laravel on default mode you will see “app/User.php” . Here User.php is the model class.

Default model  :            User style Model:

default-laravel-neupane-com-np                                   derived-laravel-neupane-com-np

The things i mentioned above is default way to keep model.The photo next to it shows the sorting of model in a single folder called “Models“. By this way all the models are kept under single folder Models.

There is a common mistake people do perform after doing so and the error could be seen on insertion or in seeding.Laravel 5 seed error and Model error is removed here.The error that is seen in seeding is

C:\xampp\htdocs\project_name>php artisan db:seed

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'User' not found

To solve this two things need to be edited.One is DatabaseSeeder.php which is on “app/Database/seed/” and another is the Model file: here it is User.php (but your could be the file whose class is missing ) .

On DatabaseSeeder.php :

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;

class DatabaseSeeder extends Seeder {

	/**
	 * Run the database seeds.
	 *
	 * @return void
	 */
	public function run()
	{
		Model::unguard();

		$this->call('UserTableSeeder');
	}
}

class UserTableSeeder extends Seeder {

	public function run()
	{
		DB::table('users')->delete();

		User::create(['id'=>'1','name'=>'test','email' => 'test@test.com','password' => Hash::make('test')]);
	}
}

Here One thing is added other than default i.e. ” use App\Models\User; ” Due to this, it would look upon the model class under App\Model namespace. The default namespace was just  “App” .

On the Model file: Here User.php

<?php namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract {

	use Authenticatable, CanResetPassword;

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = ['name', 'email', 'password'];

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $hidden = ['password', 'remember_token'];

}

Here the only thing that is different from the default is the namespace. ON Default file the namespace usage was just ” use namespace App; ” but now it is done as ” use namespace App\Models ; ” . Here App is the alias for app folder in laravel and since we have got models under Models folder we have used App\Models as namespace.

This is a simple knowledge on hierarchy but while doing a great project this small things may not come on mind and may take you days to find out what could be wrong on my code.

Guys, Happy Coding !

Adding Foreign Key on Laravel 5.0

Published by:

laravel

To add a Foreign key on a migration Schema, First you have the create the table Schema and then alter the table to add the Foreign Key.

Here is an example.

A fund table do have user_id foreign link.This is done by adding following lines of code on create_funds_table.php
which was created by

php artisan make:migration create_funds_table --create=funds

On the php file created by above code, following editing should be done.

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFundsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('funds', function(Blueprint $table)
		{
			$table->increments('id')->unsigned();
			$table->integer('user_id')->unsigned();
			$table->float('amount');
			$table->timestamps();
			
		});
		Schema::table('funds', function(Blueprint $table)
		{
			$table->foreign('user_id')
				->references('id')
				->on('users')
				->onDelete('CASCADE')
				->onUpdate('CASCADE');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('funds');
	}

}

I had not explained in words so if you have any queries leave feedback. Thank you.