linorobot / linorobot2_hardware

Apache License 2.0
92 stars 84 forks source link

Support for SimpleFOC / I2C commander? #11

Open samuk opened 2 years ago

samuk commented 2 years ago

Hi I'm interested in running I2C commander which communicates with SimpleFOC driver boards.

Code something like this would need to be added to your firmware. If I figure it out would you accept a pull request? Or is it a bit niche to be included?

There are a number of drivers that support it, from low to high power

samuk commented 2 years ago

Also noting this exists: https://github.com/Factor-Robotics/odrive_ros2_control which might be a more mainstream way of supporting BLDC motors

grassjelly commented 2 years ago

Hey @samuk . Thanks for the proposed PR. PRs are always welcome. You could take a look at how drivers are abstracted here: https://github.com/linorobot/linorobot2_hardware/blob/master/firmware/lib/motor/motor_interface.h and how to make a new macro for your driver https://github.com/linorobot/linorobot2_hardware/blob/master/firmware/lib/motor/motor_interface.h . Looking forward

samuk commented 1 year ago

Using the code here: https://github.com/samuk/linorobot2_hardware

I'm getting these errors https://pastebin.com/aSwiMDed

samuk commented 1 year ago

Even when compiling for teensy41 (rather than esp32) I get this error.

To replicate

`cd firmware
cp platformio.ini platformio.ini.old
rm platformio.ini
wget https://raw.githubusercontent.com/rosmo-robot/linorobot2_hardware/galactic/firmware/platformio.ini
cd /lib/motor 
cp default_motor.h default_motor.h.old
rm default_motor.h
wget https://raw.githubusercontent.com/rosmo-robot/linorobot2_hardware/galactic/firmware/lib/motor/default_motor.h
cp motor.h motor.h.old
rm motor.h
wget https://raw.githubusercontent.com/rosmo-robot/linorobot2_hardware/galactic/firmware/lib/motor/motor.h`
samuk commented 1 year ago

I think this is a conflict between SimpleFOC code and Linorobot2 code. I'm not sure it's resolvable.

samuk commented 1 year ago

Some suggestions: just add something like "lino_" in front of all the conflicts.. i.e., rename Encoder to LinoEncoder. The other issues seem to be that the function doesn't exist (analogwritefrequency), which you probably could just comment out because you won't be using it with the FOC anyway.