Hello everybody,
For my bachelor degree thesis I’m building a 6 DOF robotic arm, similar to a Tinkerkit Braccio.
As an aerospace engineering student I’m not an expert coder but I have some experience with Arduino. Writing all the code is not the scope of the thesis.
Since the end-effector of the arm has to follow a G-Coded pattern so I found on GitHub a library that reads the code sent via serial from the PC and decode it.
The lib is available here: GitHub - cgxeiji/CGx-Gcode-RobotArm: Gcode decoder for Arduino for robotic arms. Works together with InverseK (https://github.com/cgxeiji/CGx-InverseK) library.
I then downloaded another lib from the same author that does the inverse kinematic of the arm: GitHub - cgxeiji/CGx-InverseK: Inverse Kinematic Library for Arduino for a three link-arm system with a rotating base.
In the “stock” version the servos are moved via Adafruit PWM servo driver but apparently there is the possibility to drive them attached directly to the board, by modifying the code in the example.
Adafruit PWM Servo Driver lib: GitHub - adafruit/Adafruit-PWM-Servo-Driver-Library: Adafruit PWM Servo Driver Library
The problem I found is that the example code is correctly compiled and uploaded to the Arduino Uno board but then nothing happens.
I tried to add some “troubleshooting lines” of the example code by adding a Serial.println(“I’m ready”)to both the setup and loop function, nothing appeared on screen.
I then added a LED to pin 12 and tried to turn it on and off both in setup and loop but nothing ever happened so I’m supposing something is going wrong and the setup doesn’t even start since it won’t turn on the LED even if that’s the first instruction of the setup function.
I’m not able to fully understand what exactly, step-by-step, happens in those libraries since they are a bit too difficult for me but I get the general meaning of every subroutine.
I also have to make note of several gcc errors while compiling the modified “troubleshooting” example code. That’s weird since the same code compiled after a reboot of my pc.
If anybody has any idea of what the problem might be or more methods to troubleshoot, please answer.
Thank you for your time.
EDIT3: I just found out that any sketch, even Blink, will stop working whenever CGx_GCode.h is included. Any idea why is that?
EDIT1:
At the moment there is no hardware connected to the board. May this be the problem?
I also forgot to post the “troubleshooting” example code with the LED. The “serial” troubleshooting" give no result either.
// Enable this definition if you don't have an Adafruit 16-Channel Servo Driver connected to the Arduino/Teensy
//#define CGX_GCODE_DEBUG
#include <InverseK.h>
#include <CGx_Gcode.h>
#define pin 12
void setup() {
pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH);
delay(500);
Link base, upperarm, forearm, hand;
// Braccio Robotic Arm
base.init(0, b2a(0.0), b2a(180.0));
upperarm.init(125, b2a(15.0), b2a(165.0));
forearm.init(125, b2a(0.0), b2a(180.0));
hand.init(190, b2a(0.0), b2a(180.0));
// Black Servo Robotic Arm
//base.init(75, b2a(0.0), b2a(180.0));
//upperarm.init(105, b2a(15.0), b2a(165.0));
//forearm.init(100, b2a(0.0), b2a(180.0));
//hand.init(185, b2a(0.0), b2a(180.0));
// Attach the links to the inverse kinematic model
InverseK.attach(base, upperarm, forearm, hand);
Serial.begin(115200);
// Initialize the arm with the upright position
Gcode.decode("M105");
}
float b2a(float b){ //braccio to angle in radians
return b / 180.0 * PI - HALF_PI;
}
void loop() {
// This is all the code necessary at the loop to control the robotic arm using Gcode
digitalWrite(pin, LOW);
if (Serial.available()) {
String s = Serial.readStringUntil('\n');
Gcode.decode(s);
}
Gcode.update();
}
EDIT2:
I tryied to comment all the lines in the example above except the #include lib and the troubleshooting lines. I then tryied to upload the same ‘active’ code in another sketch and it worked. I may suppose, than, that the problem is in the libraries, installed in the IDE by adding the provided .zip file from github.