Lynxmotion Tech Support

www.lynxmotion.com
Join the Accelerator Program
It is currently Thu Jun 20, 2013 12:31 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Apr 03, 2012 7:56 pm 
Offline
Roboteer

Joined: Tue Dec 13, 2011 5:18 pm
Posts: 8
Hi all,

I'm having trouble with my code. I have some Ping Sonar code integrated with my autonomous code. The hexapod can successfully walk forward and recognize an obstruction(wall) and then rotate/turn...and continues to keep rotating. I'm sure it's simple, but I don't know how to go about getting the hexapod to exit the "loop" and continue to walk forward. Here's the section of the code....

Code:
   Steering = (Steering Max 120) min -120
   Steering2 = Steering
   Height = (Height Max 25) min -25
   Height2 = Height
   YSpeed = (YSpeed Max 120) min -120
   XSpeed = -50

   GaitSpeed = (GaitSpeed max 20) min 3
   StepFlag = (GaitSpeedTmp - 2) max 3
   LegUpShift = 70   
   if LegUpShift > 45 then
      GaitKind = 1
      GaitSpeed = GaitSpeed min 4
   else
      GaitKind = 0   
   endif
   XSpeed = -50
   low ping
   high ping
   pulsin ping, 0, pingRaw 'read the ping
   low ping
   ;pingRaw = pingRaw / 2 'adj for per sec since reading are every 0.5 sec
   ;pingRange = pingRaw / 29 'convert to cm
   pingRange = pingRaw / 148 'convert to inches
   pingRangemin = pingRange

   if pingRangemin <= 10 then ;it sees an obstruction
      XSpeed = 0
      YSpeed = 0
      Steering = -60   
   else   
      XSpeed = -50
   
      if pingRangemin > 10 then ;if it doesn't see an obstruction
         XSpeed = -50
      endif

   endif


...also, I feel like I keep re-stating the 'XSpeed' too much. Any help?

Thanks,
Justen


Last edited by Colorasplosion on Thu Apr 05, 2012 4:15 pm, edited 1 time in total.
Added [code][/code] tags.


Top
 Profile  
 
PostPosted: Thu Apr 05, 2012 3:55 pm 
Offline
Roboteer

Joined: Tue Dec 13, 2011 5:18 pm
Posts: 8
Well I figured out the problem with the code, now my new problem is that I'm trying to use 2 PING sensors and I'm not sure how to go about writing the code. I tried what I thought might work, but it only wanted to read one sensor at a time and wouldn't walk right. I read another post on here about someone trying to use multiple sensors but I couldn't gain much from it.

Any help?Please?

Justen


Top
 Profile  
 
PostPosted: Thu Apr 05, 2012 4:07 pm 
Offline
Lynxmotion Founder
User avatar

Joined: Mon Oct 31, 2005 10:46 am
Posts: 9325
Location: my quiet place
I'm not a great programmer, but I will try to help. What hexapod are you using? Is it a 2DOF? Are you using the SSC-32's hexapod sequencer? This type of problem will require us to see the wiring, do you have a schematic? Posting what you tried would be a good idea. More info...

_________________
Jim Frye, the Robot Guy
http://www.lynxmotion.com
I've always tried to do my best...


Top
 Profile  
 
PostPosted: Tue Apr 17, 2012 4:01 pm 
Offline
Roboteer

Joined: Tue Dec 13, 2011 5:18 pm
Posts: 8
Sorry, I didn't realize you responded. However, I did get the robot working how I wanted it too. I ended up using 3 sonar sensors so it can see to the front, right, and left and respond accordingly. The problem was with how I had my IF statements nested, and also I wasn't turning "off" the XSpeed when I was turning the Steering "on".


Top
 Profile  
 
PostPosted: Tue Apr 17, 2012 4:26 pm 
Offline
Lynxmotion Founder
User avatar

Joined: Mon Oct 31, 2005 10:46 am
Posts: 9325
Location: my quiet place
Well glad you got it going.

_________________
Jim Frye, the Robot Guy
http://www.lynxmotion.com
I've always tried to do my best...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group