Skip to content

CSU-Robosub-2017-2018/Controls

Repository files navigation

Robosub: Controls 2017-2018

Last Updated: April 27, 2018

CSU Robosub team is a senior desgin team with the goal of creating an autonomous underwater vehicle (AUV). The vehicle is made to compete in the nationonal robosub competition hosted by the navy in California.

The 2017-2018 team is "vertically integrated" meaning that it is made up of 11 seniors as well as 4 underclassman and 2 gradutate advisors. The team is split up into 4 different subteams: Propulsion, Sensors, Mechanical, and Controls.


Controls

The controls subteams goal is to integrate sensors and propulsion systems to make the AVU autonomous. We worked really hard in the 2017-2018 academic year to provide a robust variety of libraries specifially tailored to the robosub. They include:

  • Computer Controller Motor Drivers
  • PID Controller
  • Xbox Controller Support
  • Integration with Sensors.

Motor Driver

This driver is the interface between running vision and stabilization on the Raspberry pi and Controlling the Electronic speed controllers(ESC) of the Propulsion subteams Motors.

Originally the decision was made to try and run all of the motor ESCs off of a PWM singal generated by an Arduino. All of our code was to be run off of a Raspberry Pi then sent to the Arduino.

A Considerable amount of time was spent trying to create a reliable interface between the Raspbewrry Pi and Arduino. Several methods of doing this were considered including SPI, I2C, and UART. Eventually it was decided to use serial because it only needed the USB cable to operate. This effort was abandon because a information was never able to be reliablly communicated between over serial. The communication would be consistant one run then not exsistant another.

We switched over to using and Adafruit 12bit PWM hat to control the ESCs. This solution is considerallby more reliable than the Arduino. It was exremely easy to get working as well. Only taking about 2 days of work to get the solution relablly outputting the values that we needed.

PID Controller

One of the first challanges that needed to be tackled in order for the submarine to be autonomous was to create a reliable way for the AUV to get into a stable orientation. To do this a PID controller was developed. As it stands at the end of 2017-2018 the controller is very generic and is able to be instanciated multiple times. For accurate control of the AUV a minimum of 3 PID controllers are required. One for each: Pitch, Roll, and Yaw.

Above is the outline that I used for the structure of the PID controller.

Controller

For testing the AUV we decided to use a controller to operate all of the systems in place of sensors. This was done because all of the sensors backbones were still in devolpment at the time when we wanted to test the chassis and propulsion systems.

There are several different libraries that were evaluated to use to amke the Controller Class. These were the pygames contoller library, Approximate Engineerings python game controller library, and inputs. Ultimatly inputs was chose because of its documentation and low resource usage. It uses xinput driver that easily detected the xbox one controller that we used. There was another software that we tried using but the controller software driver broke upon sintallation and would not detect the xbox controller.

There are several issue that we ran into with the inputs methods. One was that the controller was interrupt based(which made running the code easy) casuing the controller to not detect sudden, violent movements. This caused the sub to be uncontrollable at times. A button was allocated to make clear the controller causing the sub to stop. Another issue happened when the controller was disconnected. It would casue all of the inputs to stay the same resulting in the sub being stuck in one motor command. To avoid any serious injury because of this issue the sub disarms itself when the controller disconccects.

How To

Install

  1. To begin we will make sure that all of the needed packages are installed from aptitiude.

    sudo apt-get install git build-essential python-dev python3-dev python-serial python3-serial
    

Note: I like to keep all of my python drivers in a folder in the root directory called "python_drivers"

  1. To create the python_drivers folder:

    cd
    mkdir python_drivers
    
  2. The PWM hat requires the Adafruit_Pytohn PCA9685 Driver to operate.

    1. You may follow the install instructions provided but i found that for imports to work properly you needed to install it using both python 2 and python3.

    2. I used the following install commands:

      cd ~/python_drivers
      git clone https://github.com/adafruit/Adafruit_Python_PCA9685.git
      cd Adafruit_Python_PCA9685
      sudo python setup.py install
      sudo python3 setup.py install
      
    3. This may result in several warnings but again this is the only way that I reliablly was able to get the imports to work how they were supposed to.

  3. To use the game controller we must install the inputs package.

    1. Use the following commands:

       cd ~/python_drivers
       git clone https://github.com/zeth/inputs.git
       cd inputs
       sudo python setup.py install
       sudo python3 setup.py install
      
  4. I then install all of the teams repos into a folder called github.

    cd ~
    mkdir github
    
  5. To download, install, and use the Motorcontroller you need to git a version of the Controls Repo and the Datalogger repo.

    cd ~/github
    git clone https://github.com/CSU-Robosub-2017-2018/Controls.git
    git clone https://github.com/CSU-Robosub-2017-2018/Datalogger.git
    
  6. The most up to date example of how to use all of the functions of the Controls repo is contained in the Apr7Test.py file.

Requirements

About

Repository for Controls sub-team code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published