PSL_2021 / servomotor_MX12_Lorenzo

Dependents:   PSL_ROBOT_lorenzo robot_lorenzo recepteur_mbed_os_6

Revision:
24:2ab26ed08c83
Parent:
16:8fcf79e02dd4
Child:
25:bc51575e3304
--- a/MX12.h	Sun Nov 07 11:35:16 2021 +0000
+++ b/MX12.h	Sat Nov 13 10:12:09 2021 +0100
@@ -12,6 +12,14 @@
 #define MX12_PACKET_MAX_SIZE 32
 #define MX12_MAX_MOTOR_COUNT 16
 
+#define MX12_SPEED_QUANTA_RPM 0.916 /* Data from MX12 e-manual */
+#define MX12_ABSOLUTE_MAX_SPEED_RAD_S 98.1
+/* BOT_SERVO_SPEED_QUANTA_RAD_PER_SEC = BOT_SERVO_SPEED_QUANTA_RPM*2pi / 60s */
+#define BOT_SERVO_SPEED_QUANTA_RAD_PER_SEC 0.0959
+/* SERVO_FULL_SCALE_SPEED_RAD_PER_SEC = BOT_SERVO_SPEED_QUANTA_RAD_PER_SEC*1024 */
+#define SERVO_FULL_SCALE_SPEED_RAD_PER_SEC 98.13
+
+
 /* Dynamixel protocol v1.0 : Instructions
  ******************************************/
 #define PROTOCOL_INSTRUCTION_PING          0x01
@@ -174,7 +182,7 @@
      *  of the master-slave protocol of the communication between  
      *  the robot controller (master) and the servomotors (slaves).
      */
-     enum SerialState {
+    enum SerialState {
         Writing, /**< Robot controller send an "instruction packet"
                       (request) to a servomotor */
         Reading, /**< Robot controller receive a "status packet" from a 
@@ -243,7 +251,7 @@
      */
     MX12(PinName tx, PinName rx, int baud=115200);
     
-    /** Send desired speed to a specific servomotor
+    /** Send desired normalized speed to a specific servomotor
      *
      * @param mot_id a unique value in the daisy chain network to identify
      *               each servomotor
@@ -252,6 +260,14 @@
      */
     void SetSpeed(unsigned char mot_id, float speed);
     
+    /** Send desired ablosute speed to a specific servomotor
+     *
+     * @param mot_id a unique value in the daisy chain network to identify
+     *               each servomotor
+     * @param speed desired speed in radians per second  
+     */
+    void SetSpeed_rad_s(unsigned char mot_id, float speed);
+    
     /** Informs about the availability of the bus for a new transmission 
      *  of instruction packet (Method Access Control) 
      *