#include <ros/ros.h>
#include <math.h>
#include <std_msgs/Float64.h>
#include <std_msgs/Float64MultiArray.h>
#include <moco/Signals.h>

void publish_value(ros::Publisher output_pub) {
    moco::Signals msg;
//    std_msgs::Float64 msg;
    double now_s = ros::Time::now().toSec();
    double frequency = 1; //[Hz]
    msg.signal1 = sin(2*M_PI*frequency*now_s);
    output_pub.publish(msg);
    return;
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "signalgen_node"); //registers node with ROS master
    ros::NodeHandle n;  //get the handle for node
//    ros::NodeHandle n("~");  //get the handle for node
    ros::Rate loop_rate(50);  //define rate for repeatable operations
    ros::Publisher output_pub; //define the publisher object with global scope
    output_pub = n.advertise<moco::Signals>("signals",10); //register with the system that we're publishing to a topic.
//    output_pub = n.advertise<std_msgs::Float64>("signal",10); //register with the system that we're publishing to a topic.

    while (ros::ok())
    {
        publish_value(output_pub);
	ros::spinOnce();  //process all incoming messages
        loop_rate.sleep();  //wait until defined time passes.
    }
}


