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.
Dependencies: mbed ODriveLibTest
Revision 1:8e3e04f1a7f0, committed 2019-09-13
- Comitter:
- m204517
- Date:
- Fri Sep 13 05:50:03 2019 +0000
- Parent:
- 0:763fa4531dbb
- Commit message:
- modification
Changed in this revision
| ODriveLibTest.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ODriveLibTest.lib Fri Sep 13 05:07:44 2019 +0000 +++ b/ODriveLibTest.lib Fri Sep 13 05:50:03 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/m204517/code/ODriveLibTest/#c191cf9bf1a3 +https://os.mbed.com/users/m204517/code/ODriveLibTest/#dc0c02b4a1b0
--- a/main.cpp Fri Sep 13 05:07:44 2019 +0000
+++ b/main.cpp Fri Sep 13 05:50:03 2019 +0000
@@ -1,18 +1,6 @@
#include "mbed.h"
#include "ODriveLibTest.h"
-// Printing with stream operator
-/*template<class T> inline Stream& operator <<(Stream &obj, T arg)
-{
- obj.printf(arg);
- return obj;
-}
-template<> inline Stream& operator <<(Stream &obj, float arg)
-{
- obj.printf(arg, 4);
- return obj;
-}*/
-
// Serial to the ODrive
Serial odrive_serial(p9, p10); //TX (ODrive RX), RX (ODrive TX)
Serial PC(USBTX, USBRX); //
@@ -26,9 +14,6 @@
// ODrive uses 115200 baud
odrive_serial.baud(115200);
- // ODrive object
- //ODriveArduino odrive(odrive_serial);
-
// Serial to PC
PC.baud(115200);
while (!PC) ; // wait for Arduino Serial Monitor to open
@@ -37,50 +22,16 @@
PC.printf("Setting parameters...");
odrive.SetLimit(0, 22000.0f, 50.0f);
- wait_ms(100);
odrive.SetLimit(1, 22000.0f, 50.0f);
- wait_ms(100);
odrive.ODriveInit(0);
- wait_ms(100);
odrive.ODriveInit(1);
- wait_ms(100);
- // In this example we set the same parameters to both motors.
- // You can of course set them different if you want.
- // See the documentation or play around in odrivetool to see the available parameters
- /*for (int axis = 0; axis < 2; ++axis) {
- odrive_serial << "w axis" << axis << ".controller.config.vel_limit " << 22000.0f << '\n';
- odrive_serial << "w axis" << axis << ".motor.config.current_lim " << 11.0f << '\n';
- // This ends up writing something like "w axis0.motor.config.current_lim 10.0\n"
- }*/
-
- //delay(100);
-
- // is_readyをTrueに
- //odrive_serial << "w axis0.encoder.is_ready " << 1 << '\n';
- //delay(50);
- //int requested_state = ODriveArduino::AXIS_STATE_ENCODER_INDEX_SEARCH;
- //Serial << "Axis0: Requesting state " << requested_state << '\n';
- //odrive.run_state(0, requested_state, true);
-
- //int requested_state = ODriveArduino::AXIS_STATE_CLOSED_LOOP_CONTROL;
- //Serial << "Axis0: Requesting state " << requested_state << '\n';
- //odrive.run_state(0, requested_state, false); // don't wait
- //delay(50);
-
+
PC.printf("Ready!");
- // Serial.println("Send the character '0' or '1' to calibrate respective motor (you must do this before you can command movement)");
- // Serial.println("Send the character 's' to exectue test move");
- // Serial.println("Send the character 'b' to read bus voltage");
- // Serial.println("Send the character 'p' to read motor positions in a 10s loop");
- //odrive_serial << "w axis0.controller.vel_setpoint " << 12000 << '\n';
while(1) {
if (PC.readable()) {
char c = PC.getc();
- //int velNum = c - '0';
-
- //odrive_serial << "w axis0.controller.vel_setpoint " << 12000 << '\n';
- //Serial.println(velNum);
+
if( c == 'm' ) {
odrive.SetVelocity(0, 12000);
odrive.SetVelocity(1, 12000);