Henry IX: A fully a...
 
Notifications
Clear all

Henry IX: A fully autonomous robot platform

147 Posts
14 Users
63 Reactions
16.7 K Views
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1123
 
Posted by: @briang

Any-rate, enjoy and let me know what you think!

Very nicely explained 👍.   This is shaping up to be a really nice series on robotics.  If we promise not to tell your students where your code document is, could we have a link to a it as its much easier to follow along to look at the whole code, and would help the older folk (like me) to follow along. ( and I'm old enough to be allowed to cheat a bit 😎) 

PS feel free to send it by a private post I wont tell anyone 🤫 


   
Melbul and huckOhio reacted
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1039
 
Posted by: @byron

PS feel free to send it by a private post I wont tell anyone 🤫

As long as @briang sends it to all of us still working with our DB1 robots!  😎 

SteveG


   
huckOhio reacted
ReplyQuote
BrianG
(@briang)
Member
Joined: 3 years ago
Posts: 53
Topic starter  

I will come up with a solution for the code.. I have some ideas.

/Brian


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@BrianG

Well I copied the code from the video and it compiled ok. Will test it with actual hardware later today that I used with my sonar scanner experiments.  Although I installed Pololu3piPlus32U4 the compiler couldn't seem to find it so I commented out the lines using it. Not that it matters I don't have the Pololu robot and would use my own motor control.

You can always post code on the forum.

I am using fixed sonar on my test base as on your larger robot.  Still working on the odometry navigation software.

 

 

 

 


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 180
 

   
Melbul, BrianG and MadMisha reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1123
 
Posted by: @huckohio

I used the TOF10120 laser sensor for ranging

Very interesting and thanks for this idea.   How accurate and consistent do you find your readings to be?  That is when your sensor is in a fixed position and sweeping to and fro taking its readings from the predetermined angles, do you find the average measurements for each angle  to be consistent and does the measurement you calculate verify to the real measurement with a tape measure.

I think I may have to get a couple of TOF10120 sensors. 😎 


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 180
 

@byron

All great questions.  This is my first time using the laser sensor so I am learning as I go.  I assume there would naturally be variability in the distance readings so I figured that taking an average over a set distance would be more accurate.  At each stop point in Brian's video I take 10 quick readings and then move to the next position.  I used the laser because it's faster than the ultrasonic and would give me a chance to take multiple readings at each position.  

I have not tested the accuracy yet.  


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 180
 

Update: I just realized that I am only showing 6 of the 7 results in the serial monitor.  I'll need to look into that.

Update 2:  The first time through there will be 7 readings, but once they sensor starts changing direction there will only be six per cycle.


   
ReplyQuote
BrianG
(@briang)
Member
Joined: 3 years ago
Posts: 53
Topic starter  

@huckohio

Wow!  I am going to have to order myself some of those TOF10120's to play around with.  What a great inexpensive solution.. Other then range it should have the Ultrasonics beat in every metric, and to be honest reading past 2 meters or so are often ignored..

/Brian


   
ReplyQuote
BrianG
(@briang)
Member
Joined: 3 years ago
Posts: 53
Topic starter  

@byron @huckOhio

I believe the time of flight for light over 2 meters is fast enough that whether or not the servo is moving might be irrelevant.  If it is possible to put some Serial.println(millis()) statements in before the sensor sends the signal and receives it you can get an idea, but I can't imagine it would be measurable for an ardiuno.  I think that sensor might manage all that itself and just put data on the I2C bus so I am not sure if you check at the granularity. 

What I do with the moving sound sensor is just set it up infront of some stationary objects and keep the robot stationary.. Then I let it rotate and monitor the output (I just print out the array).  If i see lots of deviations (especially in the center of the range) then I know there is probably an issue with the servo moving too fast.  I slow it down and try again until the reading stabilize. 

Again, light is so fast, I don't think the servo can move out of the way fast enough.

 

 

/Brian


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1123
 

@briang @huckohio

I'm thinking the TOF10120 laser range finder must be a very narrow beam thus taking measurements at defined angle steps would miss objects in-between the angles.  This would indicate that a continuous sweep would be required, or at least a lot on small steps.  Also it may have to sweep vertically as well as horizontally to pick up on objects.   Further experiments will show I guess. 😀 


   
ReplyQuote
Melbul
(@melbul)
Member
Joined: 3 years ago
Posts: 43
 

Good morning guys,

All very interesting reading!

Does this mean my static ultrasonic sensors are not the way to go?

I have 8 on the four base corners and 8 on the top deck corners.

The base ones are paired up on each corner and the top ones are in fours( a pair on each corner) connected to an ATMega328 controller. A La Bills corner sensors.

I tried to upload a video here but got the file too large error.

 

regards,

mel.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@Melbul

Does this mean my static ultrasonic sensors are not the way to go?

You already have your ultrasonic sensors so I would stick with them as they probably give a wider detection. Maybe the laser will pick up things like chair legs or narrow posts. You can always combine the two. In other words you can experiment and find and share the answer as to how many and what kind of sensors to use for a particular task which I assume in this case is simple obstacle avoidance.

With robotic vacuum cleaners I noticed even when they have IR obstacle detection they still push on wall so as to get close enough.  My plan was to have a spring loaded vacuum inlet that would use wall contact to suck up dust between the wall and the floor as well as keep the robot on course. It is important you think of the tasks you want your robot to perform.

 


   
ReplyQuote
Melbul
(@melbul)
Member
Joined: 3 years ago
Posts: 43
 

@robotbuilder
I'm thinking of adding a servo and extra sensor on the front of BB1, as I have both available.

This I would connect directly to the Mega as I think the I2C bus is starting to get a little crowded with distance sensors 😂


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 180
 

@byron @briang

I changed the servo to sweep in 3 degree increments from 45 to 135 degrees, and then took the average of 5 readings at each position. Still getting about a 5 second sweep period.  Yesterday's data set was  taking readings across the workbench.  I decided to up my testing approach and placed a 5 gallon bucket over the laser to get consistent readings.  I was looking for consistency  with accuracy being next.  I am including a quick video, the distance readings (each line is moving in a different direction) and the code.

The following is a LibreOffice Calc file. 

 

#include <Servo.h>
#include <Wire.h>

//TOF10120 code example from dranebotworkshop
//Servo code from BrianG

unsigned char ok_flag;
unsigned char fail_flag;

unsigned short lenth_val = 0;
unsigned char i2c_rx_buf[16];
unsigned char dirsend_flag=0;

Servo headServo; // create servo object to control a servo

// switches
const boolean HEAD_DEBUG = false;

// Head Servo Count Timing
int avgDistance;
int MEASUREMENT_COUNT = 5;
int totalDistance;





// Head Servo Constants
const int HEAD_SERVO_PIN = 9;

// Head Servo Data
int currentHeadPosition = 45;


void setup() {
Wire.begin();
Serial.begin(57600, SERIAL_8N1);
printf_begin();

// initialize the head position to start
headServo.attach(HEAD_SERVO_PIN);
headServo.write(currentHeadPosition);

// start delay
delay(3000);

}

void loop() {
// perform head movement
moveHead();

}

void moveHead() {

// rotates the servo motor from 45 to 135 degrees
for(int i=45;i<=135;i=i+3){
headServo.write(i);
delay(30);
int x = readDist();
Serial.print(x);
Serial.print(", ");

}
Serial.println();
// Repeats the previous lines from 165 to 45 degrees
for(int i=135;i>=45;i=i-3){
headServo.write(i);
delay(30);
int x = readDist();
Serial.print(x);
Serial.print(", ");
}
Serial.println();
}

int readDist() {

totalDistance=0;
for(int i=0; i<MEASUREMENT_COUNT; i++) {

//read 10 samples for distance for this mosition and add together
int x=ReadDistance();
totalDistance = totalDistance + x;
}
avgDistance = totalDistance/MEASUREMENT_COUNT; //get the average distance over the number of
return avgDistance;

}

int serial_putc( char c, struct __file * )
{
Serial.write( c );
return c;
}

void printf_begin(void)
{
fdevopen( &serial_putc, 0 );
}

void SensorRead(unsigned char addr,unsigned char* datbuf,unsigned char cnt)
{
unsigned short result=0;
// step 1: instruct sensor to read echoes
Wire.beginTransmission(82); // transmit to device #82 (0x52)
// the address specified in the datasheet is 164 (0xa4)
// but i2c adressing uses the high 7 bits so it's 82
Wire.write(byte(addr)); // sets distance data address (addr)
Wire.endTransmission(); // stop transmitting
// step 2: wait for readings to happen
delay(1); // datasheet suggests at least 30uS
// step 3: request reading from sensor
Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)
// step 5: receive reading from sensor
if (cnt <= Wire.available()) { // if two bytes were received
*datbuf++ = Wire.read(); // receive high byte (overwrites previous reading)
*datbuf++ = Wire.read(); // receive low byte as lower 8 bits
}
}

int ReadDistance(){
SensorRead(0x00,i2c_rx_buf,2);
lenth_val=i2c_rx_buf[0];
lenth_val=lenth_val<<8;
lenth_val|=i2c_rx_buf[1];
delay(30);
return lenth_val;
}

   
Melbul, byron and BrianG reacted
ReplyQuote
Page 6 / 10