ev3dev-lang-python icon indicating copy to clipboard operation
ev3dev-lang-python copied to clipboard

High-level abstractions like Lejos

Open pepijndevos opened this issue 7 years ago • 6 comments

If you have a look at the Lejos API, you'll see a bunch of lejos.hardware packages that provide very similar functionality to the ev3dev API. But there are also a lot of lejos.robotics packages that provide higher-level tools for common tasks such as localisation, mapping, and pathfinding, based on a common wheeled chassis interface.

I'm aware that this library has a MoveTank class that is similar to basic uses of lejos.robotics.chassis and maybe a subset of lejos.robotics.navigation.MovePilot, but there is a lot that has no equivalent.

Concretely, I was looking for an interface for a holonomic robot with omni-wheels. After fighting with Lejos a bit, I just wrote the following snippet

import numpy as np
angles = np.deg2rad([-36.8, -90, 36.8])
coef = np.array([np.sin(angles), np.cos(angles), [-1,1,1]]).T
speed = np.zeros(3)
# do stuff, set x, y, rotation speed
sp = coef.dot(speed)
# turn motors
motor_left.run_forever(speed_sp=sp[0])
motor_back.run_forever(speed_sp=sp[1])
motor_right.run_forever(speed_sp=sp[2])

I'm a functional guy, so I like the concept of just passing around a matrix to represent a wheeled platform. It generalizes nicely to any number of motors and supports generic math operations. You could have a MotorVector class that allows you to do speed_sp=[sp1, sp2, sp3] which would be sweet. But the rest of the library seems to be more OOP, and numpy is not a small dependency.

I'm curious what the best way would be to support more high-level interfaces in this library? The current structure of some utility classes scattered around the motor module seems not very suitable for a more complete robotics package. And if this package should be modeled on the Lejos API, the MoveTank, or something new, is up for debate. Or maybe these higher-level modules should even live in a different project.

pepijndevos avatar Jun 13 '18 17:06 pepijndevos

It does seem that some of higher level classes in motor could also belong in their own files...wheeledbot.py or something like that? What do others think?

dwalton76 avatar Oct 27 '18 00:10 dwalton76

@pepijndevos you should grab #347

dwalton76 avatar Oct 27 '18 00:10 dwalton76

I like the ideas here; we'd need to break it down into actionable features though (preferably in separate issues). The holonomic drive one is good.

WasabiFan avatar Oct 27 '18 19:10 WasabiFan

We have a “control” directory which contains some code that kinda falls into this high level category.

Seems like first steps would be to move the following out of motor.py

  • MoveTank
  • MoveJoystick
  • MoveDifferential (once it lands)

and into control/wheeledrobot.py? Not crazy about the filename since this code also works for tracked robots.

dwalton76 avatar Oct 27 '18 20:10 dwalton76

I am going to try to find some time to work on #235 that one also falls under this category

dwalton76 avatar Oct 27 '18 20:10 dwalton76

I'm not super excited about moving things around (because it's a breaking change) but that may be warranted here. If we do so, I'd suggest calling it ev3dev2.drive.

WasabiFan avatar Oct 27 '18 21:10 WasabiFan