#include <iostream>
#include <mutex>
void
{
}
void
{
}
int
main(
int argc,
char **argv )
{
try
{
ros::Publisher enableSyncMode_pub = n->advertise< std_msgs::Bool >(
"/enableSyncMode", 1 );
ros::Publisher startSimTrigger_pub = n->advertise< std_msgs::Bool >(
"/startSimulation", 1 );
ros::Publisher stopSimTrigger_pub = n->advertise< std_msgs::Bool >(
"/stopSimulation", 1 );
std_msgs::Bool trigger;
std_msgs::Bool syncMode;
std_msgs::Bool startStopSim;
std::string simulationStepDone_topic_name = "/simulationStepDone";
std::cout << "Subscribe to " << simulationStepDone_topic_name << std::endl;
std::string simulationTime_topic_name = "/simulationTime";
std::cout << "Subscribe to " << simulationTime_topic_name << std::endl;
startStopSim.data = true;
startSimTrigger_pub.publish( startStopSim );
stopSimTrigger_pub.publish( startStopSim );
vpTime::wait( 1000 );
syncMode.data = true;
enableSyncMode_pub.
publish( trigger );
startSimTrigger_pub.publish( startStopSim );
vpTime::wait( 1000 );
double t_start = vpTime::measureTimeSecond();
double t_init = vpTime::measureTimeMs();
double t_init_prev = t_init;
float t_simTime_start = 0, t_simTime = 0, t_simTime_prev = 0;
;
t_simTime_start = t_simTime_prev =
s_simTime;
t_init_prev = vpTime::measureTimeMs();
vpColVector q_init, q_final;
std::cout << "q initial: " << 180. / M_PI * q_init.t() << " deg" << std::endl;
while ( vpTime::measureTimeSecond() - t_start < 10 )
{
t_init = vpTime::measureTimeMs();
vpColVector qdot( 7, 0 );
qdot[0] = vpMath::rad( 10 );
vpTime::sleepMs( 50 );
std::stringstream ss;
ss << "Loop time: " << t_init - t_init_prev << " - " << t_simTime - t_simTime_prev << " ms";
t_init_prev = t_init;
t_simTime_prev = t_simTime;
}
std::cout << "Elapsed time: " << vpTime::measureTimeSecond() - t_start << " seconds - "
<< t_simTime - t_simTime_start << std::endl;
std::cout << "q final: " << 180 / M_PI * q_final.t() << " deg" << std::endl;
std::cout << "Joint displacement: " << 180. / M_PI * ( q_final - q_init ).t() << " deg" << std::endl;
stopSimTrigger_pub.publish( startStopSim );
}
catch ( const vpException &e )
{
std::cout << "ViSP exception: " << e.what() << std::endl;
std::cout << "Stop the robot " << std::endl;
return EXIT_FAILURE;
}
return 0;
}