ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This works for me.
#include <unistd.h>
#include <ostream>
int main()
{
char* argsUwsim[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/roscore", NULL};
char* argsUwsimSecond[5] = {"bash", "-i", "-c", ""/opt/ros/kinetic/bin/rosrun uwsim uwsim", NULL};
pid_t pid = fork();
if (pid < 0)
{
std::cerr << "fork failed";
return 1;
}
if (pid > 0) // The parent
{
execvp(argsUwsim[0], argsUwsim);
}
else // The child
{
execvp(argsUwsimSecond[0], argsUwsimSecond);
}
}
2 | No.2 Revision |
This works for me.
#include <unistd.h>
#include <ostream>
int main()
{
char* argsUwsim[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/roscore", NULL};
char* argsUwsimSecond[5] = {"bash", "-i", "-c", ""/opt/ros/kinetic/bin/rosrun "/opt/ros/kinetic/bin/rosrun uwsim uwsim", NULL};
pid_t pid = fork();
if (pid < 0)
{
std::cerr << "fork failed";
return 1;
}
if (pid > 0) // The parent
{
execvp(argsUwsim[0], argsUwsim);
}
else // The child
{
execvp(argsUwsimSecond[0], argsUwsimSecond);
}
}
3 | No.3 Revision |
This works for me. (I used a node of my own instead of uwsim
)
#include <unistd.h>
#include <ostream>
int main()
{
char* argsUwsim[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/roscore", NULL};
char* argsUwsimSecond[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/rosrun uwsim uwsim", NULL};
pid_t pid = fork();
if (pid < 0)
{
std::cerr << "fork failed";
return 1;
}
if (pid > 0) // The parent
{
execvp(argsUwsim[0], argsUwsim);
}
else // The child
{
execvp(argsUwsimSecond[0], argsUwsimSecond);
}
}
4 | No.4 Revision |
This works for me. (I used a node of my own instead of uwsim
))
There are two caveats:
- When you kill the second node, the roscore
receives a shutdown request (it doesn't actually shutdown). This is expected, since the second node is a child of the core.
- For some reason I can't shutdown the roscore
with ctrl+C.
#include <unistd.h>
#include <ostream>
int main()
{
char* argsUwsim[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/roscore", NULL};
char* argsUwsimSecond[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/rosrun uwsim uwsim", NULL};
pid_t pid = fork();
if (pid < 0)
{
std::cerr << "fork failed";
return 1;
}
if (pid > 0) // The parent
{
execvp(argsUwsim[0], argsUwsim);
}
else // The child
{
execvp(argsUwsimSecond[0], argsUwsimSecond);
}
}
5 | No.5 Revision |
This works for me. (I used a node of my own instead of uwsim
)
)
There are two caveats:
- When you kill the second node, the roscore
receives a shutdown request (it doesn't actually shutdown). This is expected, since the second node is a child of the core.
- For some reason I can't shutdown the roscore
with ctrl+C.
#include <unistd.h>
#include <ostream>
int main()
{
char* argsUwsim[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/roscore", NULL};
char* argsUwsimSecond[5] = {"bash", "-i", "-c", "/opt/ros/kinetic/bin/rosrun uwsim uwsim", NULL};
pid_t pid = fork();
if (pid < 0)
{
std::cerr << "fork failed";
return 1;
}
if (pid > 0) // The parent
{
execvp(argsUwsim[0], argsUwsim);
}
else // The child
{
execvp(argsUwsimSecond[0], argsUwsimSecond);
}
}