Git Product home page Git Product logo

cg3002rpi's Introduction

CG3002 Raspberry Pi code

System dependencies

python-dev, flite, vim, python-devel

Setup pip, virtualenv and virtualenvwrapper for Linux and OS X

  1. pip install -U pip
  2. pip install virtualenv
  3. pip install virtualenvwrapper
  4. Add this line to your .bash_profile: export WORKON_HOME=~/.virtualenvs
  5. Add this line to your .bash_profile: source /usr/local/bin/virtualenvwrapper.sh
  6. Create virtualenv: mkvirtualenv reborn
  7. Install dependencies: pip install -r requirements.txt
  8. To enter virtualenv: workon name-of-virtualenv
  9. To exit virtualenv: deactivate

Instructions to get matplotlib working with virtualenv (for MAC OS X)

Reference: http://matplotlib.org/faq/virtualenv_faq.html

  1. Copy the following to a file called fpython in the site-packages directory of your virtualenv (Normally its /Users/YOU/.virtualenvs/name-of-virtualenv/lib/python2.7/site-packages/bin)
#!/bin/bash
# what real Python executable to use
PYVER=2.7
PATHTOPYTHON=/usr/local/bin/
PYTHON=${PATHTOPYTHON}python${PYVER}

# find the root of the virtualenv, it should be the parent of the dir this script is in
ENV=`$PYTHON -c "import os; print(os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..')))"`

# now run Python with the virtualenv set as Python's HOME
export PYTHONHOME=$ENV
exec $PYTHON "$@"

Make sure that fpython is an executable, if not, sudo chmod +x fpython on the command line

  1. Run framework python when running scripts that require matplotlib - fpython name_of_script.py

  2. Running step_detection:

Connect arduino with IMU chip to serial port, find address of your serial port. Easiest way is to open arduino IDE, tools -> port, or another way is to go to /dev (for MAC users) and trial and error from all the file descriptors listed there

Open serial_input.py, change SERIAL to your own serial address and PIPE to your own local address, DO NOT COMMIT this change Open step_dectection.py, change PIPE to your own local address, DO NOT COMMIT this change

Open 2 terminal window - first: fpython step_dection.py (this is the master process, hence must run first) second: fpython serial_input.py

How to terminate: fpython will run forever and is not well behaved to CTRL-C signals from keyboard, surest way is to kill process from activity monitor or commmand line

2 files will be created in local folder - pid contains pid of the master process, so client can send signal interrupts to master, pipe is the named pipe created to transfer data between 2 processes

This is the arduino code for the IMU, please use this as the serial comms is sensitive to the data formatted here

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;

void setup()
{
  Serial.begin(115400);
  Wire.begin();
  compass.init();
  compass.enableDefault();
}

void loop()
{
  compass.read();
  double x = (compass.a.x / 1600.0);
  double y = (compass.a.y / 1600.0);
  double z = (compass.a.z / 1600.0);
  Serial.print(x);
  Serial.print(",");
  Serial.print(y);
  Serial.print(",");
  Serial.print(z);
  Serial.println();

  delay(20);
}

cg3002rpi's People

Contributors

cg3002ay1617t12 avatar joannakxt avatar rebecca-m avatar seokhoonlee avatar thejerrytan avatar zhengyangtean avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.