Precision Pendulum Assembly: Software management

From wwwelab
Revision as of 20:11, 17 February 2020 by Ist176128 (talk | contribs)
Jump to navigation Jump to search

Raspberry software

PAGE UNDER CONSTRUCTION

Software management

The Raspberry Pi computer interfaces the experiment micro-controller and the e-lab servers. Without it, no remote access is possible. It's, therefore, essential it is properly setup and configured to ensure high reliability and safety.

Operating System Installation

Should you start with a blank SD card, the first task is to install the Operating System (OS). There are several OSes supporting the Raspberry Pi (RPi) available and, in theory, any of those supporting the needed software can be used. However the use of Raspbian is highly recommended. It's the official OS from the Raspberry Pi Foundation for all RPi models, it has a wide selection of supported software available on the official repositories and tutorials and guides abound, online and in other mediums.

Instructions below this point assume that Raspbian is being used. Other OSes may have different configuration methods.

When creating a new SD card, the latest version of the OS should be installed. This ensures that the system is going to run with all the available security and performance fixes available. The latest version of Raspbian can be downloaded from this link. Three versions are available:

  • The lite version contains the minimal amount of software needed to boot the RPi. No extra software is included. This implies the lack of a Graphical User Interface (GUI), meaning that, if connected to a display, the RPi will show only a command line (as pictured).
  • The desktop version contains the same software as the lite version plus the software needed to use a GUI. When connected to a display, the RPi will show a GUI (pictured).
  • The desktop and recommended software version contains the same software as the desktop version plus some pre-selected software and utilities.

The same software is available for installation on all versions, meaning that one can start with a lite version and later install all the software included in the desktop and recommended software version. If the RPi is being prepared to run solely as a server for the experiment, it's recommended that the lite or desktop version is chosen, as having an OS with only the needed software is safer, improves performance and maintainability. In particular, if you plan to use the RPi without a display, the lite version is of special interest as it doesn't package the GUI, which is only useful if you use a display.

The Raspberry Pi Foundation provides installation instructions for the Raspbian OS here.

After Installation

After installing the OS, the SD card is now ready to be used to boot the RPi. However, before inserting the SD card on the RPi, one needs to consider how to interface it the RPi. It's possible to do so through two different methods, as follows:

Using the RPi through a keyboard, mouse and display

When using a keyboard, mouse and display, the RPi works just like any other computer. Since it's possible to interface with the RPi through the keyboard, mouse and display, the SD card can be inserted into the RPi and the boot process can be started by connecting the power adapter to the RPi. This is a simpler procedure, however the extra hardware needed makes it more expensive. Do not connect the RPi to the internet before completing the OS configuration, as described below.

Connecting to the RPi through a ssh connection

If a keyboard, mouse and display are not available to use and interact with the RPi, it's still possible to interact with it by setting up the SSH service before inserting the SD card into the RPi. The SSH service allows connections with a RPi via a network interface, through which commands can be sent. This makes use of the keyboard, mouse and display of a second computer, e.g. a already setup laptop or desktop computer. To do so, the Raspberry Pi and the computer used need their network setting to be adjusted.

To enable the SSH service on the RPi externally:

  • Insert the SD card into a computer, e.g. the one used to install the OS on the card.
  • After installing the OS, the card will show on computers as being composed of two drives. A smaller drive of a few hundred MBs and a larger drive of a few GBs (depending on the size of the SD card).
  • On the smaller "drive", create an empty file called ssh. This enables the SSH service during the next boot of the RPi only. This setting will be made permanent later.
  • On the bigger "drive", edit the file "/etc/dhcpcd.conf". On the end of the file, there should be a section of text similar to this:
# It is possible to fall back to a static IP if DHCP fails:
# define static profile
profile static_eth0
static ip_address=123.123.123.123/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
interface eth0
fallback static_eth0

Edit the file so it mimics the text shown above. The line:

static ip_address=123.123.123.123/24

Defines the fallback IP address of the Raspberry Pi when it receives no IP offers through DHCP. In general, this happens when no connection is available on the network or it has been connected to a common laptop or desktop computer. Other fallback IP's other than 123.123.123.123 can be chosen. This one is suggested as it's easy to remember.

  • The SD card can now be safely unmounted from the computer and inserted into the Raspberry Pi and booted

Next, the computer that will connect to the RPi must have it's own Ethernet connection configured so it connects to the same subnet as the RPi. This means that, following the configuration shown above, its' IP should be configured to be 123.123.123.xxx, where the last number can be any from 001 to 254, and a netmask of 255.255.255.000. The exact procedure to follow to accomplish this is highly dependent on the OS installed on the computer. Be sure to proceed in a way appropriate for your specific OS. If your computer uses the Ethernet port for day-to-day internet connection, it's possible that some specific configuration is attributed to it to make this connection possible on your network. Be sure to preserve the original network settings, by either taking screenshots of the appropriate dialogs or taking notes, of your Ethernet adapter so you can rollback any changes made. Below are some examples for common OSes.

Configuring the Ethernet Adapter on Windows 10/8.1/7 and connecting to the RPi
  • Microsoft provides instructions on how to manually configure the Ethernet adapter.
  • Follow the procedure for manually configuring IPv4 settings. When prompted, fill the IP Address field with an appropriate address according to the configuration selected for the RPi. Assuming the example configuration shown on this page was selected, this field can be filled with 123.123.123.124, and the field Subnet prefix length/Subnetmask can be filled either with 255.255.255.0 or 24. Settings regarding the Gateway and DNS fields and IPv6 can be ignored.
  • If not done so before, the RPi can be booted and connected to the computer throught Ethernet. This is accomplished by connecting one end of an Ethernet cable to the Ethernet port of the computer and the other end of the cable to the Ethernet port of the RPi
  • The network symbol on the Windows tray should now show the Ethernet connection. Possibly stating it is an unknown network.
  • Windows does not install a SSH client by default. To connect to the RPi via SSH one must be set up. Although others can be used, putty is an open source, free software SSH client for Windows. It can be installed or used as standalone, meaning no install necessary. The following steps will follow the use of putty. Be aware that although the general configuration also applies to other software, specific instructions may differ.
  • Fill the field Host Name (or IP Address) with the configured IP of the RPi. If the suggested configuration is being followed, this should be filled with 123.123.123.123. On the radio buttons below, select SSH. If you wish to save this configuration so that it's not needed to remember or rewrite it every time, write any memorable name on the field Saved Sessions and click Save. You can then retrieve this settings by selecting the name from the list and selecting Load.
  • A warning can appear stating that the host, the computer you're connecting to, is new and unknown. You'll be asked if the new computer can be trusted and the connection completed. Since this a fresh install of a computer you own and have setup by yourself, you can safely answer yes. When prompted, input the password. If this is not the first time following this guide, it's possible that the warning states that the host, the computer you're connecting to, has changed. This is expected as you can now be applying theses steps to a different RPi. Accept the warning by selecting Yes and the connection should be completed.
  • When prompted for the user and password, input the default user and password of the Raspian OS which can be found here.
  • Note that in this case pi and 123.123.123.123 are used since we're connecting to the RPi as user pi and it's directly connected to the computer with the configured IP of 123.123.123.123. After creating a new user and deleting the default one and connecting the RPi to regular network, this will change.
  • After successfully inputting the default password, a prompt will be shown stating:
pi@raspberry:~ $

You have logged in successfully and can now proceed to the RPi Operating System Configuration

  • If there was an error stating

ssh: connect to host xxx.xxx.xxx.xxx port 22: No route to host Where xxx.xxx.xxx.xxx is the IP used in the ssh command, the Ethernet adapters have been misconfigured. Please, revisit the configuration of the adapters. For a successful connection both the computer and the RPi must be configured to be in the same subnet. If you haven't followed the IP configuration suggested here, please note it is known to provide a functional set up.

Configuring the Ethernet Adapter on Linux using Network Manager and connecting to the RPi
  • Linux isn't a monolithic OS. What is generally know as Linux is a set of several distributions, also know as distros, that build an OS on the same basis, the Linux kernel. Depending on the distro used, the specific procedure to follow will differ. The following procedure applies to distros that have Network Manager setup to manage connectivity. This is the case for most of the popular distros, such as Ubuntu and its flavours, Linux Mint, Fedora, etc.
  • Right click on the Network Manager icon and select edit connections
  • Click on the + sign on the bottom left of the window,select Ethernet on the dialog shown and click create. By creating a new configuration, the settings used for regular internet access are preserved, making it easier to roll back the changes.
  • The name field can be filled with any name, although it's recommended to write an easy to remember one, such as Raspberry or Ethernet RPi.
  • Select the IPv4 Settings tab and, on the Method dropdown menu, select Manual.
  • Click Add next to the Adresses table and, when prompted, fill the Address field with an appropriate address according to the configuration selected for the RPi. Assuming the example configuration shown on this page was selected, this field can be filled with 123.123.123.124, and the neighboring field Netmask can be filled either with 255.255.255.0 or 24.
  • The rest of the fields can be safely ignored. Click Save to save the new connection settings. The new settings will now appear on the list with the name selected.
  • If not done so before, the RPi can be booted and connected to the computer throught Ethernet. This is accomplished by connecting one end of an Ethernet cable to the Ethernet port of the computer and the other end of the cable to the Ethernet port of the RPi
  • The Network Manager icon should now show a spinning symbol, as it tries to connect to the RPi. Click on the Network Manager symbol and on the menu select the Ethernet connection with the name chosen before. The connection should now be set up.
  • Most Linux distros include SSH client software on the default OS install, making it unnecessary to install any additional software. SSH commands follow the syntax ssh user@ip or ssh user@hostname. The default user and password of the Raspian OS can be found here. To connect to the RPi open a terminal on the computer, and write
ssh pi@RPI ADDRESS

RPI ADDRESS should be replaced by the IP address selected for the RPi on the previous section. Assuming the configuration suggested was followed, the command should be

ssh pi@123.123.123.123

Note that in this case pi and 123.123.123.123 are used since we're connecting to the RPi as user pi and it's directly connected to the computer with the configured IP of 123.123.123.123. After creating a new user and deleting the default one and connecting the RPi to regular network, this will change.

  • A warning can appear stating that the host, the computer you're connecting to, is new and unknown. You'll be asked if the new computer can be trusted and the connection completed. Since this a fresh install of a computer you own and have setup by yourself, you can safely answer yes. When prompted, input the password. If this is not the first time following this guide, it's possible that the warning states that the host, the computer you're connecting to, has changed. This is expected as you can now be applying theses steps to a different RPi. Edit the file stated on the warning and delete the line starting with the IP of the RPi. If the example configuration is being followed, this will be the line starting with 123.123.123.123. Attempt to reconnect by using the SSH command again. You should know see the warning stating this is a new, unknown computer.
  • After successfully inputting the default password, a prompt will be shown stating:
pi@raspberry:~ $

You have logged in successfully and can now proceed to the RPi Operating System Configuration

  • If there was an error stating

ssh: connect to host xxx.xxx.xxx.xxx port 22: No route to host Where xxx.xxx.xxx.xxx is the IP used in the ssh command, the Ethernet adapters have been misconfigured. Please, revisit the configuration of the adapters. For a successful connection both the computer and the RPi must be configured to be in the same subnet. If you haven't followed the IP configuration suggested here, please note it is known to provide a functional set up.

Configuring the Ethernet Adapter on MacOS Catalina/Mojave/High Sierra and connecting to the RPi
  • Apple provides instructions on how to manually configure the Ethernet adapter.
  • Follow the procedure for manually configuring IPv4 settings. When prompted, fill the IP Address field with an appropriate address according to the configuration selected for the RPi. Assuming the example configuration shown on this page was selected, this field can be filled with 123.123.123.124, and the field Subnetmask can be filled either with 255.255.255.0 or 24. Settings regarding the Gateway and DNS fields and IPv6 can be ignored.
  • If not done so before, the RPi can be booted and connected to the computer throught Ethernet. This is accomplished by connecting one end of an Ethernet cable to the Ethernet port of the computer and the other end of the cable to the Ethernet port of the RPi
  • The network symbol should now show the connection as being completed.
  • MacOS includes a SSH client on the default OS install, making it unnecessary to install any additional software. SSH commands follow the syntax ssh user@ip or ssh user@hostname. The default user and password of the Raspian OS can be found here. To connect to the RPi open a terminal on the computer, and write
ssh pi@RPI ADDRESS

RPI ADDRESS should be replaced by the IP address selected for the RPi on the previous section. Assuming the configuration suggested was followed, the command should be

ssh pi@123.123.123.123

Note that in this case pi and 123.123.123.123 are used since we're connecting to the RPi as user pi and it's directly connected to the computer with the configured IP of 123.123.123.123. After creating a new user and deleting the default one and connecting the RPi to regular network, this will change.

  • A warning can appear stating that the host, the computer you're connecting to, is new and unknown. You'll be asked if the new computer can be trusted and the connection completed. Since this a fresh install of a computer you own and have setup by yourself, you can safely answer yes. When prompted, input the password. If this is not the first time following this guide, it's possible that the warning states that the host, the computer you're connecting to, has changed. This is expected as you can now be applying theses steps to a different RPi. Edit the file stated on the warning and delete the line starting with the IP of the RPi. If the example configuration is being followed, this will be the line starting with 123.123.123.123. Attempt to reconnect by using the SSH command again. You should know see the warning stating this is a new, unknown computer.
  • After successfully inputting the default password, a prompt will be shown stating:
pi@raspberry:~ $

You have logged in successfully and can now proceed to the RPi Operating System Configuration

  • If there was an error stating

ssh: connect to host xxx.xxx.xxx.xxx port 22: No route to host Where xxx.xxx.xxx.xxx is the IP used in the ssh command, the Ethernet adapters have been misconfigured. Please, revisit the configuration of the adapters. For a successful connection both the computer and the RPi must be configured to be in the same subnet. If you haven't followed the IP configuration suggested here, please note it is known to provide a functional set up.

RPi Operating System Configuration

After installation, the OS needs to be configured. The first task before connecting the RPi to the internet must be to create a new user and delete the default user. Since all fresh Raspbian OS installs have the same default user and password, that everyone can find on the internet, keeping them available on the OS is a very serious security vulnerability. Anybody that knows this is free to try to login into your RPi and, if successful, take control of the system.

Autonomous codes

Hardware Server

Open terminal on HardwareServer machine (in this case RPi) and folow the procedure:

  • Validate if rec-deployement directory exits, if not create by typing:
    mkdir ${home_directory}/rec-deployement 
  • Unzip HardwareServer's zip file to rec-deployment directory
    unzip ${hardwareServerZipLocation}/${hardwareServerZipFile} -d ${home_directory}/rec-deployement/${hardwareServerAliasName}
  • Start HardwareServer:
    cd ${home_directory}/rec-deployement/${hardwareServerAliasName} && ./Start${AliasName}Driver.sh
  • NOTE The HardwareServer should only be deploy after the complete calibration procedure described on the next page.

    Video Streaming

    The video streaming is done by direct capture of the USB Webcam assigned as Video0 and encoded tu RSTP as...

    Next Page (Calibration)