Subject:
|
whats wrong with this events ?
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sat, 28 Oct 2000 22:13:25 GMT
|
Original-From:
|
Rik Bos <RIKBOS@XS4ALL.stopspamNL>
|
Viewed:
|
816 times
|
| |
| |
I tried to make a proximitysensor with was "direction aware", this means i used
two lightsensors on port 1 and 3.
And tried to make the change of direction dependable of with sensor(event) was
triggert.
See code :
#define EVENT_PROXL 0 // proximity change
#define EVENT_SWITCH 1 // right switch
#define EVENT_PROXR 2 // proximity change
#define CurrentEvents() ActiveEvents(10)
sub initial() // this is setting up the variables and events etc..
{
SetUserDisplay(BatteryLevel(),3);
SetSensorType(SENSOR_1, SENSOR_TYPE_LIGHT);
SetSensorType(SENSOR_2, SENSOR_TYPE_TOUCH);
SetSensorType(SENSOR_3, SENSOR_TYPE_LIGHT);
SetSensorMode(SENSOR_1, SENSOR_MODE_RAW + 31);
SetSensorMode(SENSOR_3, SENSOR_MODE_RAW + 31);
SetTxPower(TX_POWER_HI);
SetPower(OUT_B,8);
SetEvent(EVENT_PROXL, SENSOR_1, EVENT_TYPE_FASTCHANGE);
SetEvent(EVENT_SWITCH, SENSOR_2, EVENT_TYPE_PRESSED);
SetEvent(EVENT_PROXR, SENSOR_3, EVENT_TYPE_FASTCHANGE);
ev = 0;
_pow=6;
}
task check_signal()
{
SetPriority(1);
while(true)
{
monitor(EVENT_MASK(EVENT_PROXL) + EVENT_MASK(EVENT_PROXR))
{
SendMessage(255); Wait(20);
}
catch
{
ev = 0;
if (EVENT_MASK(EVENT_PROXL))
{
ev = 1;
}
if (EVENT_MASK(EVENT_PROXR))
{
ev = ev + 2
}
switch(ev)
{
case 1:
left(_pow);
Wait(TURN_TIME);
forw(_pow);
break;
case 2:
right(_pow);
Wait(TURN_TIME);
forw(_pow);
break;
case 3:
back(_pow);
Wait(BACKTIME);
left(_pow);
Wait(TURN_TIME);
forw(_pow);
break;
default:
break;
}
}
}
}
I'm always ending up with ev = 3 e.g. driving backwards(case 3) even if i
disconnect one sensor, what's going wrong ?
I'm sorry for the long list of code but knew no other way to express the problem
Rik Bos
--
MIME ATTACHMENTS DISCARDED:
1. Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Length: 4833
|
|
Message has 1 Reply:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|