-
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
- Jumping Drone
- Computer on Windows
- Wireless
SumoController ctrl = new SumoController();
if (ctrl.Connect())
{
// Make a square
for (int i = 0; i < 4; i++)
{
run = true;
// forward about 1m
Task.Run(() => { while (run) ctrl.Move(40, 0); } );
Thread.Sleep(1500);
//Stop
run = false;
// Turn 90°
ctrl.QuickTurn((float)Math.PI / 2);
}
}
ctrl.Disconnect();
ctrl.Dispose();
SumoController offer basic move of jumping drone:
use Move(sbyte speed, sbyte turn)
to forward and turn
use QuickTurn(float Angle)
to quick turn of a Radian Angle
But it can control Posture, Animation and Jump:
Postures(SumoEnum.Posture Posture)
Animation(SumoEnum.Animation Animation)
Jump(SumoEnum.Jump JumpType)
About Jump, Jumping drone can kick in object. For that, Use Posture.Kicker
and call JumpLoad()
to compress Spring
to release Spring and "kick" call Jump(SumoEnum.Jump.LongJump)
SumoController have many events that drone sent.
Video has proper event ctrl.ImageAvailable
wich offer:
LibSumo.Net.Events.ImageEventArgs
that contains RawImage
in OpenCV Mat format.
you can easily use .ToWriteableBitmap(PixelFormats.Bgr24);
to be used in Image component
All other events are sent in ctrl.SumoEvents += Ctrl_SumoEvents;
You can easily switch() on SumoEventArgs.TypeOfEvent
to get what event is sent.
switch(e.TypeOfEvent)
{
case (SumoEnum.TypeOfEvents.BatteryAlertEvent):
break;
case (SumoEnum.TypeOfEvents.BatteryLevelEvent):
break;
case (SumoEnum.TypeOfEvents.Connected):
break;
case (SumoEnum.TypeOfEvents.Disconnected):
break;
case (SumoEnum.TypeOfEvents.Discovered):
break;
case (SumoEnum.TypeOfEvents.PilotingEvent):
break;
case (SumoEnum.TypeOfEvents.PostureEvent):
break;
case (SumoEnum.TypeOfEvents.RSSI):
break;
}
Then use properties of SumoEventArgs
to get correct value
public SumoEnum.Posture Posture { get; set; }
public SumoEnum.BatteryAlert BatteryAlert { get; set; }
public int BatteryLevel { get; set; }
public int Rssi { get; set; }
public sbyte Speed { get; set; }
public sbyte Turn { get; set; }
SumoKeyboardPiloting
offer a ready to use Keyboard Hooker, Speed and Turn Acceleration and Deceleration algorithm, Ready to expand Keyboard Mapping...
For that, just let SumController
to instanciate SumoKeyboardPiloting
class by using the constructor SumoController(out SumoKeyboardPiloting piloting);
After that you have to connect piloting.Move
event to your handler and use the pre-calculated speed and turn value controller.Move(e.Speed, e.Turn);
to move your drone.
To respond to other key action, simply connect piloting.KeyboardKeysAvailable
event and switch() on KeyboardEventArgs.CurrentKey
private void Piloting_KeyboardKeysAvailable(object sender, KeyboardEventArgs e)
{
HookUtils.VirtualKeyStates key = e.CurrentKey;
bool IsPressed = e.IsPressed;
switch((int)key)
{
// Postures
case ((int)HookUtils.VirtualKeyStates.VK_F1): // Normal
controller.Postures(LibSumo.Net.Protocol.SumoEnum.Posture.jumper);
break;
use Ascii code for Normal keys
// Quick Turn
case (0x57): // Letter w
controller.QuickTurn(ToRadians(180)); //Quick turn right
You can connect many drone to the same Wifi for that simply use https://github.com/CoyoteProd/Jumping-PEAP project to connect your drones to your favorites wifi router.
Then you can create a ListOfDevices = new List<MiniDevice>();
which contains drones name then pass the array to controller : controller = new SumoController(out piloting, listOfName, true);
After that the controller callback notify you with the drone name discovered. See SumoApplication for more details