View unanswered posts | View active topics It is currently Tue Jun 19, 2018 6:08 pm

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
sensor values of Lego and third party sensors
Author Message
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
sensor values of Lego and third party sensors
hi,
I would appriciate very much if the sensor values of Lego and third party sensors could be polled in the same way, e. g.
 Code:SetSensor(S1, SensorSonar);SetSensor(S2, HTCompass);SetSensor(S3, MindsensorsCamRaw);SetSensor(S4,I2CRaw); // with a series of I2C-sensors int i,j,k,l,m,n;i=SensorValue(S1);j=SensorValue(S2);k=SensorValue(S3);SetI2CAddress(S4,2);  // I2C channel/address= 2l=SensorValue(S4);SetI2CAddress(S4,3);  // I2C channel/address= 3m=SensorValue(S4);SetI2CAddress(S4,4);  // I2C channel/address= 4n=SensorValue(S4);

another idea to general I2C sensors:

 Code:l=I2CSensorValue(S4,2);m=I2CSensorValue(S4,3);n=I2CSensorValue(S4,4);

This would simplify the requested program code to a very convenient level !

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}

Tue Mar 18, 2008 7:12 am
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616

Great idea. But....

This only works if a sensor has a single returned value. This is not the case for many sensors including:
* Two axis gyros that return two 16-bit values
* Cameras that have many, many returned values.
* Two axis accelerometers with two 16-bit values
* Etc.

There doesn't seem to be a nice clean way to provide a common end user interface to these!

One way this is handled is by the hardware manufacturers. For example, the HiTechnic color sensor can be configured in "basic" mode where it behaves similar to a ultrasonic sensor. It returns a single value (range 0 to 16). But it has a more powerful mode where it returns 3-different 16-bit values for the three different color components.

Tue Mar 18, 2008 6:32 pm
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

OK, I see, sth. like
 Code:i=SensorValue(S1)

won't work with a Cam.

But maybe
 Code:int msg[10];in i;msg=SensorValue(S1) // OR:for (i=1;i<=10;i++){msg[i]=I2CSensorValue(S1,i);}

The I2C protocoll is much too complicate to handle. This really needs to be simplified a lot.
Why can't you implement a sensor protocol that allows some easy access to all sensors, equal if I/O, analog, or I2C (see above)?

As you said yourself, RobotC has been designed for beginners and novices.
An I2C protocoll is far too a low hardware- and bit-shifting level and appears to be more suitable for kind of professional embedded C programmers.

Novices and beginners need something like that 1 sensor block in NXT-G, but transfered to a convenient script language:

To get any sensor value, one line of RobotC code must fit!

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}

Wed Mar 19, 2008 4:49 am
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616

You're absolutely right! Individual programmers should not have to write drivers for each 3rd party sensor that they own.

The ROBOTC sample program includes drivers for a few of the 3rd party sensors. I had hoped that the sensor manufacturers would use these samples to write drivers in ROBOTC code the same way they have written NXT-G blocks; unfortunately they haven't!

The NXT-G blocks for 3rd party sensors are in fact complicated subroutines that "compile" into many instructions of the NXT-G virtual machine. These are masked from the end user.

THe sample drivers for ROBOTC behave similarly. They are code written in ROBOTC contained in a separate #include file. They usually have a simple interface which is all the end user needs to know about.

In fact, the simple sensors with a single value can be accessed with the "SensorValue[xx]" variable used throughout ROBOTC since the driver code is allowed to write to this value.

As time permits, additinoal driver files will be added to ROBOTC.

Wed Mar 19, 2008 5:32 am
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

 Dick Swan wrote: You're absolutely right! Individual programmers should not have to write drivers for each 3rd party sensor that they own.(...) I had hoped that the sensor manufacturers would use these samples to write drivers in ROBOTC code the same way they have written NXT-G blocks; unfortunately they haven't!

That's really poor!
From the view of the customers, it seems that completely developed RobotC drivers are available just like NXT-G sensor blocks, because the manufacturers (Mindsensors, Hitechnic) picture your "RobotC label" on their websites.
That every single programmer has to write his own routines is unreasonably and impudently (babelfish English, sorry ).
Why don't you forbid them to show your trademark label, if they they don't hold, what they promise!?
 Dick Swan wrote:As time permits, additional driver files will be added to ROBOTC.

I'll gladly wait for it...
Maybe we can start meanwhile publishing such private written drivers, if the code will be checked by you (just as I started with the HT Compass driver, see my posting in "NXT Programming: Tips for Beginning with ROBOTC")

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}

Last edited by Ford Prefect on Wed Mar 19, 2008 10:53 am, edited 2 times in total.

Wed Mar 19, 2008 5:56 am
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616

Ford Prefect wrote:
 Dick Swan wrote: You're absolutely right! Maybe we can start meanwhile publishing such private written drivers, if the code had been checked by you (just as I started with the HT Compass driver, see my posting in "NXT Programming: Tips for Beginning with ROBOTC")

I'm all for user contributions.

Did you notice that the compass sensor driver is one of the samples included with ROBOTC? There's two files -- a driver file and a sample of its use.

Wed Mar 19, 2008 6:09 am
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

no, I didn't!
I probably e-mailed 20 times to Hitechnic, cause with the drivers I found I didn't get it to work.
Could you plz check "my" code and compare it with yours (especially the calibrating part of the routine)?
If the code is the same, I will delete my post.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}

Wed Mar 19, 2008 6:25 am
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

I meanwhile found some compass code of you (I think), but
- it's much too complicated to handle
- it lets you not calibrate the sensor.
- some endless tasks are started, which consistantly search, if a compass has been connected (this is absolutely unnecessary, cause I know where I have attached a sensor, the driver must not search for this!) .

I think the Hitechnic Code (and my small header file adjustement) are the best and most convenient for the moment.

Maybe you can improve the code further on to initiate and access the sensor like
 Code:SensorType[port]=HTCompass;CalibrateSensor[port];heading=SensorValue[port];

using the same routines, but expanding the RobotC syntax for sensor access (?) - I can't do that.
(it's hard to explain for me in English. What I mean is:
die Routinen des HiTechnic Codes sollen beibehalten werden, aber die bestehende RobotC Syntax für den Zugriff auf Sensoren soll entsprechend auf den Kompass erweitert werden)

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}

Wed Mar 19, 2008 3:36 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 8 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.