new function to change wait time between each note, and glissendo function, to do glissendos
This commit is contained in:
parent
29a1a1bdf1
commit
1d8a928df5
19
README.md
19
README.md
|
|
@ -3,3 +3,22 @@
|
||||||
##requirements
|
##requirements
|
||||||
|
|
||||||
need a "libraries" folder in the parent folder, in which is located the Dynamixel-sdk library for C++, with the folder toolkit-dynamixel
|
need a "libraries" folder in the parent folder, in which is located the Dynamixel-sdk library for C++, with the folder toolkit-dynamixel
|
||||||
|
|
||||||
|
|
||||||
|
##usage
|
||||||
|
|
||||||
|
plug the poppy to the computer and power it
|
||||||
|
|
||||||
|
(compile the code if you need. You can use 'make' in Linux.)
|
||||||
|
|
||||||
|
After going to playing position, the poppy will disable its torque.
|
||||||
|
|
||||||
|
###First phase
|
||||||
|
|
||||||
|
You can then move it around and have it register 9 positions (from 0 to 8) by putting the id of the position and pressing enter.
|
||||||
|
it will then register its current position
|
||||||
|
|
||||||
|
when you are finished, enter 555 and press enter.
|
||||||
|
|
||||||
|
###Second phase
|
||||||
|
|
||||||
|
|
|
||||||
103
main.cpp
103
main.cpp
|
|
@ -21,6 +21,7 @@ int _targetJointTorqueGripper = 1140;
|
||||||
float _proportionnalIncrement = 0.025f;
|
float _proportionnalIncrement = 0.025f;
|
||||||
float _proportionnalIncrementAbove = 0.01f;
|
float _proportionnalIncrementAbove = 0.01f;
|
||||||
float _threshold= 1.9;
|
float _threshold= 1.9;
|
||||||
|
int waitTime = 0;
|
||||||
std::array<std::array<short unsigned int, 6>,9> notes_position = {{{511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}}};
|
std::array<std::array<short unsigned int, 6>,9> notes_position = {{{511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}, {511, 511, 511, 511, 511, 511}}};
|
||||||
//short unsigned int notes_position[54] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54};
|
//short unsigned int notes_position[54] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54};
|
||||||
std::array<short unsigned int, 6> playingPosition = {{511, 410, 515, 515, 685, 589}}; //511, 310, 485, 515, 665, 592
|
std::array<short unsigned int, 6> playingPosition = {{511, 410, 515, 515, 685, 589}}; //511, 310, 485, 515, 665, 592
|
||||||
|
|
@ -202,6 +203,7 @@ int closeGripper()
|
||||||
void playNote(int myNote)
|
void playNote(int myNote)
|
||||||
{
|
{
|
||||||
goToPlayingPosition();
|
goToPlayingPosition();
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
std::vector<uint16_t> l_vTargetJointPosition;
|
std::vector<uint16_t> l_vTargetJointPosition;
|
||||||
switch(myNote){
|
switch(myNote){
|
||||||
|
|
@ -269,16 +271,16 @@ void playNote(int myNote)
|
||||||
l_vTargetJointPosition.push_back(notes_position[8][4]);
|
l_vTargetJointPosition.push_back(notes_position[8][4]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
l_vTargetJointPosition.push_back(convertAnglesToJointCmd(25.0f));
|
l_vTargetJointPosition.push_back(playingPosition[0]);
|
||||||
l_vTargetJointPosition.push_back(convertAnglesToJointCmd(-55.0f));
|
l_vTargetJointPosition.push_back(playingPosition[1]);
|
||||||
l_vTargetJointPosition.push_back(convertAnglesToJointCmd(0.0f));
|
l_vTargetJointPosition.push_back(playingPosition[2]);
|
||||||
l_vTargetJointPosition.push_back(convertAnglesToJointCmd(0.0f));
|
l_vTargetJointPosition.push_back(playingPosition[3]);
|
||||||
l_vTargetJointPosition.push_back(convertAnglesToJointCmd(20.0f));
|
l_vTargetJointPosition.push_back(playingPosition[4]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
l_vTargetJointPosition.push_back(playingPosition[5]); //mettre pince à convertAnglesToJointCmd(38.0f) (à revérifier si ça ne change pas avec un poppy différent)
|
l_vTargetJointPosition.push_back(playingPosition[5]); //mettre pince à convertAnglesToJointCmd(38.0f) (à revérifier si ça ne change pas avec un poppy différent)
|
||||||
_oDxlHandler.sendTargetJointPosition(l_vTargetJointPosition);
|
_oDxlHandler.sendTargetJointPosition(l_vTargetJointPosition);
|
||||||
sleep(1); //time period in seconds
|
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); //time period in milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
void playMultipleNotes(std::string myMusic)
|
void playMultipleNotes(std::string myMusic)
|
||||||
|
|
@ -288,6 +290,79 @@ void playMultipleNotes(std::string myMusic)
|
||||||
std::cout<<c<<std::endl;
|
std::cout<<c<<std::endl;
|
||||||
playNote((c - '0')+1);
|
playNote((c - '0')+1);
|
||||||
}
|
}
|
||||||
|
goToPlayingPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
void changeWaitTime()
|
||||||
|
{
|
||||||
|
int myTime = 0;
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "write the wait Time between each note in milliseconds" << std::endl;
|
||||||
|
|
||||||
|
std::cin >> myTime;
|
||||||
|
waitTime = myTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void glissendo()
|
||||||
|
{
|
||||||
|
//good idea, but not working so much, might need to make a linear displacement instead of a joint one (but too much work for this project)
|
||||||
|
std::string upOrDown = "u";
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "Do you want a glissendo upwards or downwards ? u/d" << std::endl;
|
||||||
|
std::cin >> upOrDown;
|
||||||
|
|
||||||
|
if (upOrDown == "u" || upOrDown == "U")
|
||||||
|
{
|
||||||
|
std::vector<uint16_t> Target1JointPosition;
|
||||||
|
Target1JointPosition.push_back(notes_position[0][0]);
|
||||||
|
Target1JointPosition.push_back(notes_position[0][1]);
|
||||||
|
Target1JointPosition.push_back(notes_position[0][2]);
|
||||||
|
Target1JointPosition.push_back(notes_position[0][3]);
|
||||||
|
Target1JointPosition.push_back(notes_position[0][4]);
|
||||||
|
Target1JointPosition.push_back(playingPosition[5]);
|
||||||
|
|
||||||
|
_oDxlHandler.sendTargetJointPosition(Target1JointPosition);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
||||||
|
|
||||||
|
std::vector<uint16_t> Target2JointPosition;
|
||||||
|
Target2JointPosition.push_back(notes_position[5][0]);
|
||||||
|
Target2JointPosition.push_back(notes_position[5][1]);
|
||||||
|
Target2JointPosition.push_back(notes_position[5][2]);
|
||||||
|
Target2JointPosition.push_back(notes_position[5][3]);
|
||||||
|
Target2JointPosition.push_back(notes_position[5][4]);
|
||||||
|
Target2JointPosition.push_back(playingPosition[5]);
|
||||||
|
|
||||||
|
_oDxlHandler.sendTargetJointPosition(Target2JointPosition);
|
||||||
|
}
|
||||||
|
else if (upOrDown == "d" || upOrDown == "D")
|
||||||
|
{
|
||||||
|
std::vector<uint16_t> Target1JointPosition;
|
||||||
|
Target1JointPosition.push_back(notes_position[5][0]);
|
||||||
|
Target1JointPosition.push_back(notes_position[5][1]);
|
||||||
|
Target1JointPosition.push_back(notes_position[5][2]);
|
||||||
|
Target1JointPosition.push_back(notes_position[5][3]);
|
||||||
|
Target1JointPosition.push_back(notes_position[5][4]);
|
||||||
|
Target1JointPosition.push_back(playingPosition[5]);
|
||||||
|
|
||||||
|
_oDxlHandler.sendTargetJointPosition(Target1JointPosition);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
||||||
|
|
||||||
|
std::vector<uint16_t> Target2JointPosition;
|
||||||
|
Target2JointPosition.push_back(notes_position[0][0]);
|
||||||
|
Target2JointPosition.push_back(notes_position[0][1]);
|
||||||
|
Target2JointPosition.push_back(notes_position[0][2]);
|
||||||
|
Target2JointPosition.push_back(notes_position[0][3]);
|
||||||
|
Target2JointPosition.push_back(notes_position[0][4]);
|
||||||
|
Target2JointPosition.push_back(playingPosition[5]);
|
||||||
|
|
||||||
|
_oDxlHandler.sendTargetJointPosition(Target2JointPosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "write only u for upwards, or d for downards" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
@ -346,6 +421,22 @@ int main()
|
||||||
std::cout<<"Write 'stop' to stop"<<std::endl;
|
std::cout<<"Write 'stop' to stop"<<std::endl;
|
||||||
std::cin >> myMusic;
|
std::cin >> myMusic;
|
||||||
}
|
}
|
||||||
|
else if (myMusic == "wait")
|
||||||
|
{
|
||||||
|
changeWaitTime();
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout<<"Write the notes you want to play (from 0 to 8), without spaces between them"<<std::endl;
|
||||||
|
std::cout<<"Write 'stop' to stop"<<std::endl;
|
||||||
|
std::cin >> myMusic;
|
||||||
|
}
|
||||||
|
else if (myMusic == "glissendo")
|
||||||
|
{
|
||||||
|
glissendo();
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout<<"Write the notes you want to play (from 0 to 8), without spaces between them"<<std::endl;
|
||||||
|
std::cout<<"Write 'stop' to stop"<<std::endl;
|
||||||
|
std::cin >> myMusic;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playMultipleNotes(myMusic);
|
playMultipleNotes(myMusic);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue