Need help in programming part for my hexa robot

aa

PROBLEM SOLVED!
now i can made my robot walk forward when no object is in front and it will stop right there if a object is in front!

but anyway
please help me solve this

look at my code XSpeed = -50
it only will walk forward when Xsped = -50
if set to Xspeed = 50 it will walk backward.
just hope to ask, why this will happen?
Because I though when xspeed is positive and it should be walking front?

===================1st part====================
	;code for ping)))
	low p4
	pulsout p4, 5
	input p4
	pulsin p4, 0, toolong, 40000, wdist
	wdist = wdist / 148   ;convert for inches
	if wdist > 50 then		;when distance >50 move forward, <50 turn right
	aaa = 0			;turning right automatic is off
	Automode = 1    ;moving forward automatic is on
	else
	
	Automode = 0	;moving forward automatic is off
	aaa = 1			;turning right automatic is on
 
	endif
	toolong:      ; if the program gets here the sensor is not functioning, or wired wrong

============2nd part======================================
	;moving forward automatic code
	if Automode then
	   
   		YSpeed = 0
   		XSpeed = -50   ; moving forward
   		Steering = 0    ; 
		
   		StepFlag =  3  ; not sure try changing...
   		Height = 0  

	else
		YSpeed = DualShock(3) - 128		; Right Stick Horizontal
	
		XSpeed = DualShock(4) - 128		; Right Stick Vertical
	
		Steering = DualShock(5) - 128		; Left Stick Horizontal
	
		StepFlag = (GaitSpeedTmp - 2) max 3
		if HeightAdjust or LockLegs then
			Height = LastHeight + (((DualShock(6) - 128) / 5) - LastHeight) / StepFlag; Left Stick Vertical
		endif
	
		Height = (Height Max HeightLimit) min - HeightLimit
	endif
	

=====================3rd part===============================
	;code turning right
		if aaa then
	   
   		YSpeed = 50	;turning right
   		XSpeed = 0   
   		Steering = 0    ; 
		
   		StepFlag =  3  ; not sure try changing...
   		Height = 0  


		endif

about the code on top
there are 3 part, first part is ping))) code, second part is forward code and 3rd part is move to right code.
At first is code for ping))), when distance >50, automode = 1 and aaa = 0, robot will move forward. When there is an object and distance <50,automoce = 0 and aaa=1, robot will move right.
My question is…
for my program, robot move forward, then meet object, then it will keep walking to right until i stop the robot.
Anyone have any idea to make this?
robot move forward, meet object, then move to right but still keep detect the object until distance >50(no more object in front), then robot move forward again. I try to figure this for whole day but i just can’t get the idea

Hi again, don’t have the time to fully code this (besides that is where the fun is!) :wink:

But it should not be very hard to layout the code that says go foreword as long as there is nothing in front of me else go right…

Something like:

if Automode then
   low p4
   pulsout p4, 5
   input p4
   pulsin p4, 0, toolong, 40000, wdist
   wdist = wdist / 148   ;convert for inches
   if wdist > 50 then      ;when distance >50 move forward, <50 turn right
        YSpeed = 0
         XSpeed = -50   ; moving forward
  else
          YSpeed = 50   ;turning right
         XSpeed = 0   
  endif
  Steering = 0    ; 
  StepFlag =  3  ; not sure try changing...
  Height = 0  
   ...
else
; the non-auto mode...

Hopefully that should get you moving.
Kurt

thank kurte for your help.

1 question
my robot still not walking straight.
It will slightly move to right site a bit.
offset and alignment (from powerpod) of my robot is quite ok already.
but still not walking straight.

So should i adjust the angle of the servo?
But i have no idea about the programming code of the servo in my programming part.
Can help?
THank~

EXPERIMENT!!!

Try things like what happens if I instead of: XSpeed=-50 and YSpeed=0
Try something like XSpeed=-50 and YSpeed = 1 or -1…

Kurt

oh thank kurte~
i didnt think of it…
i will try it out tomorrow
Thank!

[code]wdist var word

main:
low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
serout s_out, i9600, "Distance: ", sdec wdist, 13, 10] ;display result in terminal
goto main

toolong: ; if the program gets here the sensor is not functioning, or wired wrong
serout s_out, i9600, “Timeout, sensor is not working”, 13]
goto main[/code]

The code on top will show me sensor distance in terminal 1 after i click connect.
I need all of the result from initial i start to click connect and until i stop the program.
How can i transfer my output data to Excel or notepad?
Because the initial result in terminal 1 will gone if my sensor data run too long, right?

anyone can help about this please?

I am not sure if you are asking for the obvious answer of you select the text, do a right mouse click and select copy, then go to either notepad or excel and do a paste command?

If the terminal program does not have enough hold enough lines you have options, try different terminal programs such as hyper term. If that does not work, you can easily write a VB app that can do it.

Kurt

i can’t do copy and paste because terminal has not enough space to record my result.
i have no idea how to make a VB app to do this.
Can you help me on it or do you still have others way to help me how to record my sensor output into EXcel?