vis_mockup.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 Technical University of Munich, Chair of Materials Handling,
3  * Material Flow, Logistics – All Rights Reserved
4  *
5  * You may use, distribute and modify this code under the terms of the 3-clause
6  * BSD license. You should have received a copy of that license with this file.
7  * If not, please write to {kontakt.fml@ed.tum.de}.
8  */
9 
10 #include "ros/ros.h"
11 #include <iostream>
12 #include "vda5050_msgs/Visualization.h"
13 #include "vda5050_msgs/AGVPosition.h"
14 #include <string>
15 #include <ctime>
16 #include <math.h>
17 
18 using namespace std;
19 
20 
21 string getTimestamp()
22 {
23  time_t now;
24  time(&now);
25  char buf[sizeof "2011-10-08T07:07:09Z"];
26  strftime(buf, sizeof buf, "%FT%TZ", gmtime(&now));
27  return(buf);
28 }
29 
30 /*
31  * This is a simple example program to send the vis message to anyfleet
32  */
33 
34 //creates the order msg
35 vda5050_msgs::Visualization createMessage()
36 {
37  vda5050_msgs::Visualization msg;
38  msg.headerId=1;
39  msg.timestamp=getTimestamp();
40  msg.version="1.1";
41  msg.manufacturer="fml Enterprise";
42  msg.serialNumber="ajf894ajc";
43  msg.agvPosition.x=25.07;
44  msg.agvPosition.y=17.44;
45  msg.agvPosition.theta=0;
46  msg.agvPosition.positionInitialized=true;
47  msg.agvPosition.mapId="c01bf928-27b4-4018-9df0-cb37b96bf710";
48  return (msg);
49 
50 }
51 
52 vda5050_msgs::Visualization updateMessage(vda5050_msgs::Visualization msg, float angle, float r, float mx, float my)
53 {
54 
55  msg.agvPosition.x=r*cos(angle)+mx;
56  msg.agvPosition.y=r*sin(angle)+my;
57  msg.agvPosition.theta=angle;
58  return (msg);
59 }
60 
61 int main(int argc, char **argv)
62 {
63  string topicPublish = "viz_to_mc";
64  if (argc > 1)
65  topicPublish=argv[1];
66  ros::init(argc, argv, "vis_msg_mockup");
67  ros::NodeHandle nh;
68  ros::Rate loop_rate(2);
69  ros::Publisher publisherState = nh.advertise<vda5050_msgs::Visualization>(topicPublish, 1000);
70  vda5050_msgs::Visualization msg = createMessage();
71  float mx=30;
72  float my=30;
73  float r=10;
74  cout << topicPublish << "\n";
75  float angle=-M_PI;
76  while(ros::ok())
77  {
78  publisherState.publish(msg);
79  ros::spinOnce();
80  loop_rate.sleep();
81  msg.headerId+=1;
82 // msg=updateMessage(msg,angle,r,mx,my);
83 // angle+=0.05;
84 // if (angle >= M_PI)
85 // angle=-M_PI;
86  }
87  return(0);
88 };
89 
ros::Publisher
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros.h
ros::spinOnce
ROSCPP_DECL void spinOnce()
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
ros::ok
ROSCPP_DECL bool ok()
ros::Rate::sleep
bool sleep()
getTimestamp
string getTimestamp()
Definition: vis_mockup.cpp:21
main
int main(int argc, char **argv)
Definition: vis_mockup.cpp:61
std
ros::Rate
createMessage
vda5050_msgs::Visualization createMessage()
Definition: vis_mockup.cpp:35
ros::NodeHandle
updateMessage
vda5050_msgs::Visualization updateMessage(vda5050_msgs::Visualization msg, float angle, float r, float mx, float my)
Definition: vis_mockup.cpp:52


vda5050_connector
Author(s): Florian Rothmeyer , Florian Spiegel
autogenerated on Wed Mar 22 2023 02:38:56