how can i incorporate that into my current project is there anyone out there that could work on my blocky its so difficult lol. im going to keep trying while i have the day off.
no matter what i do i can't incorparate the rc script with my script into arlo it ends up being that the rc script runs first then i can't use the rc script after my script runs.
How are your Ping sensors oriented on the robot?
Which Ping pin corresponds to these orientations?
I think you'll want to start at least two other cogs. In one of these cogs, constantly update the values of "Aileron" and "Throttle". In the other cog constantly update four variables used for Ping distances.
In your main loop initially calculate a target speed based on the "Aileron" and "Throttle" values. After obtaining a target speed, check the Ping variables (which have been updating continuously) and modify the target speed based on the Ping variable values.
Only after all input values (RC and Ping) have been used to modify the target speed then send the motor speeds.
Since you're using Arlo hardware, you should let the "Robot drive speed" control the speed of the motors. You don't want to also use "Pulse-Out."
Whenever I've added RC to a robot, I use elevator and aileron to steer the robot. I'd suggest using the elevator channel rather than throttle.
Edit: This code won't work as expected. I'll clarify once I have a chance to test the code.
I think this translates to Blocky as seen in the attached image. (I used your variable "Throttle" but in the code above this channel would be from the aileron channel.
the pings are not lighting up but the rc works like a charm thanks btw . if you push the throttle top left corner it goes forward bottom right corner goes backwards.
i have been trying out duane degn's code which i get that you have to run a separate function but now i can't get the pings to work i left my link open to the public (#1) being a code combo of yours and mine. and (#2) being a simplified update of yours and mine by duane degn.
You can intuitively drive an Arlo type robot with one joystick. Let X be the aileron input - 1500 and Y be the elevator input - 1500. This makes X and Y zero with a centered stick.
Assuming Y is positive when the stick is moved forward and X is positive when the stick is moved to the right, then the motor speed can be calculated as:
leftMotorSpeed = (Y + X) / C
rightMotorSpeed = (Y - X) / C
You might need to swap the + and - if X and Y don't behave as assumed above. The value "C" will scale the output to the appropriate range for the "Robot" comand. I don't know what is range is. If speed ranges from -100 to +100 then C should be set to around 5.
The above lets the robot turn in place when the stick is only moved side to side. I think you'll find it more intuitive than have the controls on two different joysticks.
I still haven't tested this out myself. I was using different hardware on my robot and need to switch it back to using an Activity Board with HB-25 controllers.
im still having trouble writing a code that allows me to run the ping code and the rc code together. im really glad the rc aspect of it works but as far as the pings go i can't get it to work properly with rc.
Sorry for not helping sooner.
I'm a bit out of date with Parallax hardware.
I just now realized Arlo uses the DHB-10 AND the Activity Board WX.
I was attempting to use two HB-25 motor controllers. I see these are no longer made.
Sorry about that. I have a DHB-10 so I'll wire it up and see if I can better test your code.
Until I get up and running here are some suggestions.
I suggest you first test if the code works as desired using just the RC input. Use "Save As" to save a copy of your program and delete all Ping statements.
Once you're satisfied with the RC control, then start adding one Ping at a time. Say you add the Ping sensor on the right side of your robot. What do you want the robot to do when this Ping detects an object? I'd suggest turning away from it by slowing the speed of left wheel. You could either have the left wheel speed limited to a predetermined minimum value or you could scale the left wheel speed based on the right wheel speed and/or the distance detected by the Ping.
As I mentioned in an earlier reply, I think robots steer more intuitively using the elevator/aileron stick. I use the throttle and rudder channels to control other servos or gadgets.
I use the throttle to set the max speed of the robot. I use aileron and elevator to control the robot's direction.
In order to figure out the pulses corresponding to various inputs, I used this program.
You might need change the value of some of the constants to get the code to work correctly with your hardware.
The constants to check are "CENTER_PULSE_1485" which is set to the value of the centered aileron and elevator channels (hopefully these are about the same value).
The constant "ZERO_THROTTLE_1108" is the throttle value when the throttle is at the lowest position.
"THROTTLE_RANGE_750" is the difference between the highest throttle setting and the lowest.
The constant "MAX_RC_MOVEMENT_410" is how far the aileron and elevator inputs can vary from the center position input.
Scaling the max speed using the throttle channel isn't a very useful feature. I might be better to use the throttle channel for something else.
I haven't added the Ping sensors yet. I only have two sensors myself but I'll share what I come up with here.
I worked a lot with some of the earlier Arlo hardware and I wasn't aware Parallax had switched to use the DHB-10 instead of two HB-25 drivers. I have a DHB-10 board so I can experiment with the latest hardware version of the Arlo.
Once I was able to test code, I could see all the errors in my earlier Blocky attempts.
Sorry have haven't helped with your Ping question yet but now that I have my hardware switched over, I should have an example to share soon.
I think using another processor to monitor all of the pings would work. Your code could be quite simple or a bit more complex depending on how you want things. I could see it detecting something from a distance and as it gets closer the motors ramp down to a stop when it gets too close. Then backing off to a distance that's higher than the set point for stopping. Is this a bot you drive or it drives? That may effect what happens while detecting and correcting in your code and what it does.
Incorporating the Pings to the RC code is harder than I thought.
I'm going to just think of senarios for two Pings for now (since that's how many I have handy).
Here's what I've thought of so far.
I figure I'll use two threshold distances. "PING_CAUTION" and "PING_DANGER". These are presently set at 60cm and 10cm but these values will likely change with experimentation. I'll also use "MAX_PING_SPEED" (presently 60) to set an adjusted speed when an obstacle is detected.
If either sensor detects an object withing the "PING_DANGER" range, the robot will only allow reverse motion.
If both sensors detect an object withing the "PING_CAUTION" range, the robot will slow to less than "MAX_PING_SPEED". The speed will likely be a function of the distance to the closest obstacle (closer the obstacle the slower the speed).
If only one sensor detects an object withing the "PING_CAUTION" range, the robot will slow the wheel opposite of the sensor. Hopefully this will allow the robot to turn away from an obstacle.
Since I don't have a Ping on the rear of my robot, I'm only modifying the speed when the robot is in forward motion.
Does anyone have other suggestions on what sort of logic to combine the Ping inputs with the RC inputs?
Thats kind of along the lines of what I was thinking. I got the idea from my cnc machine the hard and soft limits operate like that for the limit switches.
I allow negative speed values to skip the section of code which modifies the motor speed. This should allow the robot to backup. I attached an image showing the logic.
I'm just about to test my code. I'll share it in case anyone is interested in seeing it but don't expect it to work yet.
I just tested the code and it works well enough to demonstrate the concept.
I think rather than using the throttle to set the max speed of the robot, a better use of the channel would be adjust the distance limit where the Ping code is used. Another option would be use the landing gear or other spare channel to turn the Ping portion of the code on or off.
I'm not sure how much more I'll continue using Blocky with this robot. I find Blocky fun for small programs but when programs start to get large, the weakness of block based code exceeds its benefits. I'll likely switch to Spin for continued development.
I'm not sure I understand your question. Pins 12 and 13 connect with the DHB-10 board. I used different pins for the RC connection.
I used these instructions to connect the Activity Board with the DHB-10.
I didn't add a buzzer on P4.
I used P0 through P2 for the radio input. I powered the radio receiver with 5V from the Activity Board. My radio receiver (Spektrum clone) uses 3.3V logic so I didn't have any resistors between the radio output and the Activity Board's input. If you use a radio with 5V logic, use a 3K to 10K resistor between the radio and the Propeller board on each channel.
I didn't use any of the three pin headers P14 through P17 since you plan to use these with the Ping sensors.
You can of course move the radio receiver pins to any unused pins. You'd just change the code shown in attached image as needed.
As I mentioned in an earlier comment, you might need to change the value of some of the constants based on the output of your radio. I previously linked to some code for checking the radio channels.
oh ok so im using the right stick only on the radio controller interface interface which the receiver only has 2 out pins im using now instead of putting those specific pins on 12 and 13 i put them into pulse-in pin 0 and pulse-in pin 1. why are there 3 pulse-in pin reads just curious i only would use two pulse-in pins probably. thanks btw for helping me with this.
lol i finally nailed it omg i had the rc pins in the 12 and 13 this whole time omg!!!!! hahahaha sorry you guys but im on it now. Thanks this project is complete for now.
Comments
Which Ping pin corresponds to these orientations?
I think you'll want to start at least two other cogs. In one of these cogs, constantly update the values of "Aileron" and "Throttle". In the other cog constantly update four variables used for Ping distances.
In your main loop initially calculate a target speed based on the "Aileron" and "Throttle" values. After obtaining a target speed, check the Ping variables (which have been updating continuously) and modify the target speed based on the Ping variable values.
Only after all input values (RC and Ping) have been used to modify the target speed then send the motor speeds.
Since you're using Arlo hardware, you should let the "Robot drive speed" control the speed of the motors. You don't want to also use "Pulse-Out."
Whenever I've added RC to a robot, I use elevator and aileron to steer the robot. I'd suggest using the elevator channel rather than throttle.
Edit: This code won't work as expected. I'll clarify once I have a chance to test the code.
I think this translates to Blocky as seen in the attached image. (I used your variable "Throttle" but in the code above this channel would be from the aileron channel.
I haven't tested this, but here's where I'd start.
http://blockly.parallax.com/blockly/projectlink?id=127835&key=fb6d9dd9-1fde-413a-a587-38bf2f769912
Edit: In the code section above, I failed remember the "channel" array had been modified so center sticks were zero.
Ken Gracey
i have been trying out duane degn's code which i get that you have to run a separate function but now i can't get the pings to work i left my link open to the public (#1) being a code combo of yours and mine. and (#2) being a simplified update of yours and mine by duane degn.
1.
http://blockly.parallax.com/blockly/editor/blocklyc.jsp?project=127445
2.
http://blockly.parallax.com/blockly/projectlink?id=127835&key=fb6d9dd9-1fde-413a-a587-38bf2f769912
I messed up with the earlier code.
This should be better. (Speed code only. The Ping code will need to be changed.)
http://blockly.parallax.com/blockly/projectlink?id=127835&key=fb6d9dd9-1fde-413a-a587-38bf2f769912
You can intuitively drive an Arlo type robot with one joystick. Let X be the aileron input - 1500 and Y be the elevator input - 1500. This makes X and Y zero with a centered stick.
Assuming Y is positive when the stick is moved forward and X is positive when the stick is moved to the right, then the motor speed can be calculated as:
leftMotorSpeed = (Y + X) / C
rightMotorSpeed = (Y - X) / C
You might need to swap the + and - if X and Y don't behave as assumed above. The value "C" will scale the output to the appropriate range for the "Robot" comand. I don't know what is range is. If speed ranges from -100 to +100 then C should be set to around 5.
The above lets the robot turn in place when the stick is only moved side to side. I think you'll find it more intuitive than have the controls on two different joysticks.
I still haven't tested this out myself. I was using different hardware on my robot and need to switch it back to using an Activity Board with HB-25 controllers.
I'm a bit out of date with Parallax hardware.
I just now realized Arlo uses the DHB-10 AND the Activity Board WX.
I was attempting to use two HB-25 motor controllers. I see these are no longer made.
Sorry about that. I have a DHB-10 so I'll wire it up and see if I can better test your code.
Until I get up and running here are some suggestions.
I suggest you first test if the code works as desired using just the RC input. Use "Save As" to save a copy of your program and delete all Ping statements.
Once you're satisfied with the RC control, then start adding one Ping at a time. Say you add the Ping sensor on the right side of your robot. What do you want the robot to do when this Ping detects an object? I'd suggest turning away from it by slowing the speed of left wheel. You could either have the left wheel speed limited to a predetermined minimum value or you could scale the left wheel speed based on the right wheel speed and/or the distance detected by the Ping.
As I mentioned in an earlier reply, I think robots steer more intuitively using the elevator/aileron stick. I use the throttle and rudder channels to control other servos or gadgets.
Here's the code which works with my setup.
I use the throttle to set the max speed of the robot. I use aileron and elevator to control the robot's direction.
In order to figure out the pulses corresponding to various inputs, I used this program.
You might need change the value of some of the constants to get the code to work correctly with your hardware.
The constants to check are "CENTER_PULSE_1485" which is set to the value of the centered aileron and elevator channels (hopefully these are about the same value).
The constant "ZERO_THROTTLE_1108" is the throttle value when the throttle is at the lowest position.
"THROTTLE_RANGE_750" is the difference between the highest throttle setting and the lowest.
The constant "MAX_RC_MOVEMENT_410" is how far the aileron and elevator inputs can vary from the center position input.
Scaling the max speed using the throttle channel isn't a very useful feature. I might be better to use the throttle channel for something else.
I haven't added the Ping sensors yet. I only have two sensors myself but I'll share what I come up with here.
I worked a lot with some of the earlier Arlo hardware and I wasn't aware Parallax had switched to use the DHB-10 instead of two HB-25 drivers. I have a DHB-10 board so I can experiment with the latest hardware version of the Arlo.
Once I was able to test code, I could see all the errors in my earlier Blocky attempts.
Sorry have haven't helped with your Ping question yet but now that I have my hardware switched over, I should have an example to share soon.
I'm going to just think of senarios for two Pings for now (since that's how many I have handy).
Here's what I've thought of so far.
I figure I'll use two threshold distances. "PING_CAUTION" and "PING_DANGER". These are presently set at 60cm and 10cm but these values will likely change with experimentation. I'll also use "MAX_PING_SPEED" (presently 60) to set an adjusted speed when an obstacle is detected.
If either sensor detects an object withing the "PING_DANGER" range, the robot will only allow reverse motion.
If both sensors detect an object withing the "PING_CAUTION" range, the robot will slow to less than "MAX_PING_SPEED". The speed will likely be a function of the distance to the closest obstacle (closer the obstacle the slower the speed).
If only one sensor detects an object withing the "PING_CAUTION" range, the robot will slow the wheel opposite of the sensor. Hopefully this will allow the robot to turn away from an obstacle.
Since I don't have a Ping on the rear of my robot, I'm only modifying the speed when the robot is in forward motion.
Does anyone have other suggestions on what sort of logic to combine the Ping inputs with the RC inputs?
I'm just about to test my code. I'll share it in case anyone is interested in seeing it but don't expect it to work yet.
http://blockly.parallax.com/blockly/projectlink?id=128757&key=d7ac6b08-bf4c-486c-bb3e-08bbe34a6471
I'll update this thread after I test it.
I think rather than using the throttle to set the max speed of the robot, a better use of the channel would be adjust the distance limit where the Ping code is used. Another option would be use the landing gear or other spare channel to turn the Ping portion of the code on or off.
I'm not sure how much more I'll continue using Blocky with this robot. I find Blocky fun for small programs but when programs start to get large, the weakness of block based code exceeds its benefits. I'll likely switch to Spin for continued development.
I used these instructions to connect the Activity Board with the DHB-10.
I didn't add a buzzer on P4.
I used P0 through P2 for the radio input. I powered the radio receiver with 5V from the Activity Board. My radio receiver (Spektrum clone) uses 3.3V logic so I didn't have any resistors between the radio output and the Activity Board's input. If you use a radio with 5V logic, use a 3K to 10K resistor between the radio and the Propeller board on each channel.
I didn't use any of the three pin headers P14 through P17 since you plan to use these with the Ping sensors.
You can of course move the radio receiver pins to any unused pins. You'd just change the code shown in attached image as needed.
As I mentioned in an earlier comment, you might need to change the value of some of the constants based on the output of your radio. I previously linked to some code for checking the radio channels.
It would work with just two channels. I just changed the code and saved it here.
I haven't tested this version yet. I'll report back once I've made sure it works.
I'll update when it's fixed.
Edit: It might just be a wiring error.