I have double checked my connections and power supply and
Iconcluded that I have done a mistake at installing the library
what I do to install it is download the repo at my home folder and then:
mkdir _build_
cd _build_
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/
( PUT it at usr/local to install system wide??)
then I type make install
is that sufficient to install the library in my ubuntu linux?
then I write a Main.cpp file
#include "RPMSerialInterface.h"
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
using namespace std;
int main( int argc, char** argv )
{
chrono::seconds sec(5);
// Create the interface
std::string error_msg;
const std::string & dev = "/dev/ttyACM0";
RPM::SerialInterface* serialInterface = RPM::SerialInterface::createSerialInterface( dev, 9600, &error_msg);
std::cout << error_msg;
std::cout << "Serial Communication Started!\n";
std::cout << serialInterface->isOpen()<<"\n";
if ( !serialInterface->isOpen() ){
std::cout << "Serial Communication Failed!\n";
return -1;}
// Set the value of channel 0 to 6000 quarter-of-microseconds (i.e. 1.5 milliseconds)
std::cout << "target point 1! \n";
serialInterface->setTargetCP( 0, 12000 );
std::cout << "target 1 Done! \n";
this_thread::sleep_for(sec);
std::cout << "target point 2! \n";
serialInterface->setTargetCP( 0, 15000 );
std::cout << "target 2 Done! \n";
// Delete the interface
std::cout << "Deleting Serial Interface! \n";
delete serialInterface;
return 0;
}
and compile it like:
g++ -std=c++11 -O3 Main.cpp -lRapaPololuMaestro -o out
I donāt know if this is the correct way to compile the C++ code but the compiler produces no errors.
Then I type ./out
the programme executes but the motors donāt move.
I checked that the hardware works (no burned motors power supply etcā¦) by executing MaestroControlCenter and then the motors move correctly through the graphical interfaceā¦
if someone could tell me what I am doing wrong and how to correctly install the library and how to compile it correctly I would be gratefull.
It sounds like the Maestroās serial mode setting is not configured properly, since the RapaPololuMaestro library uses the Maestroās serial interface to communicate with it. By default, the Maestroās serial mode is set to āUART, detect baud rateā. In that mode, the Maestro will not listen to commands from the USB virtual COM port. You would need to set the Maestroās serial mode to USB Dual Port if you want to send serial commands to the Maestroās Command Port.
Thanks for the feedback. Yes initially when I tried the control center It didnāt work either. Then I marked the option in the serial settings tab and everything workedā¦
But how do I change the mode in c++?
Do I have to change something on my computer(configure a file? ) or I can pass an argument at the serialinterface CONSTRUCTOR?
Thanks in advance
Thanos
Hi
I dont know if I can set the serial setting by the Maestro control center.
I chose the Serial setting tab and then enabled the āUSB Dual Portā then I pushed the button āapply settingsā
I also enabled the channel 0 from status tabā¦
but still when I execute my code nothing happens. and the enabled motors get disabled during the execution of my programā¦
Also the documentation doesnt really help meā¦ I dont understand what should I do in order to "configure " the maestro before the first use. should I do something so that channels stay enabled for ever and the serial is at dual for ever? and if so how?
Clicking on the āApply Settingsā button in the Maestro Control Center will save the new serial mode setting on the Maestroās EEPROM, and each time the Maestro is reset or power cycled, it will reapply that setting.
I looked at your code in your first post and noticed that you are sending position values 12000 and 15000 to the servo channel 0. The Maestroās native units are in quarter-microseconds and it is configured to output a standard pulse width range of 1ms to 2ms (or 4000 quarter-microseconds to 8000 quarter-microseconds) by default. By the way, 90 degrees is the standard range of motion for a servo given 1ms to 2ms pulses. Have you tried running the RapaPololuMaestroSimpleTest example under the āsamplesā folder on its GitHub page? In your code, try changing 12000 and 15000 to something like 4000 and 6000 and let us know the outcome.
If you did not see any movement from your servos, then the RapaPololuMaestroSimpleTest example probably did not run successfully. It looks like the code controls channel 2 on the Maestro. Did you have one of your servos connected to channel 2 when you ran the RapaPololuMaestroSimpleTest program? If so, can you change the channel number in the example code to 0 and run the code again to see if you still get no movement? I am asking you to try that since is since it sounds like channel 0 and the servo connected to it work with your C++ code, and I want to see if just channel 2 might be damaged.