Statistics
| Branch: | Tag: | Revision:

humotion / examples / meka / include / mekajointinterface.h @ 79d4e516

History | View | Annotate | Download (2.198 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 5e4bc615 sschulz
6 473a6a6c Simon Schulz
#include "ros/ros.h"
7
#include "sensor_msgs/JointState.h"
8 a4795834 Simon Schulz
#include "trajectory_msgs/JointTrajectory.h"
9 5e4bc615 sschulz
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 e50b15da Simon Schulz
    void publish_target(int e, float position, float velocity);
28 2be6243f Sebastian Meyer zu Borgsen
    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 5e4bc615 sschulz
    void store_dummy_data(int id, humotion::Timestamp timestamp);
35 a4795834 Simon Schulz
    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 2be6243f Sebastian Meyer zu Borgsen
    void set_eyelid_angle(double angle);
41
    void set_eyebrow_angle(int id);
42
    void set_mouth();
43
44
    //iCubDataReceiver *icub_data_receiver;
45
    void init_joints();
46
    double lid_angle;
47
    int lid_opening_previous;
48
    int previous_mouth_state;
49
50 e4bb9fd4 Simon Schulz
    std::string input_scope;
51 6168b08c Simon Schulz
    std::string control_scope;
52 e4bb9fd4 Simon Schulz
    std::string output_scope;
53 2be6243f Sebastian Meyer zu Borgsen
54
    float last_pos_eye_vergence;
55
    float last_pos_eye_pan;
56
    float last_vel_eye_vergence;
57
    float last_vel_eye_pan;
58
59 6168b08c Simon Schulz
    bool controller_enabled;
60
61 2be6243f Sebastian Meyer zu Borgsen
    void store_joint(int id, float value);
62
    void set_target_in_positionmode(int id, double value);
63
    void set_target_in_velocitymode(int id, double value);
64
65
66
    int convert_enum_to_motorid(int e);
67
    int convert_motorid_to_enum(int id);
68
69
70
    typedef boost::bimap<int, int > enum_id_bimap_t;
71
    typedef enum_id_bimap_t::value_type enum_id_bimap_entry_t;
72
    enum_id_bimap_t enum_id_bimap;
73
};