Dynamixel servo controller. This program consists of 2 parts: "dynamixel_servo_controller.cpp/.h" and "main.cpp"( demo program ).
Fork of dynamixel_servo_controller by
main.cpp@2:92f3aa5245dc, 2018-06-13 (annotated)
- Committer:
- PicYusuke
- Date:
- Wed Jun 13 08:31:51 2018 +0000
- Revision:
- 2:92f3aa5245dc
- Parent:
- 1:2c82c636c43e
Separated into 3 files.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PicYusuke | 1:2c82c636c43e | 1 | /* |
PicYusuke | 1:2c82c636c43e | 2 | * Copyright (c) 2018 Yusuke Okino |
PicYusuke | 1:2c82c636c43e | 3 | |
PicYusuke | 1:2c82c636c43e | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
PicYusuke | 1:2c82c636c43e | 5 | * of this software and associated documentation files (the "Software"), to deal |
PicYusuke | 1:2c82c636c43e | 6 | * in the Software without restriction, including without limitation the rights |
PicYusuke | 1:2c82c636c43e | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
PicYusuke | 1:2c82c636c43e | 8 | * copies of the Software, and to permit persons to whom the Software is |
PicYusuke | 1:2c82c636c43e | 9 | * furnished to do so, subject to the following conditions: |
PicYusuke | 1:2c82c636c43e | 10 | |
PicYusuke | 1:2c82c636c43e | 11 | * The above copyright notice and this permission notice shall be included in all |
PicYusuke | 1:2c82c636c43e | 12 | * copies or substantial portions of the Software. |
PicYusuke | 1:2c82c636c43e | 13 | |
PicYusuke | 1:2c82c636c43e | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
PicYusuke | 1:2c82c636c43e | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
PicYusuke | 1:2c82c636c43e | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
PicYusuke | 1:2c82c636c43e | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
PicYusuke | 1:2c82c636c43e | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
PicYusuke | 1:2c82c636c43e | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
PicYusuke | 1:2c82c636c43e | 20 | * SOFTWARE. |
PicYusuke | 0:c9df5db1b525 | 21 | */ |
PicYusuke | 0:c9df5db1b525 | 22 | |
PicYusuke | 2:92f3aa5245dc | 23 | #include "dynamixel_servo_controller.h" |
PicYusuke | 0:c9df5db1b525 | 24 | |
PicYusuke | 0:c9df5db1b525 | 25 | int main() |
PicYusuke | 0:c9df5db1b525 | 26 | { |
PicYusuke | 0:c9df5db1b525 | 27 | const uint8_t servo_id = 0x01; |
PicYusuke | 2:92f3aa5245dc | 28 | |
PicYusuke | 1:2c82c636c43e | 29 | dynamixel_servo_v2::XM430 xm430(PA_9, PA_10); |
PicYusuke | 1:2c82c636c43e | 30 | |
PicYusuke | 1:2c82c636c43e | 31 | xm430.Torque_ON(servo_id); |
PicYusuke | 2:92f3aa5245dc | 32 | |
PicYusuke | 1:2c82c636c43e | 33 | // 少し待つ処理が必要( サーボからの返答を受信する処理を入れたら不要になる ) |
PicYusuke | 1:2c82c636c43e | 34 | #ifdef MBED_ENVIRONMENT |
PicYusuke | 1:2c82c636c43e | 35 | wait(0.1); |
PicYusuke | 1:2c82c636c43e | 36 | #endif |
PicYusuke | 0:c9df5db1b525 | 37 | |
PicYusuke | 0:c9df5db1b525 | 38 | xm430.Set_Pos(servo_id, 999); |
PicYusuke | 1:2c82c636c43e | 39 | |
PicYusuke | 1:2c82c636c43e | 40 | |
PicYusuke | 1:2c82c636c43e | 41 | #ifdef MBED_ENVIRONMENT |
PicYusuke | 1:2c82c636c43e | 42 | while(1) |
PicYusuke | 1:2c82c636c43e | 43 | { |
PicYusuke | 1:2c82c636c43e | 44 | |
PicYusuke | 1:2c82c636c43e | 45 | } |
PicYusuke | 1:2c82c636c43e | 46 | #endif |
PicYusuke | 0:c9df5db1b525 | 47 | |
PicYusuke | 0:c9df5db1b525 | 48 | return 0; |
PicYusuke | 1:2c82c636c43e | 49 | } |
PicYusuke | 1:2c82c636c43e | 50 | |
PicYusuke | 1:2c82c636c43e | 51 |