|
Page 1 of 1
|
[ 7 posts ] |
|
Dynamically accessing sensors and motors
| Author |
Message |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Dynamically accessing sensors and motors
If is possible to access sensors and motors based on a variable? For example: or: Of course, I know that these won't compile or work, but I want to be able to implement this type of functionality. I'm trying to write a library, and want to create functions that can be used in a wide variety of situations. Is there any way to accomplish what I'm trying to do?
_________________ sudo rm -rf /
|
| Sat Jan 08, 2011 8:14 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 Re: Dynamically accessing sensors and motors
Take a look at the driver suite I've made. I pass variables for sensors all the time  Just not as strings. - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Jan 09, 2011 2:24 am |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: Dynamically accessing sensors and motors
Of course I should have looked at your drivers! I feel dumb now  . Thanks so much.
_________________ sudo rm -rf /
|
| Sun Jan 09, 2011 10:45 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 Re: Dynamically accessing sensors and motors
No need to feel dumb.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Jan 09, 2011 10:49 am |
|
 |
|
charsleysa
Rookie
Joined: Mon Jan 10, 2011 11:39 pm Posts: 16
|
 Re: Dynamically accessing sensors and motors
Iv have already written a Framework that uses this everywhere. I even write my own commands that access the opcodes directly. Here take a look at this: This allows me to change the sensor type by using my own definitions/variables that use integers instead of the default ones. not very complex but very handy. Heres its use:
_________________Regards Stefan Andres Charsley charsleysa@gmail.com
|
| Mon Jan 10, 2011 11:52 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 Re: Dynamically accessing sensors and motors
Accessing the opcodes directly is a completely unsupported way of working. There is no guarantee that the opcodes remain the same between releases, only the ROBOTC API to access them.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue Jan 11, 2011 2:03 am |
|
 |
|
charsleysa
Rookie
Joined: Mon Jan 10, 2011 11:39 pm Posts: 16
|
 Re: Dynamically accessing sensors and motors
Well the RobotC API does the exact same thing as I have done there, no different! And if they change it, so will I! But they hardly ever do, they just add on to the end, so the opcode numbers have like never changed! And accessing the opcodes directly give me an advantage because I wont be limited to the RobotC API, the only restriction I have is the RobotC firmware!
_________________Regards Stefan Andres Charsley charsleysa@gmail.com
|
| Tue Jan 11, 2011 2:19 am |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|