blob: 254cbe41ac0ccdcd43945b155efe947b21f22b0d [file] [log] [blame]
Brian Silverman1a675112016-02-20 20:42:49 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
Brian Silverman26e4e522015-12-17 01:56:40 -05007
8
9#ifndef _SIM_ENCODER_H
10#define _SIM_ENCODER_H
11
12#include "simulation/gz_msgs/msgs.h"
13#include <gazebo/transport/transport.hh>
14#include <gazebo/common/Time.hh>
15
16using namespace gazebo;
17
18class SimEncoder {
19public:
20 SimEncoder(std::string topic);
21
22 void Reset();
23 void Start();
24 void Stop();
25 double GetPosition();
26 double GetVelocity();
27
28private:
29 void sendCommand(std::string cmd);
30
31 double position, velocity;
32 transport::SubscriberPtr posSub, velSub;
33 transport::PublisherPtr commandPub;
34 void positionCallback(const msgs::ConstFloat64Ptr &msg);
35 void velocityCallback(const msgs::ConstFloat64Ptr &msg);
36};
37
38#endif