#how to include a new motor function in custom base

1 messages · Page 1 of 1 (latest)

abstract raptor
#

@restive aurora following on from the remote base issue, and again moving to the appropriate place.

General idea of changing the code like this:

  • can drive the motors with speed instead of power or speed & distance. (then my robot will hopefully drive straight!)
  • avoid passing a 0 distance to a command that needs a distance

I've added a SetVelocity function to my roboclaw driver, and I've made my own base, where I've changed the SetVelocity function to use the motor SetVelocity instead of runAll. I get this error: diff_base/diff_base.go:221:33: m.SetVelocity undefined (type motor.Motor has no field or method SetVelocity) . How do I add a new method to motor so base can see it?

err = multierr.Combine(err, m.SetVelocity(ctx, rRPM, extra)) - the line in question from my base component

and my components:

base: https://gist.github.com/ryanpennings/eee93bb5f4a56621a5472e7567817315
roboclaw: https://gist.github.com/ryanpennings/69651e8dd7a0bb1556f888936d1f4013

restive aurora
#

I might need to talk to a couple colleagues to see how we can support this.

turbid cobalt
#

hi @abstract raptor that's a cool implementation of roboclaw you've got there - one suggestion I have that might unblock you:

  • keep the base driver as is, since the apis only expose the functions avaiable in the motor API, which are SetPower GoFor GoTo IsPowered etc. SetVelocity is a base api, and as Shawn mentioned not found on motors. having a runAll function also allows the motors to start simultaneously, and is a better guard against latency introduced by grpc calls.
  • use your implementation of SetVelocty in GoFor. What I would do is pass in an extra parameter that is a boolean to motor.GoFor that makes it run your SetVelocity logic in the case it is true, and run the basic implementation of GoFor in the case it is false. Since both functions are in the same module, you don't have to worry about calling the motor SetVelocity function from outside the motor package.
  • You can then edit runAll to take the extra parameter and pass it to the motor GoFor .