Exadler / DMCC_Library

Code library for the beaglebone DMCC (Dual Motor Controller Cape)
4 stars 10 forks source link

Python Interface Questions #2

Closed dfarrell07 closed 10 years ago

dfarrell07 commented 10 years ago

Hello!

First, this looks like an awesome project! The university robotics team I lead is considering buying three of your boards for our current robot, but we have some questions about the Python interface (our codebase is in Python). Basically, are these aspects of my understanding of the codebase correct?

Do I understand the code correctly in these regards, or did I miss something?

On a related note, is there a timeline for the development of the Python interface?

Thanks again for your work on this awesome project! I hope we can work together to help it mature, both for the sake of our robot and for the development of this seemingly much-needed project.

paulctan commented 10 years ago

Thanks for the kind words!!

On your points:

  1. Yes, currently only setMotor is exposed in Python. However, you can change direction of the motors by simply giving setMotor a negative number (positive numbers move it forward, negative numbers reverses the polarity).
  2. The other methods will be exposed shortly.
  3. If you use setMotor, it overrides the PID control and allows you to control the power of the motor. In order to use it in PID mode (yeah, the code comments need to be cleaned up a bit), just call setTargetVel (for velocity PID mode), or setTargetPos ( for position PID ). Basically, each motor can operate in either Power control (setMotor), Position PID (setTargetPos), or Velocity PID (setTargetVel). Calling one of these functions changes the mode (only one mode can be active per motor at any given time). I'll see if I can get some of the comments in the code cleaned up.

So, yes, you basically understand the code, except for the confusion on the PID modes.

As far as the timeline for the Python interface, I got sidetracked on working on the PRU (Programmable Realtime Unit) code on the Beaglebone in order to read the iGaging DRO scales to CNC convert my manual lathe (see my blog at http://exadler.blogspot.com/). The PRU seems to be needed because of random delays in Angstrom Linux that stretches out the pulse every so often (I was seeing it about 4% of the time). However, if you need the Python interface now, I can get back to finishing up the rest of the methods in the next week or so.

I'm glad you are thinking of using it for a robotics project, as that's what I had originally intending this board to be used for, and I would love to see pictures of your robot in action!

dfarrell07 commented 10 years ago

However, you can change direction of the motors by simply giving setMotor a negative number (positive numbers move it forward, negative numbers reverses the polarity).

Okay, very good to know!

In order to use it in PID mode (yeah, the code comments need to be cleaned up a bit), just call setTargetVel (for velocity PID mode)

Okay, so replacing setMotorPower(session, nMotor, nPower); with setTargetVel(desired_vel, motor_num) in DMCC-py.c (and updating associated code to get desired_vel instead of nPower, of course) would result in setting motor_num motor to run at desired_vel, which it would maintain using the PID logic? How would you change the direction while using setTargetVel (since the velocity param is unsigned)? Add logic in setMotor that calls configMotorDir with the desired direction?

As far as the timeline for the Python interface, I got sidetracked on working on the PRU (Programmable Realtime Unit) code on the Beaglebone in order to read the iGaging DRO scales to CNC convert my manual lathe (see my blog at http://exadler.blogspot.com/).

Yeah, I saw that on your blog. We have some people working on the PRUs as well, for use with our ultrasonic sensors. We're pretty early into that work, but I'd be happy to share our codebase with you, especially once we have something useful in that domain. It's open source, but a private GitHub repo for now.

However, if you need the Python interface now, I can get back to finishing up the rest of the methods in the next week or so.

That would be awesome, if you don't mind. We'll be glad to help with development as much as we can, but we're pressed for developer bandwidth, so your support is invaluable.

I'm glad you are thinking of using it for a robotics project, as that's what I had originally intending this board to be used for, and I would love to see pictures of your robot in action!

We'll share some with you ASAP. :)

paulctan commented 10 years ago

Yes, just exposing setTargetVel will result in setting motor_num motor to run at desired_vel using PID logic, and yes, you did find a bug in the code. desired_vel should be a signed int!! We'll get that fixed and tested asap.

dfarrell07 commented 10 years ago

Yes, just exposing setTargetVel will result in setting motor_num motor to run at desired_vel using PID logic

Great! That's all of the questions I have for now. Thank you so much for your awesome, very fast support! I can't commit before I hear back from the rest of the team, but my doubts about whether this is the board for our project have been assuaged.

you did find a bug in the code. desired_vel should be a signed int!! We'll get that fixed and tested asap.

Glad I could help. :)

R00ney commented 10 years ago

I would like to second the thanks for awesome, fast support!