Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Initial commit, add the code of 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
furmi committed Oct 10, 2016
1 parent ee23545 commit 852decc
Show file tree
Hide file tree
Showing 781 changed files with 117,090 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.elf
*.hex
build/
.sconsign.dblite
__pycache__/
node_modules/
npm-debug.log
*.sublime*
hokuyo/bin/hokuyo
CMakeCache*
CMakeFiles*
cmake_install*
*calculate_xy
*find_port
*get_distance
*get_distance_intensity
*get_multiecho
*get_multiecho_intensity
*sensor_parameter
*sync_time_stamp
*liburg_c.a
Binary file added C2015_Reglement_FR_final.pdf
Binary file not shown.
Binary file added E2015_Rules_EU_EN_final.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions NetworkSharing
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
On host (with internet) :
replace <output_interface> by network access interface (ex : wlan0)
replace <input_interface> by network sharing interface (ex : eth0>

sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o <output_interface> -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i <input_interface> -o <output_interface> -j ACCEPT

On target device :
ip route add default via <host_ip> dev <device_interface>
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# coupe17
Attention la lune, on arrive ! #moonvillage
Code source des robots d'UTCoupe 2015
=======

Participation à la Coupe de France de Robotique 2015 dont le thème est : Robomovies

Structure :

![alt tag](https://raw.githubusercontent.com/utcoupe/coupe15/master/UTCoupe.png)
Binary file added UTCoupe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
145 changes: 145 additions & 0 deletions arduino/GB/AFMotor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
// Adapté pour UTCoupe2011 par Arthur, 19/01/2011
// Moteurs 1 et 2 correspondent à la carte Rugged


#include <avr/io.h>
#include <Arduino.h>


#include "AFMotor.h"


/******************************************
MOTORS
******************************************/
inline void initPWM1(uint8_t freq) {
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
// use PWM from timer2B (pin 3)
TCCR2A |= _BV(COM2B1) | _BV(WGM20) | _BV(WGM21); // fast PWM, turn on oc2b
TCCR2B = freq & 0x7;
OCR2B = 0;
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// on arduino mega, pin 3 is now PE5 (OC3C)
TCCR3A |= _BV(COM1C1) | _BV(WGM10); // fast PWM, turn on oc3c
TCCR3B = (freq & 0x7) | _BV(WGM12);
OCR3C = 0;

#else
#error "This chip is not supported!"
#endif

pinMode(3, OUTPUT);
}

inline void setPWM1(uint8_t s) {
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
// use PWM from timer2A on PB3 (Arduino pin #11)
OCR2B = s;
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// on arduino mega, pin 11 is now PB5 (OC1A)
OCR3C = s;
#else
#error "This chip is not supported!"
#endif
}

inline void initPWM2(uint8_t freq) {
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
// use PWM from timer2A on PB3 (Arduino pin #11)
TCCR2A |= _BV(COM2A1) | _BV(WGM20) | _BV(WGM21); // fast PWM, turn on oc2a
TCCR2B = freq & 0x7;
OCR2A = 0;
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// on arduino mega, pin 11 is now PB5 (OC1A)
TCCR1A |= _BV(COM1A1) | _BV(WGM10); // fast PWM, turn on oc1a
TCCR1B = (freq & 0x7) | _BV(WGM12);
OCR1A = 0;
#else
#error "This chip is not supported!"
#endif
pinMode(11, OUTPUT);
}

inline void setPWM2(uint8_t s) {
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
// use PWM from timer2A on PB3 (Arduino pin #11)
OCR2A = s;
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// on arduino mega, pin 11 is now PB5 (OC1A)
OCR1A = s;
#else
#error "This chip is not supported!"
#endif
}

AF_DCMotor::AF_DCMotor(uint8_t num, uint8_t freq) {
motornum = num;
pwmfreq = freq;

switch (num) {
case 1:
pinMode(MOTOR1_DIR, OUTPUT);
digitalWrite(MOTOR1_DIR, LOW);
initPWM1(freq);
break;
case 2:
pinMode(MOTOR2_DIR, OUTPUT);
digitalWrite(MOTOR2_DIR, LOW);
initPWM2(freq);
break;
}
}

void AF_DCMotor::run(uint8_t cmd) {
uint8_t dirPin;
switch (motornum) {
case 1:
dirPin = MOTOR1_DIR; break;
case 2:
dirPin = MOTOR2_DIR; break;
default:
return;
}

switch (cmd) {
case FORWARD:
digitalWrite(dirPin, LOW);
break;
case BACKWARD:
digitalWrite(dirPin, HIGH);
break;
case RELEASE:
//TODO
break;
}
}

void AF_DCMotor::setSpeed(uint8_t speed) {
switch (motornum) {
case 1:
setPWM1(speed); break;
case 2:
setPWM2(speed); break;
}
}


46 changes: 46 additions & 0 deletions arduino/GB/AFMotor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#ifndef _AFMotor_h_
#define _AFMotor_h_

#include <inttypes.h>
#include <avr/io.h>


#define MOTOR12_64KHZ _BV(CS20) // no prescale
#define MOTOR12_8KHZ _BV(CS21) // divide by 8
#define MOTOR12_2KHZ _BV(CS21) | _BV(CS20) // divide by 32
#define MOTOR12_1KHZ _BV(CS22) // divide by 64

#define MOTOR1_DIR 12
#define MOTOR2_DIR 13

#define MOTOR1_A 2
#define MOTOR1_B 3
#define MOTOR2_A 1
#define MOTOR2_B 4
#define MOTOR4_A 0
#define MOTOR4_B 6
#define MOTOR3_A 5
#define MOTOR3_B 7

#define FORWARD 1
#define BACKWARD 2
#define BRAKE 3
#define RELEASE 4


class AF_DCMotor
{
public:
AF_DCMotor(uint8_t motornum, uint8_t freq = MOTOR12_8KHZ);
void run(uint8_t);
void setSpeed(uint8_t);

private:
uint8_t motornum, pwmfreq;
};

#endif
1 change: 1 addition & 0 deletions arduino/GB/GB.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/asserv.ino
1 change: 1 addition & 0 deletions arduino/GB/PID.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/PID.c
1 change: 1 addition & 0 deletions arduino/GB/PID.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/PID.h
1 change: 1 addition & 0 deletions arduino/GB/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../SConstruct
1 change: 1 addition & 0 deletions arduino/GB/block.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/block.c
1 change: 1 addition & 0 deletions arduino/GB/block.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/block.h
1 change: 1 addition & 0 deletions arduino/GB/compat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/compat.cpp
1 change: 1 addition & 0 deletions arduino/GB/compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/compat.h
1 change: 1 addition & 0 deletions arduino/GB/control.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/control.c
1 change: 1 addition & 0 deletions arduino/GB/control.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/control.h
1 change: 1 addition & 0 deletions arduino/GB/emergency.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/emergency.c
1 change: 1 addition & 0 deletions arduino/GB/emergency.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/emergency.h
1 change: 1 addition & 0 deletions arduino/GB/encoder.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/encoder.c
1 change: 1 addition & 0 deletions arduino/GB/encoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/encoder.h
1 change: 1 addition & 0 deletions arduino/GB/goals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/goals.c
1 change: 1 addition & 0 deletions arduino/GB/goals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/goals.h
1 change: 1 addition & 0 deletions arduino/GB/local_math.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/local_math.c
1 change: 1 addition & 0 deletions arduino/GB/local_math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../asserv/local_math.h
11 changes: 11 additions & 0 deletions arduino/GB/make
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

export AVR_HOME=/usr/bin ARDUINO_HOME=../arduino-1.0
export ARDUINO_BOARD=mega2560

if ! ../check_protocol; then
echo "Found duplicate value for orders in protocol.h"
exit 1
fi

scons -f ../SConstruct $@
61 changes: 61 additions & 0 deletions arduino/GB/motor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/****************************************
* Author : Quentin C *
* Mail : [email protected] *
* Date : 29/11/13 *
****************************************/
#include "parameters.h"
#include "AFMotor.h"
#include <Arduino.h>

#ifndef PWM_MIN
#define PWM_MIN 0
#endif

//Controleur :
//-255:0 : Marche arrière
//0:255 : Marche avant

AF_DCMotor motor_left(1, MOTOR12_64KHZ);
AF_DCMotor motor_right(2, MOTOR12_64KHZ);

extern "C" void set_pwm_right(int pwm);
extern "C" void set_pwm_left(int pwm);

void set_pwm_left(int pwm){
pwm = -pwm;//les moteurs sont faces à face, pour avancer il faut qu'il tournent dans un sens différent
if (pwm > 0)
pwm += PWM_MIN;
else if (pwm < 0)
pwm -= PWM_MIN;

if(pwm > 255)
pwm = 255;
else if(pwm < -255)
pwm = -255;

if(pwm >= 0)
motor_left.run(FORWARD);
else
motor_left.run(BACKWARD);

motor_left.setSpeed(abs(pwm));
}

void set_pwm_right(int pwm){
if (pwm > 0)
pwm += PWM_MIN;
else if (pwm < 0)
pwm -= PWM_MIN;

if(pwm > 255)
pwm = 255;
else if(pwm < -255)
pwm = -255;

if(pwm >= 0)
motor_right.run(FORWARD);
else
motor_right.run(BACKWARD);

motor_right.setSpeed(abs(pwm));
}
17 changes: 17 additions & 0 deletions arduino/GB/motor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/****************************************
* Author : Quentin C *
* Mail : [email protected] *
* Date : 31/03/13 *
****************************************/
#ifndef MOTOR_H
#define MOTOR_H

void set_pwm(int side, int pwm);

inline void MotorsInit(void) {};

void set_pwm_left(int pwm);

void set_pwm_right(int pwm);

#endif
Loading

0 comments on commit 852decc

Please sign in to comment.