whill-sdk-arduino
A simple WHILL Model CR Library for Arduino.
Requirements
- WHILL Model CR (Normal Model C does not support serial communication.)
- An Arduino device suports SoftwareSerial. e.g. Arduino Uno.
- RS232C Shield (Recommended:https://www.seeedstudio.com/RS232-Shield-p-1910.html)
Getting Started
Download this repository and place on your Arduino library folder.
APIs
Communication
WHILL(SoftwareSerial*)
Initialize WHILL instance with SoftwareSerial.
WHILL::begin(unsigned int interval_ms)
Command WHILL to start reporting WHILL status.
WHILL::refresh()
Fetch serial interface and do internal process.
Call this function , WHILL::delay()
and/or WHILL::keep_joy_delay()
once at least in loop()
. Callbacks are fired when these functions are called.
stopSendingData()
Command WHILL to stop report WHILL status.
Manipulation
WHILL::setJoystick(int x,int y)
Manipulate a WHILL via this command.
WHILL::setPower(bool)
Turn on/off a WHILL. True
to power WHILL on.
WHILL::setBatteryVoltaegeOut(bool)
Enable/Disable power supply to the interface connector. True
to enable power supply.
Sensors and Status
Accelerometer
int WHILL::accelerometer.x
int WHILL::accelerometer.y
int WHILL::accelerometer.z
Accelerometer mounted on body.
Gyro
int WHILL::gyro.x
int WHILL::gyro.y
int WHILL::gyro.z
Gyro sensor mounted on body.
Battery
unsigned char WHILL::battery.level
signed long WHILL::battery.current
Remaining battery level and consumpting current[mA].
Motor State
float WHILL::left_motor.angle
int WHILL::left_motor.speed
float WHILL::right_motor.angle
int WHILL::right_motor.speed
Motors angle and speed. The angle range is -PI to +PI, Speed unit is km/h.
Note that the speed value is low-pass filterd.
Speed Mode
bool WHILL::speed_mode_indicator
Current selected speed mode.
Callback
By registering callback functions, You can hook at status is updated.
See Example: callback.ino
License
MIT License