You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ## DynamixelClient for XL motors
  2. This node is a client for the Dynamixel motors. It is based on the Dynamixel SDK and is used to control the motors. It
  3. is a Python node that communicates with the motors via the USB port.
  4. ## YAML Configuration
  5. ````YAML
  6. nodes:
  7. - id: dynamixel_client
  8. path: client.py # modify this to the relative path from the graph file to the client script
  9. inputs:
  10. pull_position: dora/timer/millis/10 # pull the present position every 10ms
  11. pull_velocity: dora/timer/millis/10 # pull the present velocity every 10ms
  12. pull_current: dora/timer/millis/10 # pull the present current every 10ms
  13. # write_goal_position: some goal position from other node
  14. # write_goal_current: some goal current from other node
  15. # end: some end signal from other node
  16. outputs:
  17. - position # regarding 'pull_position' input, it will output the position every 10ms
  18. - velocity # regarding 'pull_velocity' input, it will output the velocity every 10ms
  19. - current # regarding 'pull_current' input, it will output the current every 10ms
  20. env:
  21. PORT: COM9 # e.g. /dev/ttyUSB0 or COM9
  22. CONFIG: config.json # the configuration file for the motors
  23. ````
  24. ## Arrow format
  25. ### Outputs
  26. Arrow **StructArray** with two fields, **joints** and **values**:
  27. ```Python
  28. import pyarrow as pa
  29. # Create a StructArray from a list of joints (py_list, numpy_array or pyarrow_array) and a list of values (py_list, numpy_array or pyarrow_array)
  30. arrow_struct = pa.StructArray.from_arrays(
  31. arrays=[joints, values],
  32. names=["joints", "values"]
  33. )
  34. # Send the StructArray to the dataflow
  35. node.send_output("output_name", arrow_struct, None)
  36. # Receive the StructArray from the dataflow
  37. event = node.next()
  38. arrow_struct = event["value"]
  39. joints = arrow_struct.field("joints") # PyArrow Array of Strings
  40. values = arrow_struct.field("values") # PyArrow Array of Int32/Uint32/Float32...
  41. ```
  42. ### Inputs
  43. Arrow **StructArray** with two fields, **joints** and **values**:
  44. ```Python
  45. import pyarrow as pa
  46. # Create a StructArray from a list of joints (py_list, numpy_array or pyarrow_array) and a list of values (py_list, numpy_array or pyarrow_array)
  47. arrow_struct = pa.StructArray.from_arrays(
  48. arrays=[joints, values],
  49. names=["joints", "values"]
  50. )
  51. # Send the StructArray to the dataflow
  52. node.send_output("output_name", arrow_struct, None)
  53. # Receive the StructArray from the dataflow
  54. event = node.next()
  55. arrow_struct = event["value"]
  56. joints = arrow_struct.field("joints") # PyArrow Array of Strings
  57. values = arrow_struct.field("values") # PyArrow Array of Int32/Uint32/Float32...
  58. ```
  59. **Note**: The zero-copy is available for numpy arrays (with no None values) and pyarrow arrays.
  60. ## Configuration
  61. The configuration file that should be passed to the node is a JSON file that contains the configuration for the motors:
  62. ```JSON
  63. {
  64. "shoulder_pan": {
  65. "id": 1,
  66. "model": "x_series",
  67. "torque": true,
  68. "P": 800,
  69. "I": 0,
  70. "D": 0,
  71. "goal_current": null
  72. }
  73. }
  74. ```
  75. The configuration file starts by the **joint** name of the servo. **id**: the id of the motor in the bus, **model**: the
  76. model of the motor, **torque**: whether the motor should be
  77. in torque mode or not (at the beginning), **P**: the proportional gain for position control mode, **I**: the integral
  78. gain for position control mode, **D**: the derivative gain for position control mode, **goal_current**: the goal current
  79. for the motor at the beginning, null if you don't want to set it.
  80. ## License
  81. This library is licensed under the [Apache License 2.0](../../LICENSE).