wtorek, 10 lipca 2018

How to install MATE Desktop Environment in CentOS 7 minimal - full guide

MATE Desktop is Linux GUI based on GNOME 2
Installing MATE on Centos 7 is easy.

First step:
Check internet connection, if you want use DHCP run this:
dhclient

If internet connection is working update pckage:
yum update

Install epel-release:
yum install epel-release

Install kernel-devel:
yum install kernel-devel

Install X Window system:
yum groupinstall "X Window system"

Install MATE Desktop:
yum groupinstall "MATE Desktop"

Now you can run MATE Desktop using:
systemctl isolate graphical.target

Set MATE Desktop Environment as deflaut GUI:
systemctl set-default graphical.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'

If something goes wrong install Development Tools:
yum groupinstall "Development Tools"


Optional is install GNOME Disc Utility:
yum install gnome-disk-utility

Best of the best for using KVM over IP to remote administration.
MATE Desktop homepage:
https://mate-desktop.org/

środa, 4 lipca 2018

Problem with power off computer in Windows 10 - guide to fix it

Problem description:
When power off computer use log out and show start screen but can't power off computer.

Platform:
Windows 10 64-bit

Solutions:
In control panel in "Hardwear and Sound" (polish: Sprzęt i dźwięk) select "Change what the power buttons do" (polish: Zmień działanie przycisków zasilania) and click on: "Change settings that are currently unavailable" (polish: Zmień ustawienia, które są obecnie niedostępne). Uncheck all option. Problem was fixed.

How to build GDAL from source for Visual C++ in Visual Studio

The goal of the project:
Download, compile and add GDAL library for Visual C++ project in Visual Studio IDE.

What is a GDAL?
is a translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single raster abstract data model and single vector abstract data model to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing. The NEWS page describes the June 2018 GDAL/OGR 2.3.1 release.

Source: http://www.gdal.org

Step 1:

Visit in GDAL website (http://www.gdal.org) and go to section "Developer Oriented Documentation" after that enter "Building GDAL From Source".
Link: http://trac.osgeo.org/gdal/wiki/BuildHints













Step 2:

Download source package (I recomend lastest stable release).
For windows it is gdal.zip
example: gdal321.zip














Step 3:
Unzip it uzing 7ZIP, WinRAR or another tool for unzip file.














Step 4:
Run power shell (or command line [cmd.exe]):














Step 5:
Run generate_vcxproj.bat script in Power Shell with parametrs.
Instruction and description:
https://trac.osgeo.org/gdal/wiki/GeneratingVisualStudioProject













Step 6:
Run gdal_vsXXXX.vcxproj in visual studio
Where XXXX - version of visual studio
example: gdal_vs2015.vcxproj













Step 7:
Build project in visual studio
Use Build -> Build Solutions
or use CTRL + SHIFT + B














Sucessful compilation:













Step 8:
Create new Visual C++ project in Visual studio.















Select finish.
















Build project for test.
If use x64 processor set project to x64.














Stel 9:
Add GDAL library and other GDAL files to this project.
Select "properties" from project.













In VC++ Directories edit Include Directores:














Add directories:
C:\Users\zoz\Desktop\gdal-2.3.1
C:\Users\zoz\Desktop\gdal-2.3.1\gcore
C:\Users\zoz\Desktop\gdal-2.3.1\apps
C:\Users\zoz\Desktop\gdal-2.3.1\port
C:\Users\zoz\Desktop\gdal-2.3.1\ogr
"zoz" is username.














Add to Library Directories:
$C:\Users\zoz\Desktop\gdal-2.3.1
$C:\Users\zoz\Desktop\gdal-2.3.1\gcore
$C:\Users\zoz\Desktop\gdal-2.3.1\port
$C:\Users\zoz\Desktop\gdal-2.3.1\apps
$C:\Users\zoz\Desktop\gdal-2.3.1\ogr














Add in Linker -> Input -> Additional Dependencies
"C:\Users\zoz\Desktop\gdal-2.3.1\gdal_i.lib"
Click EDIT in this selection




























If add GDAL library is could successful build.
#include














Main site of project:
http://www.gdal.org
GDAL FAQ:
http://trac.osgeo.org/gdal/wiki/FAQ

Used softweare:
Windows 10 64-bit PRO
GDAL version: 2.3.1
Microsoft Visual Studio 2015 version 14.0.25431.01 Update 3
Microsoft .NET Framework 4.7.03056














Video on youtube:
https://youtu.be/Yf8rYOfvZjY

sobota, 21 kwietnia 2018

Lazy Robot V1 - Część 6/8 - Moduł bluetooth i komunikacja

Podłączenie do modułu:



















Kod źródłowy:
/*                      Download from Lazy Admin Blog                        */
/* Blog URL:     https://lazyadminblog.blogspot.com                          */
/* Mail:         lazychannelandblog@gmail.com                                */
/* YouTube:      https://www.youtube.com/channel/UC8DB_NVekpEIuG-SAvpXOWQ    */
/* GitHub:       https://github.com/LazyAdminBlog                            */

int BLUETOOTH_SERIAL_INPUT; /* Variable to save input data from bluetooth module */

void setup()
{
  Serial1.begin(9600);  /* Begin serial port (bluetooth port). Set the data rate in bits (9600 bits per second (baud). */
  Serial1.println("Bluetooth X-Bee comunication test sucessful.");  /* Write to serial port (bluetooth) control text. */
}

void loop()
{
  if(Serial1.available() >= 0) /* Check available of serial port (bluetooth) and chack which number was input (if >= go to next step). */
  {
      BLUETOOTH_SERIAL_INPUT = Serial1.read();  /* Read data from serial port (bluetooth) and save to BLUETOOTH_SERIAL_INPUT variable */
  }
  switch(BLUETOOTH_SERIAL_INPUT)              /*  Switch case instruction to control robot                                  */
  {
    case '1':
      Serial1.println("First test pass.");   /* Write text: "First test pass." if read "1" from serial port (bluetooth).  */
      break;
    case '2':
      Serial1.println("Second test pass.");  /* Write text: "Second test pass." if read "2" from serial port (bluetooth). */
      break;
    default:
      break;
  }
}

Lazy Robot V1 - Część 5/8 - Sterowanie napędem robota

    W tej części opiszę sterowanie silnikami napędowymi robota. Na płytce Romeo V2 znajduje się układ sterowania silnikami L298P, za jego pomocą będziemy mogli manipulować prędkością oraz kierunkiem obrotu silników lub je zatrzymać.

Na płytce Romeo V2 należy ustawić odpowiednio cztery zworki.
Znajdują się one w sekcji Motor Mode Jump (zaznaczone kolorem fioletowym).



















Poprawne ustawienie zworek przedstawia obrazek:


















Podłączenie silników do modułu:














Kod źródłowy:
/*                      Download from Lazy Admin Blog                        */
/* Blog URL:     https://lazyadminblog.blogspot.com                          */
/* Mail:         lazychannelandblog@gmail.com                                */
/* YouTube:      https://www.youtube.com/channel/UC8DB_NVekpEIuG-SAvpXOWQ    */
/* GitHub:       https://github.com/LazyAdminBlog                            */

int MOTOR_1_RIGHT_DIRECTION = 4; /* Variable to save Motor 1 direction.      */
int MOTOR_1_RIGHT_SPEED = 5;  /* Variable to save Motor 1 speed (values from 0 to 255). */

int MOTOR_2_LEFT_SPEED = 6;   /* Variable to save Motor 2 speed (values from 0 to 255). */
int MOTOR_2_LEFT_DIRECTION = 7;  /* Variable to save Motor 2 direction      */

void motor_stop(void) /* Function to stop robot (stop motors) */
{
  digitalWrite(MOTOR_1_RIGHT_SPEED,LOW); /* Set low signal on right motor                */
  digitalWrite(MOTOR_2_LEFT_SPEED,LOW);  /* Set low signal on left motor                */
}

void motor_drive_forward(char a, char b)      /* Function to driveing forward using motors    */
{
  analogWrite(MOTOR_1_RIGHT_SPEED,a);         /* Set speed of right motor                     */
  digitalWrite(MOTOR_1_RIGHT_DIRECTION,LOW);  /* Set low signal on right motor                */
  analogWrite(MOTOR_2_LEFT_SPEED,b);          /* Set speed of left motor                      */
  digitalWrite(MOTOR_2_LEFT_DIRECTION,LOW);   /* Set low signal on left motor                 */
}

void motor_drive_back(char a, char b)         /* Function to driveing back using motors */
{
  analogWrite(MOTOR_1_RIGHT_SPEED,a);         /* Set speed of right motor               */
  digitalWrite(MOTOR_1_RIGHT_DIRECTION,HIGH); /* Set high signal on right motor         */
  analogWrite(MOTOR_2_LEFT_SPEED,b);          /* Set speed of left motor                */
  digitalWrite(MOTOR_2_LEFT_DIRECTION,HIGH);  /* Set high signal on left motor          */
}

void motor_turn_right(char a, char b)    /* Fuction to turn right the robot.  */
{
  analogWrite(MOTOR_1_RIGHT_SPEED,a);         /* Set speed of right motor               */
  digitalWrite(MOTOR_1_RIGHT_DIRECTION,LOW);  /* Set low signal on right motor          */
  analogWrite(MOTOR_2_LEFT_SPEED,b);          /* Set speed of left motor                */
  digitalWrite(MOTOR_2_LEFT_DIRECTION,HIGH);  /* Set high signal on left motor          */
}

void motor_turn_left(char a, char b)    /* Fuction to turn left the robot.  */
{
  analogWrite(MOTOR_1_RIGHT_SPEED,a);         /* Set speed of right motor               */
  digitalWrite(MOTOR_1_RIGHT_DIRECTION,HIGH); /* Set high signal on right motor         */
  analogWrite(MOTOR_2_LEFT_SPEED,b);          /* Set speed of left motor                */
  digitalWrite(MOTOR_2_LEFT_DIRECTION,LOW);   /* Set low signal on left motor           */
}

void setup()
{
  /* Set pins 4, 5, 6,7 as OUTPUT (pins for left and right motor */
  for(int i=4; i<=7; ++i)
  {
    pinMode(i,OUTPUT); /* Mode pin "i" as output pin. */
  }
}

void loop()
{
  motor_drive_forward(255,255); /* Drive forwart with maximal speed           */
  delay(8000);     /* Wait 8 secound                */
  motor_stop();     /* Stop all motos                */
  delay(8000);     /* Wait 8 secound                 */
  motor_drive_back(255,255); /* Drive back with maximal speed            */
  delay(8000);     /* Wait 8 secound                 */
  motor_stop();     /* Stop all motos                */
  delay(8000);     /* Wait 8 secound                 */
  motor_turn_right(150,150); /* Turn right with 150/255 speed. It is minimal speed for rotate robot   */
  delay(8000);     /* Wait 8 secound                 */
  motor_stop();     /* Stop all motos                */
  delay(8000);     /* Wait 8 secound                 */
  motor_turn_left(150,150);  /* Turn left with 150/255 speed. It is minimal speed for rotate robot   */
  delay(8000);     /* Wait 8 secound                 */
  motor_stop();     /* Stop all motos                */
  delay(8000);     /* Wait 8 secound                 */
}



Opis sterowania silnikami na stronie producenta:
https://www.dfrobot.com/wiki/index.php/Romeo_V2-All_in_one_Controller_(R3)_(SKU:DFR0225)

Źródło zdjęcia z pinami Romeo V2:
https://www.dfrobot.com/wiki/index.php/File:RomeoV2R3.png
Źródło zdjęcia z ustawieniami zworek pinów silników:
https://www.dfrobot.com/wiki/index.php/File:RomeoMotorJmp.png

Lazy Robot V1 - Część 4/8 - Czujnik ultradźwiękowy HC-SR04

Podłączenie i test ultradźękowego czujnika odległości HC-SR04


Schemat podłączenia ulradźwiękowego czujnika odległości HC-SR04:


















Kod źródłowy:
/*                      Download from Lazy Admin Blog                        */
/* Blog URL:     https://lazyadminblog.blogspot.com                          */
/* Mail:         lazychannelandblog@gmail.com                                */
/* YouTube:      https://www.youtube.com/channel/UC8DB_NVekpEIuG-SAvpXOWQ    */
/* GitHub:       https://github.com/LazyAdminBlog                            */

#define ULTRASONIC_TRIG_PIN 11 /* Define witch pin will be HC-SR04 TRIG */
#define ULTRASONIC_ECHO_PIN 12 /* Define witch pin will be HC-SR04 ECHO */

int read_distance()
{
  long duration, distance;       /* Declarete duratuion and distance variable long type */
  digitalWrite(ULTRASONIC_TRIG_PIN, LOW);   /* Chance TRIG pin state to LOW       */
  delayMicroseconds(2);        /* Wait 2 miliseconds         */
  digitalWrite(ULTRASONIC_TRIG_PIN, HIGH);   /* Chance TRIG pin state to HIGH      */
  delayMicroseconds(10);       /* Wait 10 miliseconds         */
  digitalWrite(ULTRASONIC_TRIG_PIN, LOW);   /* Chance TRIG pin state to LOW       */
  duration = pulseIn(ULTRASONIC_ECHO_PIN, HIGH); /* pulseln() on ECHO pin to HIGH      */
  distance = (duration/2) / 29.1;     /* distaince calculation        */
  
  if (distance >= 200 || distance <= 0)  /* If read value is >=200 or >=0 */
  {
    return 999;   /*  Function return 999 it's error (out of range)  */
  }
  else
  {
    return distance; /* Function return correct distaince     */
  }
}

void setup()
{
 Serial.begin(9600);  /* Initial serial port (COM) for arduino with 9600 bits per second speed */
 pinMode(ULTRASONIC_TRIG_PIN, OUTPUT); /* Set TRIG pin as output*/
 pinMode(ULTRASONIC_ECHO_PIN, INPUT); /* Set ECHO pin as input*/
}

void loop()
{
 Serial.println(read_distance()); /* Print for serial result of function read_distance() */
 delay(500);       /* Wait 0.5 second */
}



Opis funkcji pulseIn():
https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein/

Lazy Robot V1 - Część 1/8 - Opis projektu i potrzebne części

Nazwa projektu: Lazy Robot V1

Cel projektu:
Budowa robota z podwoziem gąsienicowym sterowanego poprzez interfejs bluetooth za pomocą aplikacji mobilnej.

Zakres funkcjonalności:
-sterowanie ręczne i jazda we wszystkich kierunkach z poziomu aplikacji mobilnej
-czujnik temperatury i wilgotności z możliwością odczytywania poprzez aplikację mobilną
-tryb autonomiczny realizowany poprzez czujnik ultradźwiękowy umieszczony na serwomechanizmie pozwalający na jazdę z omijaniem przeszkód
-połączenie robota odbywa się z poziomu aplikacji mobilnej

Zakres projektu:
-R&D elementów elektronicznych oraz mechanicznych, wybór użytych komponentów
-testowanie poszczególnych elementów robota
-integracja i złożenie w całość gotowego robota
-napisanie kodu do robota oraz aplikacji mobilnej oraz testowanie całości

Potrzebne elementy:
•Podwozie robota Arexx Robby RP5/RP6robot RP5-CH02 EAN: 8717371230135
Cena: 145,14 PLN + wysyłka (stan na 5 kwietnia 2018)

•Czujnik ultradźwiękowy HC-SR04

•GoldPin męskie proste 2.54mm (1mils) rzędy po 3 oraz 4 sztuki.

•Serwomechanizm MicroServo 9g SG90

•Płytka DFRobot Romeo V2

•Moduł Bluetooth V2 X-Bee Haoyu Electronics
Strona producenta: www.PowerMCU.com
Cena: 49.50 PLN + wysyłka (stan na 5 kwietnia 2018)
można zastąpić innym modułem bluetooth na złącze XBee

•Czujnik temperatury i wilgotności DHT-11

•Rezystor 10k Ω (Ohm) +/- 5% węglowy
Koszt 0.05 PLN

•GoldPin żeńskie na kabel 20x

•Płytka prototypowa dwustronna

•Cztery zworki 2.54mm (1mils)
Zworki będą potrzebne do ustawienia trybu pracy silników.


•Koszyk na sześć baterii AA (R6) wersja 3x2

•Kolorowe kable do goldpinów

•Obudowy na GoldPiny:
-1x4 dwie sztuki
-2x3 jedna sztuka
-1x3 trzy sztuki

•Kawałek miedzianej blaszki do włożenia pomiędzy baterię
(można zastąpić regulatorem napięcia 7805)


Robot do działania potrzebuje sześciu baterii AA (R6). Nie wliczałem ich do cennika gdyż korzystałem z własnych akumulatorków.
Telefon na którym testowałem aplikację posiada androida w wersji 6.0.1 oaz bluetooth w wersji V4.2
Kabel Micro-USB do telefonu z opcją transmisji danych pozwoli na wgrywanie oprogramowania do mikro kontrolera.


Źródła:
Zdjęcia Modułu bluetooth pochodzą z:
https://elty.pl/pl/p/Bluetooth-V2.0-wireless-module-XBee-pin-compatible/146
http://www.powermcu.com/