Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 7 | |
| 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 | |
| 16 | using namespace gazebo; |
| 17 | |
| 18 | class SimEncoder { |
| 19 | public: |
| 20 | SimEncoder(std::string topic); |
| 21 | |
| 22 | void Reset(); |
| 23 | void Start(); |
| 24 | void Stop(); |
| 25 | double GetPosition(); |
| 26 | double GetVelocity(); |
| 27 | |
| 28 | private: |
| 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 |