Comments (6)
Hi Stephan,
This library is focused on Reinforcement Learning which is why the default interface is an OpenAI gym environment.
There is a lower-level interface to the Qube (and the Quanser Aero) in quanser_wrapper.pyx
For example if you want to apply a random voltage at every timestep:
import random
from gym_brt.quanser.quanser_wrapper.quanser_wrapper import QubeServo2
with QubeServo2(frequency=250, max_voltage=3.0) as qube:
while True:
voltages = [random.gauss(mu=0, sigma=1.0)]
currents, encoders, others = qube.action(voltages)
print(f"voltage={voltage}, currents={currents}, encoders={encoders}, others={others}")
Or if you want to apply a sine wave:
import math
from gym_brt.quanser.quanser_wrapper.quanser_wrapper import QubeServo2
with QubeServo2(frequency=250, max_voltage=3.0) as qube:
count = 1
sine_wave_period = 2 # in seconds
while True:
voltages = [math.sin(count / (frequency * sine_wave_period))]
currents, encoders, others = qube.action(voltages)
print(f"voltage={voltage}, currents={currents}, encoders={encoders}, others={others}")
count += 1
from quanser-openai-driver.
from quanser-openai-driver.
So i have tried it and it's working but i would like to do something like:
hil_read_analog(board, channels)
hil_write_analog(board, channels, voltages)
in quanser hil api you can do :
result=hil_read(board, analog_channels, NUM_ANALOG_CHANNELS, encoder_channels, NUM_ENCODER_CHANNEL, digital_channels,NUM_DIGITAL_CHANNELS, other_channels, NUM_OTHER_CHANNELS, &voltages[0], &counts[0], &states[0], &values[0] );
Is it possible ?
from quanser-openai-driver.
Can i do something like that ?
from quanser-openai-driver.
Hi Stefan,
The way this library is implemented is by abstracting away some of the lower-level information like those used in the HIL SDK examples. So that you can use the Qube but not need to deal with those HIL API functions.
You can make this work by looking at the code in quanser_wrapper.pyx as a starting point and using that to create Cython functions that can then be called from Python. If you would like to add some additional functionality similar to that feel free to open up a pull request
I've been looking into rewriting the library with ctypes which would have made it easier to do exactly that but have not had much time or need for those changes on the reinforcement learning side.
from quanser-openai-driver.
Thank you very much, I know how to code c and Python but i don't really know how to that sorry. I also found that quanser has python api, almost same as c api for linux. You have to install quarc runtime and than you can install this python api on ubuntu.
from quanser-openai-driver.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quanser-openai-driver.