Category Archives: FrontPage
Resistance to Odometry is futile
It sure is. But a good odometry in a robotic context is an objective that is hard to achieve. For a robot like the aMoSeRo only two main velocities are relevant: linear and angular speed. Both do not occur on the same time, but still – correctly determining any of them is essential as most higher algorithms like slamming and planning highly depend on it. For me in a out of time running thesis, this task can be the biggest still kinda opened challenge.
All other system parts like gmapping, robot_pose_ekf, tf_broadcasts, sensor code, drivers, dynamic_reconfigure (insert long list of other important things here) are up and well enough running. Most of the thesis is written, only evaluation (experiments) and conclusion (the big round up in the end) is still missing.
Therefore I am really looking forward to a time after my thesis – full of well deserved sleep and a university degree 🙂
Howto run two 6V DC motors with arduino micro
So before trying to get the planned stepper motors running, I quickly put a dc motors setup together:
- The fully wired l298n
- mobile setup
- arduino micro supporting 5V and IN1,IN2,IN3,IN4
I’ve got two dc motors coming with my make block robot starter kit. And for research I also ordered a small l298n motor controller shield which is able to control motors up to 24Vs and 2A each by 4 small input wires at for example 3,3V and 2 additional +5V motor enablers.
There is a nice little page which explains all states of the L298N according to the arduino micro here. For a [amazon &title=Raspberry Pi&text=Raspberry Pi] I found a nice Youtube video explaining everything here.
For me in the end both motors rotated quite nicely, like this video shows:
For the micro I wrote this peace of code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
const int IN1 = 10; const int IN2 = 11; const int IN3 = 8; const int IN4 = 9; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); } void loop() { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); //hold speed fro 5 seconds for(byte j = 5; j > 0; j--) { delay(1000); } //stop for two seconds. digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); delay(2000); //switching direction digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); //hold speed for 5 seconds for(byte u = 5; u > 0; u--) { delay(1000); } } |
Arduino Micro and ultrasonic sensor HC-SR04
This is my very first arduino application. But its simple and amazing.
You will need 4 female to female jumper wires and [amazon &title=HC-SR04&text=HC-SR04] ultrasonic sensor, a microusb cable and in the end you’ll be able to measure distances with this little device.
Just wire it like shown below:
I used pins 7 (orange echo) and 8 (yellow trigger) for data pins, 5V(red) and ground(black).
I have taken some code from this page. The result you can see in the screenshot below, its a amount of cm written in the serial console:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
/* [amazon &title=HC-SR04&text=HC-SR04] Ping distance sensor: VCC to arduino 5v GND to arduino GND Echo to Arduino pin 7 Trig to Arduino pin 8 This sketch originates from Virtualmix: http://goo.gl/kJ8Gl Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html on 10 Nov 2012. */ #define echoPin 7 // Echo Pin #define trigPin 8 // Trigger Pin #define LEDPin 13 // Onboard LED int maximumRange = 200; // Maximum range needed int minimumRange = 0; // Minimum range needed long duration, distance; // Duration used to calculate distance void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LEDPin, OUTPUT); // Use LED indicator (if required) } void loop() { /* The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing soundwaves off of it. */ digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); //Calculate the distance (in cm) based on the speed of sound. distance = duration/58.2; if (distance >= maximumRange || distance <= minimumRange){ /* Send a negative number to computer and Turn LED ON to indicate "out of range" */ Serial.println("-1"); digitalWrite(LEDPin, HIGH); } else { /* Send the distance to the computer using Serial protocol, and turn LED OFF to indicate successful reading. */ Serial.println(distance); digitalWrite(LEDPin, LOW); } //Delay 50ms before next reading. delay(50); } |
Rasberry Pi Robot with ROS, Xtion and working base_controller teleop
Before I dismantle my little [amazon &title=Raspberry Pi&text=Raspberry Pi] Robot #1 , I wanted to have a little video of its base_controller working together with the turtlebot teleop. It uses the geometry/Twist messages to transmit moving information like a lot of ROS Robots do.
As you see there is a little acceleration control implemented which makes the robot start smoothly and stop after gently after no key is pressed anymore. In case of emergency its possible to hit e.g. the space bar for a instant full stop.
This robot isn’t very fast – but the next one will be. So this was a successful ROS-learning robot which I can recommend to everyone who wants to know how ROS Robots work.
Its a bit hard to get all of the source compiled on the small arm cpu, and there are nearly no precompiled packages – but it takes away all the fear from compiling errors in the future 🙂