I would like to write a program that makes the Arduino Bracchio draw simple forms.
However, the obligatory begin() method at the beginning of each sketch always threatens my Bracchio to get entangled with the cables of its servo motors.
That is why I am looking for a way to bypass the begin() method, or at least for a way to bypass the initial taking up of the so-called safety position. The commentary mentions that
// Initialization functions and set up the initial position for Braccio
// All the servo motors will be positioned in the "safety" position:
// Base (M1):90 degrees
// Shoulder (M2): 45 degrees
// Elbow (M3): 180 degrees
// Wrist vertical (M4): 180 degrees
// Wrist rotation (M5): 90 degrees
// Gripper (M6): 10 degrees
And this is executed so abruptly in the beginning that by now the gripper arm has got entangled so many times that some of the screw joints have worn out so much that they do no longer maintain stability of the whole Bracchio, and probably need to get replaced.
For the sake of the safety of my arm, I would strongly prefer to avoid this "safety position".
How can I avoid it?
Sounds plausible! Where exactly can I access the source code of the begin() method?
I took a look into the libraries folder and searched for "begin", without results.
Open one of the library's example codes in the Arduino IDE. Select 'Sketch --> Show Sketch Folder' from the tool bar. Navigate up two directory levels. You should now be in the library's main directory. Its source code will either be there or down one level in the 'src' directory.
Thank you, I guess I have found what I am looking for in a file called Braccio.ccp.
There I see this code:
#include "Braccio.h"
extern Servo base;
extern Servo shoulder;
extern Servo elbow;
extern Servo wrist_rot;
extern Servo wrist_ver;
extern Servo gripper;
extern int step_base = 0;
extern int step_shoulder = 45;
extern int step_elbow = 180;
extern int step_wrist_rot = 180;
extern int step_wrist_ver = 90;
extern int step_gripper = 10;
_Braccio Braccio;
//Initialize Braccio object
_Braccio::_Braccio() {
}
/**
* Braccio initialization and set intial position
* Modifing this function you can set up the initial position of all the
* servo motors of Braccio
* @param soft_start_level: default value is 0 (SOFT_START_DEFAULT)
* You should set begin(SOFT_START_DISABLED) if you are using the Arm Robot shield V1.6
* SOFT_START_DISABLED disable the Braccio movements
*/
unsigned int _Braccio::begin(int soft_start_level) {
//Calling Braccio.begin(SOFT_START_DISABLED) the Softstart is disabled and you can use the pin 12
if(soft_start_level!=SOFT_START_DISABLED){
pinMode(SOFT_START_CONTROL_PIN,OUTPUT);
digitalWrite(SOFT_START_CONTROL_PIN,LOW);
}
// initialization pin Servo motors
base.attach(11);
shoulder.attach(10);
elbow.attach(9);
wrist_rot.attach(6);
wrist_ver.attach(5);
gripper.attach(3);
//For each step motor this set up the initial degree
base.write(0);
shoulder.write(40);
elbow.write(180);
wrist_ver.write(170);
wrist_rot.write(0);
gripper.write(73);
//Previous step motor position
step_base = 0;
step_shoulder = 40;
step_elbow = 180;
step_wrist_ver = 170;
step_wrist_rot = 0;
step_gripper = 73;
if(soft_start_level!=SOFT_START_DISABLED)
_softStart(soft_start_level);
return 1;
}
Now I guess I just need to understand the code and rewrite it accordingly.
Great, thanks for your help!
PS:
It probably comes down to these two sections:
extern int step_base = 0;
extern int step_shoulder = 45;
extern int step_elbow = 180;
extern int step_wrist_rot = 180;
extern int step_wrist_ver = 90;
extern int step_gripper = 10;
Alright I have just redefined the degree values in both of these instances and that seems to have solved the issue. So this danger seems to be averted now. Thanks for the help!