Stop forwarding motion with HDC2450

7 years 10 months ago #29527531 by marcusbarnet
As you know, I\'m using a HDC2450 driver in mixed mode (for tank steering) for one of my mobile robots and I need to stop the forwarding motion when a particular event occurs.
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.

7 years 10 months ago #29527535 by roboteq
Replied by roboteq on topic Re:Stop forwarding motion with HDC2450
You may be able to use the function \"Forward Limit\" switch, as the Use configuration for the digital input. But that function may operate somehow funny in the mixed mode.

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.

7 years 10 months ago #29527539 by marcusbarnet
Thank you a lot for your reply.

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.

7 years 10 months ago #29527541 by marcusbarnet
I need help to understand the command to use to block the forward motion.

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.

7 years 10 months ago #29527545 by marcusbarnet
May be, I should use this:
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.

7 years 10 months ago #29527549 by roboteq
Replied by roboteq on topic Re:Stop forwarding motion with HDC2450
You should use setconfig only to change configuration that need to be changed on the fly. Otherwise just set them with Roborun and do not change them from the script.

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.

7 years 10 months ago #29527551 by marcusbarnet
Thank you a lot!

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

print(\"\\rWA=\",WallAhead,\" T=\",Trottle,\" S=\",Steering\")

will also send the text over USB at the same time?
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.

7 years 10 months ago #29527553 by roboteq
Replied by roboteq on topic Re:Stop forwarding motion with HDC2450
This script is written for mixed mode where commands on channel 1 is the throttle, and channel 2 is steering.

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.

7 years 10 months ago #29527555 by marcusbarnet

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.

7 years 10 months ago #29527563 by roboteq
Replied by roboteq on topic Re:Stop forwarding motion with HDC2450
THe linux libary lets you send command, queries and configurations. Pls check the documetation.

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.143 seconds