Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of AX-12A by
Revision 4:f2da3b1d9988, committed 2015-12-17
- 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();
