Hardware communication fails after ros::init
Dear list,
I've a couple of packages for communicating with our delta robot. This is sample code, it's ugly, but it's for demonstration purposes only:
....
std::cout << "par_trajectory_planning." << std::endl;
ros::init(argc, argv, "par_trajectory_planning");
//ros::NodeHandle n;
modbus_t* ctx = modbus_new_rtu("/dev/ttyS0", 115200, 'N', 8, 1);
//init_communication(ctx);
//configure_PTP_motion(ctx);
par_trajectory_planning::commands cmd;
cmd.xyz_pos.clear();
stepperMotor = new StepperMotor(ctx);
stepperMotor->initCom();
cmd.xyz_pos.push_back(-41.5733);
cmd.xyz_pos.push_back(-41.5733);
cmd.xyz_pos.push_back(-41.5733);
stepperMotor->confPTPMotion(cmd);
...
If i run this program with the following command:
rosrun par_trajectory_planning par_planning
It seems to block the hardware. I get messages like the following:
ANGLE: -41.5733
[03][10][04][02][00][02][04][00][00][02][A1][8B][D6]
Waiting for a confirmation...
<03><10><04><02><00><02><E0><DA>
errno: File exists
There errno is the problem. If i disable this line in the sample code:
ros::init(argc, argv, "par_trajectory_planning");
The program works as expected; we start it with the same command. Of course no ROS integration, but it communicates with the hardware as expected. What happens in ros::init that alters the behavior of our program? We make use of libmodbus ( www.libmodbus.org ) in this package and it works fine; but if we integrate it in ROS it doesn't work.
I tried to start everything as root, but that doesn't change errors. Thanks.