ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Hardware communication fails after ros::init

asked 2011-05-13 02:10:11 -0600

Wouter van Teijlingen gravatar image

updated 2011-06-17 10:54:28 -0600

kwc gravatar image

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.

edit retag flag offensive close merge delete

Comments

Total shot in the dark: ros::init edits argc and argv; are you possibly sending command-line arguments that look like ROS arguments?
Mac gravatar image Mac  ( 2011-06-17 10:52:04 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2011-06-17 11:16:37 -0600

Straszheim gravatar image

You're going to need to find the very first point at which execution diverges from the working and nonworking versions. At this point you could ask, "why does ros::init change this specific behavior", but with what is here it is hard to say.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-05-13 02:10:11 -0600

Seen: 215 times

Last updated: Jun 17 '11