RoboDurden / Hoverboard-Firmware-Hack-Gen2.x

with different defines_2-x.h for different board layouts :-) Compiles with Keil version 6
GNU General Public License v3.0
73 stars 24 forks source link

SendLR #60

Open BaktiyarBr opened 5 months ago

BaktiyarBr commented 5 months ago

hello thank you for your project it saved our lifes i have a quiestion im using HoverSendLR function and passing -1000 and 1000 to spin the wheel to oposite directions but it doesnt work how spining to different sides can be done

2.10 test speed example

RoboDurden commented 5 months ago
  template <typename O,typename I> void HoverSendLR(O& oSerial, I iSpeedLeft, I iSpeedRight) // -1000 .. +1000
  {
    // speed coeff in config.h must be 1.0 : (DEFAULT_)SPEED_COEFFICIENT   16384
    // steer coeff in config.h must be 0.5 : (DEFAULT_)STEER_COEFFICIENT   8192 
    HoverSend(oSerial,iSpeedRight - iSpeedLeft,(iSpeedLeft + iSpeedRight)/2);
  }

Please post the serial feedback log sent from hoverboard to ESP32 (or alike).

AILIFE4798 commented 5 months ago

gen2.x does not support tank steering afaik use uartbus

RoboDurden commented 5 months ago

HoverSendLR should just do that. send a speed for left motor and a speed for right motor. But have not tested it for a long time now..

AILIFE4798 commented 5 months ago

ok i dk that it would be very helpful

BaktiyarBr commented 5 months ago

so i have this HoverSendLR(oSerialHover, 1000, -1000); and log says iSpeed0 iSteer 1000 and wheels doesnt move at all how to use uartbus for this?

AILIFE4798 commented 5 months ago

uartbus master and slave will receive own speed and you need to change the slaveID of them so you can set them to different speed

RoboDurden commented 4 months ago

Well, @AILIFE4798 might be right and the hoverSendLR is old code from my EFeru FOC hovercar firmware.

For some reason, This gen2 firmware uses a large float array to map steer and speed to speedL and speedR in main.c

So maybe hoverSendLR does not work as expected.

@BaktiyarBr , you could replace the angle mapping with the original code from Niklas fauth

speedR = CLAMP(speed SPEED_COEFFICIENT - steer STEER_COEFFICIENT, -1000, 1000); speedL = CLAMP(speed SPEED_COEFFICIENT + steer STEER_COEFFICIENT, -1000, 1000);

and report back if we can get rid of that huge angle array main.c

Or try uartBus as suggested by @AILIFE4798

RoboDurden commented 4 months ago

In gen2.x it is named pwmSlave and pwmMaster. Simply overwrite these values at

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x-GD32/blob/baea91b61afc442094e400651ade305a14643c60/HoverBoardGigaDevice/Src/main.c#L418