resibots / libdynamixel

C++ interface to the dynamixel actuators
GNU General Public License v2.0
9 stars 15 forks source link

[Feature Request] Set PID gains from command line #46

Open naoki-mizuno opened 6 years ago

naoki-mizuno commented 6 years ago

It would be nice to be able to set the PID parameters from the command line utilities i.e. dynamixel and p2-dynamixel. Example usage:

$ p2-dynamixel set-gain-pos-p --id 1 80
$ p2-dynamixel set-gain-vel-i --id 2 20
$ p2-dynamixel st-gain-pos-i --id 3 30
Error: ProH54200S500 does not support setting the Position I gain

Currently, we can get/set the gains using:

# Read position P gain for ProH54200S500
$ p2-dynamixel read --id 1 2 3 -a 594 -s 2 --timeout 0.3
# Write
$ p2-dynamixel write --id 1 2 3 -a 594 -s 2 -v 80 --timeout 0.3 

but it'd be nice to have a command for that.

Dynamixel Pro addresses:

Name Address
Pos P 594
Vel P 588
Vel I 586

MX-106 (and probably MX Series Protocol 2):

Name Address
Pos P 84
Pos I 82
Pos D 80
Vel P 78
Vel I 76
naoki-mizuno commented 6 years ago

It would be even nicer if we could set this in dynamixel_control_hw's YAML file. Maybe like:

dynamixel_control_hw:
  serial_interface: /dev/ttyUSB0
  baudrate: 57600
  # ...
  servos:
    first:
      id: 1
      gains:
        pos:
          p: 30
          i: 10
          d: 0
        vel:
          p: 40
dogoepp commented 6 years ago

You're right, it would be nice to add these fields in the command line utility, as well as (most of) the others. I'm thinking on possible angles to add all these fields at once. If you have ideas, it's welcome.

However, I'm not sure about about integrating it in dynamixel_control_hw. It seems to me to not be the right tool to configure the actuators. One reason is that we wouldn't check if the configuration went well. Also, we would be writing this EEPROM at every startup, which is useless and a (limited but useless) wear of the EEPROM.

Nonetheless, I'm open to discussion and I agree that the current way to configure the servos is not really satisfying. Maybe we could do a configuration tool using ROS ? It could also understand YAML configuration, should you want it.

Besides, have you already tried Dynamixel Workbench?

naoki-mizuno commented 6 years ago

I'm thinking on possible angles to add all these fields at once

I'm not too sure about adding all the fields to the command line utility. I would say it may clutter the subcommands help message too much, and I think just the ones that will be used frequently should be added (maybe min/max voltage limits, homing offset, and other limiting fields).

we would be writing this EEPROM at every startup

IIRC, the PID gains are stored in the RAM so it gets reset every time. I'm not sure what the rationale behind this is, but I believe being able to set the gains to appropriate values every time ros_control is brought up reduces the amount of task for the users. Just out of curiosity, how do you guys set the PID gains for your application?

Besides, have you already tried Dynamixel Workbench?

Last time I checked, they didn't have a ros_control interface, so I ended up not using it. I needed ros_control because I wanted my programs to work both on Gazebo and the actual manipulator.

dogoepp commented 6 years ago

Adding fields

The fields you use regularly depends on your usage of the actuators. I personally use the mode switch rather regularly, but almost never the other fields. Therefore, any choice of which parameters to support would be arbitrary. I don't mind adding a few field, but doing so I might go the extra step to support most, if not all, parameters.

Anyway, I'm a bit busy with other things right now. It would need to wait for some time.

Setting PID parameters

I had forgotten that the PID parameters are set in the RAM. You're right. This topic should be tracked in an other issue at dynamixel_control_hw.

Dynamixel Workbench

It seems to still lack this interface. I just saw it yesterday and thought that their dynamixel configuration soft seemed cool so I was curious to know if you had tried. Doesn't solve your issue, sorry.