Statistics
| Branch: | Tag: | Revision:

humotion / examples / meka / include / mekajointinterface.h @ 318729f7

History | View | Annotate | Download (2.25 KB)

1 2be6243f Sebastian Meyer zu Borgsen
#pragma once
2
#include <humotion/server/joint_interface.h>
3
#include <humotion/server/server.h>
4
#include <boost/bimap.hpp>
5
//#include "meka_data_receiver.h"
6
//class MekaDataReceiver;
7 473a6a6c Simon Schulz
#include "ros/ros.h"
8
#include "sensor_msgs/JointState.h"
9 a4795834 Simon Schulz
#include "trajectory_msgs/JointTrajectory.h"
10 6168b08c Simon Schulz
#include <m3meka_msgs/M3ControlStates.h>
11 2be6243f Sebastian Meyer zu Borgsen
12
class MekaJointInterface : public humotion::server::JointInterface{
13
public:
14 6168b08c Simon Schulz
    MekaJointInterface(std::string _input_scope, std::string control_scope, std::string _output_scope);
15 2be6243f Sebastian Meyer zu Borgsen
    ~MekaJointInterface();
16
17
    //void fetch_position(Device *dev, double timestamp);
18
    //void fetch_speed(Device *dev, double timestamp);
19 473a6a6c Simon Schulz
    //void fetch_position(int id, double value, double timestamp);
20
    //void fetch_speed(int id, double value, double timestamp);
21 2be6243f Sebastian Meyer zu Borgsen
    void run();
22
23
    static const int MAIN_LOOP_FREQUENCY = 50;
24
25
protected:
26
    void disable_joint(int e);
27
    void publish_target_position(int e);
28
    void enable_joint(int e);
29
    void execute_motion();
30
31
private:
32 6168b08c Simon Schulz
    void incoming_controlstate(const m3meka_msgs::M3ControlStates &control_state);
33 473a6a6c Simon Schulz
    void incoming_jointstates(const sensor_msgs::JointState & msg);
34 a4795834 Simon Schulz
    void store_dummy_data(int id, double timestamp);
35
    void store_min_max(int id, float min, float max);
36 473a6a6c Simon Schulz
    ros::Subscriber joint_state_subscriber;
37 6168b08c Simon Schulz
    ros::Subscriber control_state_subscriber;
38 a4795834 Simon Schulz
    ros::Publisher target_publisher;
39 473a6a6c Simon Schulz
40 6353defa Simon Schulz
    double get_timestamp_s();
41 2be6243f Sebastian Meyer zu Borgsen
42
    void set_eyelid_angle(double angle);
43
    void set_eyebrow_angle(int id);
44
    void set_mouth();
45
46
    //iCubDataReceiver *icub_data_receiver;
47
    void init_joints();
48
    double lid_angle;
49
    int lid_opening_previous;
50
    int previous_mouth_state;
51
52 e4bb9fd4 Simon Schulz
    std::string input_scope;
53 6168b08c Simon Schulz
    std::string control_scope;
54 e4bb9fd4 Simon Schulz
    std::string output_scope;
55 2be6243f Sebastian Meyer zu Borgsen
56
    float last_pos_eye_vergence;
57
    float last_pos_eye_pan;
58
    float last_vel_eye_vergence;
59
    float last_vel_eye_pan;
60
61 6168b08c Simon Schulz
    bool controller_enabled;
62
63 2be6243f Sebastian Meyer zu Borgsen
    void store_joint(int id, float value);
64
    void set_target_in_positionmode(int id, double value);
65
    void set_target_in_velocitymode(int id, double value);
66
67
68
    int convert_enum_to_motorid(int e);
69
    int convert_motorid_to_enum(int id);
70
71
72
    typedef boost::bimap<int, int > enum_id_bimap_t;
73
    typedef enum_id_bimap_t::value_type enum_id_bimap_entry_t;
74
    enum_id_bimap_t enum_id_bimap;
75
};