Telesensorics / AX-12A

Dependents:   RobotArmDemo

Fork of AX-12A by robot arm demo team

Files at this revision

API Documentation at this revision

Comitter:
jepickett
Date:
Thu Dec 17 00:09:38 2015 +0000
Parent:
1:d7642b2e155d
Child:
5:bae6dc62dfb4
Commit message:
added SetId

Changed in this revision

AX12.cpp Show annotated file Show diff for this revision Revisions of this file
AX12.h Show annotated file Show diff for this revision Revisions of this file
--- a/AX12.cpp	Tue Dec 15 04:37:54 2015 +0000
+++ b/AX12.cpp	Thu Dec 17 00:09:38 2015 +0000
@@ -18,6 +18,21 @@
 
 /*****/
 
+StatusCode AX12::SetServoId(char newId)
+{
+    int offset = ctID;
+    CommBuffer data;
+    data.push_back( newId );
+    StatusCode s = _pbus->Write(_ID, offset, data); 
+    if( s == statusValid )
+    {
+        _ID = newId;
+    }
+    return s;
+}
+
+/*****/
+
 StatusCode AX12::SetGoal(float degrees)
 {
     short goal = (short)((1024.0f * degrees) / 300.0f);
@@ -105,3 +120,4 @@
     int offset = ctTorqueEnable;
     return _pbus->Write(_ID, offset, data); 
 }
+
--- a/AX12.h	Tue Dec 15 04:37:54 2015 +0000
+++ b/AX12.h	Thu Dec 17 00:09:38 2015 +0000
@@ -83,6 +83,9 @@
 public:
     AX12(DynamixelBus* pbus, ServoId = 1);
 
+    // sets the servo ID
+    StatusCode SetServoId(char newId);
+
     // returns the status of the servo (connected/not connected + errors)
     StatusCode Ping();