setVehicleActuators.cpp
Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2013 University of Jaume-I.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the GNU Public License v3.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.gnu.org/licenses/gpl.html
00007  * 
00008  * Contributors:
00009  *     Mario Prats
00010  *     Javier Perez
00011  */ 
00012 
00016 #include <ros/ros.h>
00017 #include <std_msgs/Float64MultiArray.h>
00018 #include <stdlib.h>
00019 
00020 int main(int argc, char **argv) {
00021         if (argc < 3) {
00022                 std::cerr << "Usage: " << argv[0] << "<topic> <u1> <u2> ... <un>" << std::endl;
00023                 exit(0);
00024         }
00025         std::string topic(argv[1]);
00026 
00027         ros::init(argc, argv, "setVehicleActuators");
00028         ros::NodeHandle nh;
00029 
00030         ros::Publisher u_pub;
00031         u_pub=nh.advertise<std_msgs::Float64MultiArray>(topic,1);
00032         ros::Rate rate(5);
00033 
00034         double u[argc-2];
00035         for (int i=2; i<argc; i++) u[i-2]=atof(argv[i]);
00036 
00037         while (ros::ok()) {
00038                 std_msgs::Float64MultiArray um;
00039 
00040                 for (int i=0; i<argc-2; i++)
00041                         um.data.push_back(u[i]);
00042 
00043                 u_pub.publish(um);
00044 
00045                 ros::spinOnce();
00046                 rate.sleep();
00047         }
00048 
00049         return 0;
00050 }


uwsim
Author(s): Mario Prats
autogenerated on Mon Oct 6 2014 08:24:07