blob: 1c0e9a76dd69355fb67980ac5f087dc6d9401142 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014-2017. 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/*----------------------------------------------------------------------------*/
7
8#pragma once
9
10#include <string>
11
12#include <gazebo/common/Time.hh>
13#include <gazebo/transport/transport.hh>
14
15#include "simulation/gz_msgs/msgs.h"
16
17namespace frc {
18
19class SimEncoder {
20 public:
21 explicit SimEncoder(std::string topic);
22
23 void Reset();
24 void Start();
25 void Stop();
26 double GetPosition();
27 double GetVelocity();
28
29 private:
30 void sendCommand(std::string cmd);
31
32 double position, velocity;
33 gazebo::transport::SubscriberPtr posSub, velSub;
34 gazebo::transport::PublisherPtr commandPub;
35 void positionCallback(const gazebo::msgs::ConstFloat64Ptr& msg);
36 void velocityCallback(const gazebo::msgs::ConstFloat64Ptr& msg);
37};
38
39} // namespace frc