7996B
November 10, 2022, 3:11pm
5
Gif class made by Jpearman as a demo that can show off “a couple of C API’s that we don’t usually expose that were added to vexos 1.0.5”:
Hers’s another demo that can be built with VEXcode. It’s not very well developed and uses a couple of C API’s that we don’t usually expose that were added to vexos 1.0.5. I’ll also explain a couple of more advanced aspects of the setup in another post later, specifically how to allow VEXcode access to more dynamic memory than is available with the default project build scripts.
output looks like this.
[gifdemo]
and uses this animated gif.
[world]
You can display more than one gif by creat…
in that topic he covers how to change the HEAP size:
Looks like I had already bumped the HEAP size up to 8MB for this demo, so 45 second gif I would have thought worked, however, you could try changing this line in mkenv.mk
LNK_FLAGS = --defsym _HEAP_SIZE=0x800000 -nostdlib -T "$(TOOLCHAIN)/$(PLATFORM)/lscript.ld" -R "$(TOOLCHAIN)/$(PLATFORM)/stdlib_0.lib" -Map="$(BUILD)/$(PROJECT).map" --gc-section -L"$(TOOLCHAIN)/$(PLATFORM)" ${TOOL_LIB}
The _HEAP_SIZE symbol control the size, the default for VEXcode if this is not defined is just 1MB, for thi…
factory calibration for IMU:
This procedure calibrates the accelerometers in the Inertial sensor and saves the result in non volatile memory.
This procedure needs vexos 1.0.10 or later.
Only perform this calibration if your VEX inertial sensor is showing angles for roll and/or pitch that are larger than perhaps 1 or 2 degrees when the inertial sensor is on a flat surface that is known to be level in both axis.
Some inertial sensors can show significant error for roll and pitch when placed on a level surface. To check a…
7 Likes
Sylvie
November 10, 2022, 3:12pm
6
i advise people to be careful here…
7 Likes
xTigr
November 30, 2022, 9:34pm
8
Optical sensor update rates:
The optical sensor will send back data to the the brain every 20mS, however, to make the sensor sensitive enough to light the default integration time is 103mS, that means that normally you will see values change approximately every 100mS. The integration time can be changed in VEXcode as necessary, the relevant APIs are.
/**
* @brief set sensor integration time
*/
void integrationTime( double timeMs );
/**
* @brief get sensor integration time…
4 Likes
Vex Electronics Taken Apart:
I got some requests to post the pictures I took while disassembling and reassembling my V5 components, so here they are.
[DISCLAIMER: Don’t take this as a guide in any way. Don’t do this unless you really know what you are doing and are willing to replace the part you are messing with. For the curious of you (like me), I took pictures so you wouldn’t have to do this.]
Let’s start things off with the motor:
Front cap removed:
[Photo Sep 05, 4 23 00 PM.jpg]
Casing separated:
[Photo Sep 05, …
4 Likes
xTigr
February 17, 2023, 2:26pm
11
controller::button::PRESSED:
Here, a couple of examples for you. Obviously move most of the code into usercontrol, except leave the event registration in main if you go that route.
This one using the button pressing() API, it detects the release to press transition.
example using pressing and state flags /*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp …
4 Likes
The guido class, which is generally never used by customers although could be, looks like this.
namespace vex {
class guido {
public:
guido(){};
virtual ~guido(){};
// pure virtual methods that must be implemented
virtual double angle( rotationUnits units = rotationUnits::deg ) = 0;
virtual double heading( rotationUnits units = rotationUnits::deg ) = 0;
virtual void calibrate( int32_t value ) = 0;
virtual bool isCalibrating(void) = 0;
virtual void setHeading( double value, rotationUnits units ) = 0;
virtual double rotation( rotationUnits units = rotationUnits::deg ) = 0;
virtual void setRotation( double value, rotationUnits units ) = 0;
virtual turnType getTurnType( void ) = 0;
};
};
how the GPS and gyro works
2 Likes
A few finds from messing around this season, including some random fun facts.
vex::vision::code
is largely undocumented/unexplained. I believe these work similar to Pixy2 Vision Codes
Suprisingly, vex::pneumatics
isn’t listed anywhere on VEX help resources (they recommend using digital_out
instead). This offers an easier abstraction over digital_out
.
vex::this_thread::sleep_for();
offers an alternative API to vex::task::sleep
, which better matches the standard library implementation of threads.
Headers for libv5rt can be easily accessed via the vscode extension (since lv5rt.a
is a static library). api.vexcode.cloud seems to be generated on these headers using doxygen (or something similar). These include the undocumented C API, but not the actual private API (v5_apiprivate.h
is omitted from the actual production distribution of the V5 SDK).
The actual entrypoint for the V5 API is actually v5_cpp.h
and not v5_vcs.h
. v5_vcs.h
seems to be included in vex.h
as a relic of the older VEX coding studio program.
vex::competition::bStopAllTasksBetweenModes
For some reason vex::inertial::getTurnType
is marked as protected, making it impossible to tell which direction the gyro of an inertial sensor reads as positive.
VEXCode Pro is written using nw.js and uses Monaco for its internal editor.
This is documented, but not well known. vex::triport::installed
allows you to get the status and type of a triport device, similar to how smart port devices have an installed method.
vex::controller::axis::position
returns integers from [-100, 100], while vex::controller::axis::value
returns integers from [-127, 127]. This isn’t really listed anywhere, and could be a footgun if you use value instead of position.
8 Likes
Sylvie
March 7, 2023, 4:24pm
14
teehee~
there is more fun to be had here
4 Likes
LVGL running on VEXcode; uses some undocumented v5 API calls for configuring the brain display properly.
The LittleV Graphics Library (LVGL) has some nice demo code. One example is a music player demo, it needs the latest version of LVGL. I was updating the VEXcode LVGL library repo today to the latest (7.11.0) and thought it might be fun to try the music player on the V5. Works quite nicely.
[IMG_1302]
source the for project is here.
and if you want to change LVGL configuration, the vexcode lvgl library project is here.
1 Like
Vision sensor methods.
Also it’s probably important to mention the comment suggests that these could likely be removed or recieve breaking changes at any time, so probably don’t use these.
2 Likes
Details on controller position vs. value
The whole point of position() returning values in the range +/- 100 was so it could be directly used in APIs that take percentage as a parameter. We kept value() (which existed before the position() function was added) returning +/-127 as that was the traditional range for a VEX controller axis to return.
and for those interested, this is all position() does.
int32_t
controller::axis::position( percentUnits units ) const {
int32_t percent = value() * 100 / 127;
return( percent );
}
The installed() motor class member function will tell you if a motor is installed on a particular port. example of use.
while(1) {
for(int port=PORT1;port<PORT22;port++) {
vex::motor m(port);
if( m.installed() ) {
// do something with a detected motor
}
else {
// no motor on this port
}
}
this_thread::sleep_for(100);
}
detecting if motors are plugged into the brain
2 Likes
ok, I see, on the product page.
That’s mostly, but not entirely, wrong.
Internally the raw data we get from the sensor is about that (IIRC, it’s actually 640x480), but it’s in a format that’s not very useful for the color detecting algorithm. That image is converted and scaled down to 316x212 for processing, that’s also the coordinate system used for sending object information back to the V5.
see this kb article.
size of the vision sensor is scaled down from the camera
1 Like
you could have a look at code I posed here.
or the simplified version using graphical setup here.
That’s probably a lot more than you need, it simulates the built in drive code for V5
GitHub repositories containing V5’s default “Drive” program. Useful as a reference for implementing joystick control, or for those programming clawbots, I guess.
2 Likes
If updating from 1.1.1 to 1.1.2, the components that are updated will be.
Internal power control firmware
Inertial sensor
GPS
3-wire port firmware
motors, controllers, everything else, is the same as in 1.1.1
updated part firmware for vexOS 1.1.2
1 Like
It’s essentially the same.
The issue we have is that there is no way to detect a gen2 battery from an older gen1 battery. Gen2 batteries have a much flatter discharge curve, voltage will drop quickly during perhaps last 15% of capacity. We could have tried to add some fancy code looking at voltage over time, but in the end we just decided to keep it simple and do what we did in gen1.
// full range 6400mV to 8200mV
int32_t percent = (volts - 6400) / 18;
// limit to 5% increments
percent = (pe…
IQ gen2 battery percentage
Yes, with the correct tools you could recover Python source code from the brain.
yes, Python source is “compiled” to byte code by the interpreter before it runs (to improve execution speed).
python code is compiled on the brain
1 Like