- Forum
- Roboteq Motor Controllers
- Controller Configuration & Operation
- Stop forwarding motion with HDC2450
Stop forwarding motion with HDC2450
- marcusbarnet
- Topic Author
- Offline
- Posts: 69
- Thank you received: 0
I drive it with RC pulses.
I try to better explain what I have to do: I\'m using some sonars placed in front of my robot to detect obstacles.
When a detection occurs, I have a digital output which goes HIGH (5V) for all the detection duration.
What I need to do is to read the digital output with my HDC2450 and then to immediately stop the forwarding motion if the signal becomes HIGH.
Since the sonars are placed just in front of my robot, I only need to stop the forward motion (even if the forward RC pulse is still present) in case of a detection: in this way, i can turn on the left or on the right or go backward to clear the frontal obstacle detection.
Is it possible to do this configuration by using the Roborun utility? Or do I have to develop a script?
Please Log in or Create an account to join the conversation.
- roboteq
Alternatively, you need to write a script that will monitor the digital input and then alter the motor command when the wall is detected. Let us know if you want to explore that route and if you need guidance to get started.
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
- Posts: 69
- Thank you received: 0
Since I need to have a safe and reliable solution, I think I should try the second route you suggested (my company need to commercialize the robot, so it must work very well in any condition).
Even if I\'m using a lot of your drivers for this mobile robot (MDC2250, HDC2450, SDC2150) I never had the opportunity to write a script so I need guidance to get started.
I\'ve read the user manual, but I didn\'t understand it very well.
Can you guide me in this script developing, please?
In this way, I can add other features to the script and improve the driver operations.
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
- Posts: 69
- Thank you received: 0
I wrote this script, for the moment:
top:
digital_value = getvalue(_DI, 1)
if digital_value == 1 then
setcommand(..,..) \'What do I have to specify here?
end if
wait (50)
goto top
I think I should stop the forward motion and disable the forward RC pulse recognition until the digital_value returns to LOW.
However, when digital_value is equal to 1 I still need to be able to turn on the right or on the left or to go backward in order to come back to a \"non-collision\" condition.
P.S. If I use a print command, for example: Print(\"String\"), then this word can be even read from USB connection by using Linux Library?
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
- Posts: 69
- Thank you received: 0
setconfig(_DINA, 1, 164)
where 164 = (4 + 1*32 + 2*64)
and 4 is the value for the forward limit switch.
But isn\'t it the same thing which I can do with Roborun utility?
Please Log in or Create an account to join the conversation.
- roboteq
For your script, one important consideration is that the motor commands will now be given from the script, instead of from your remote control or external microcomputer.
So you must have the script capture the command from your radio or microcomputer, check the limit sensor, and then apply the command to the motor.
The untested script below should do what you need. It assumes command are received from the RC radio pulse inputs.
Beware that
top:
\' Read Commands that arrived on the RC pulse inputs
Throttle = getvalue(_CIP, 1)
LeftRightJoystick = getvalue(_CIP, 2)
\' Read the sensor
WallAhead = getvalue (_DI, 1)
\' Do not allow forward motion if WallAhead
if(WallAhead = 1 and Throttle > 0) then Throttle = 0
\' Apply to motors
setcommand(_G, 1, Throttle)
setcommand(_G, 2, Steering)
\' Print on the console for debugging
print(\"\\rWA=\",WallAhead,\" T=\",Trottle,\" S=\",Steering\")
wait(10)
goto top
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
- Posts: 69
- Thank you received: 0
Your code seems to be very clear to me even if I didn\'t testet it, yet.
Just one question: does this code work well even if I\'m using mixed mode for tank steering?
Or do I have to add some specific value in the script in order to achieve the tank steering mode?
P.S. This command
will also send the text over USB at the same time?print(\"\\rWA=\",WallAhead,\" T=\",Trottle,\" S=\",Steering\")
If yes, I can use it to read information in my C application under Linux.
Please Log in or Create an account to join the conversation.
- roboteq
The print output will go on the last port on which a command was received.
If you only have USB connectd and you sent data to the controller via USB, then the output of print will remain on the USB.
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
- Posts: 69
- Thank you received: 0
If you only have USB connectd and you sent data to the controller via USB, then the output of print will remain on the USB.
Is there any function in roboteq linux library which I can use to read sent data in my C application?
In this way, I can add a print statement in the script you suggested before in order to send a text string to my C application when WallAhead is HIGH.
Please Log in or Create an account to join the conversation.
- roboteq
Please Log in or Create an account to join the conversation.
- Forum
- Roboteq Motor Controllers
- Controller Configuration & Operation
- Stop forwarding motion with HDC2450