Revision 21444915
CMakeLists.txt | ||
---|---|---|
10 | 10 |
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs sensor_msgs message_generation genmsg) |
11 | 11 |
IF (NOT catkin_FOUND) |
12 | 12 |
MESSAGE(FATAL_ERROR "Error: could not find ROS middleware!") |
13 |
ENDIF (catkin_FOUND) |
|
13 |
ENDIF (NOT catkin_FOUND)
|
|
14 | 14 |
|
15 | 15 |
INCLUDE(FindPkgConfig) |
16 | 16 |
|
17 | 17 |
##libreflexxes |
18 |
IF (libreflexxes_DIR) |
|
19 |
MESSAGE("using libreflexxes_DIR as override ('${libreflexxes_DIR}')") |
|
20 |
SET(REFLEXXES_PREFIX ${libreflexxes_DIR}) |
|
21 |
ELSE () |
|
18 |
#IF (libreflexxes_DIR) |
|
19 |
# MESSAGE("using libreflexxes_DIR as override ('${libreflexxes_DIR}')") |
|
20 |
# SET(REFLEXXES_PREFIX ${libreflexxes_DIR}) |
|
21 |
# SET(REFLEXXES_LIBRARY "ReflexxesTypeII") |
|
22 |
#ELSE () |
|
22 | 23 |
PKG_CHECK_MODULES(REFLEXXES REQUIRED libReflexxesTypeII>=1.2.3) |
23 | 24 |
IF (NOT REFLEXXES_FOUND) |
24 | 25 |
message(FATAL_ERROR "Error: could not find lib libReflexxesTypeII") |
25 | 26 |
ENDIF () |
26 |
ENDIF () |
|
27 |
#ENDIF ()
|
|
27 | 28 |
|
28 | 29 |
|
29 | 30 |
SET(REFLEXXES_LIBRARY_DIRS "${REFLEXXES_PREFIX}/lib") |
... | ... | |
80 | 81 |
|
81 | 82 |
## Specify additional locations of header files |
82 | 83 |
## Your package locations should be listed before other locations |
83 |
include_directories (BEFORE ${Boost_INCLUDE_DIRS} ${REFLEXXES_INCLUDE_DIRS})
|
|
84 |
include_directories(BEFORE ${Boost_INCLUDE_DIRS} ${REFLEXXES_INCLUDE_DIRS}) |
|
84 | 85 |
include_directories(BEFORE include) |
85 | 86 |
include_directories(BEFORE include/humotion) |
86 | 87 |
#make sure to use ros messages from current build |
examples/yarp_icub/CMakeLists.txt.user | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<!DOCTYPE QtCreatorProject> |
3 |
<!-- Written by QtCreator 3.0.1, 2015-03-12T13:07:35. -->
|
|
3 |
<!-- Written by QtCreator 3.0.1, 2016-02-04T09:55:06. -->
|
|
4 | 4 |
<qtcreator> |
5 | 5 |
<data> |
6 | 6 |
<variable>ProjectExplorer.Project.ActiveTarget</variable> |
... | ... | |
53 | 53 |
<valuemap type="QVariantMap"> |
54 | 54 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> |
55 | 55 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> |
56 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{3152ed58-41d1-426c-b17f-dbe12171436a}</value>
|
|
56 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{0ff36a7d-682d-4601-a9c1-275f77eefc70}</value>
|
|
57 | 57 |
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
58 | 58 |
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
59 | 59 |
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
60 | 60 |
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
61 | 61 |
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value> |
62 |
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/homes/sschulz/src/flobidev.core/humotion/examples/yarp_icub/qbuild</value> |
|
62 |
<value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.UserArguments">-DCMAKE_INSTALL_PREFIX=/vol/icub/sschulz/releases/roman16-humotion-nightly/</value> |
|
63 |
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/homes/sschulz/src/flobi/humotion/examples/yarp_icub/build</value> |
|
63 | 64 |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
64 | 65 |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
65 | 66 |
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value> |
... | ... | |
153 | 154 |
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value> |
154 | 155 |
<value type="bool" key="CMakeProjectManager.CMakeRunConfiguration.UseTerminal">false</value> |
155 | 156 |
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value> |
156 |
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
|
157 |
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
157 | 158 |
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
158 | 159 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">icub_humotion_server</value> |
159 | 160 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
160 | 161 |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.icub_humotion_server</value> |
161 | 162 |
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
162 |
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
|
163 |
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
163 |
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
|
|
164 |
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
|
|
164 | 165 |
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
165 | 166 |
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
166 | 167 |
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
... | ... | |
174 | 175 |
</data> |
175 | 176 |
<data> |
176 | 177 |
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> |
177 |
<value type="QByteArray">{ccede451-c1b6-4b92-a13d-14bd6a65dd35}</value>
|
|
178 |
<value type="QByteArray">{44110186-3313-405d-bf42-c546b33c1fcb}</value>
|
|
178 | 179 |
</data> |
179 | 180 |
<data> |
180 | 181 |
<variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
include/humotion/server/joint_interface.h | ||
---|---|---|
50 | 50 |
JointInterface(); |
51 | 51 |
~JointInterface(); |
52 | 52 |
|
53 |
void set_target_position(int joint_id, float position); |
|
53 |
void set_target_position(int joint_id, float position, float speed);
|
|
54 | 54 |
float get_target_position(int joint_id); |
55 | 55 |
virtual void publish_target_position(int joint_id) = 0; |
56 | 56 |
virtual void execute_motion() = 0; |
... | ... | |
114 | 114 |
float joint_min[JOINT_ID_ENUM_SIZE]; |
115 | 115 |
float joint_max[JOINT_ID_ENUM_SIZE]; |
116 | 116 |
float joint_target[JOINT_ID_ENUM_SIZE]; |
117 |
float joint_target_speed[JOINT_ID_ENUM_SIZE]; |
|
117 | 118 |
|
118 | 119 |
|
119 | 120 |
|
include/humotion/server/reflexxes_motion_generator.h | ||
---|---|---|
41 | 41 |
~ReflexxesMotionGenerator(); |
42 | 42 |
|
43 | 43 |
protected: |
44 |
void reflexxes_set_input(int dof, float target, float max_speed, float max_accel); |
|
44 |
void reflexxes_set_input(int dof, float target, float position, float max_speed, float max_accel);
|
|
45 | 45 |
void reflexxes_calculate_profile(); |
46 | 46 |
|
47 | 47 |
//***************************************** |
src/server/eye_motion_generator.cpp | ||
---|---|---|
60 | 60 |
float max_accel = fmin(80000.0, 1526.53*distance_abs + 10245.4); |
61 | 61 |
|
62 | 62 |
//feed reflexxes api with data |
63 |
reflexxes_set_input(dof, target, max_speed, max_accel); |
|
63 |
reflexxes_set_input(dof, target, now, max_speed, max_accel);
|
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
//! calculate joint targets |
... | ... | |
100 | 100 |
setup_eyemotion(0, eye_pan_l_target, eye_pan_l_now); |
101 | 101 |
setup_eyemotion(1, eye_pan_r_target, eye_pan_r_now); |
102 | 102 |
setup_eyemotion(2, eye_tilt_target, eye_tilt_now); |
103 |
cout << "EYE MOTION 2 " << eye_tilt_target << " now=" << eye_tilt_now << "\n"; |
|
103 | 104 |
|
104 | 105 |
//call reflexxes to handle profile calculation: |
105 | 106 |
reflexxes_calculate_profile(); |
106 | 107 |
|
107 | 108 |
//tell the joint about the new values: |
108 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_LR, reflexxes_position_output->NewPositionVector->VecData[0]); |
|
109 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_LR, reflexxes_position_output->NewPositionVector->VecData[1]); |
|
110 |
joint_interface->set_target_position(JointInterface::ID_EYES_BOTH_UD, reflexxes_position_output->NewPositionVector->VecData[2]); |
|
109 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_LR, |
|
110 |
reflexxes_position_output->NewPositionVector->VecData[0], |
|
111 |
reflexxes_position_output->NewVelocityVector->VecData[0]); |
|
112 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_LR, |
|
113 |
reflexxes_position_output->NewPositionVector->VecData[1], |
|
114 |
reflexxes_position_output->NewVelocityVector->VecData[1]); |
|
115 |
joint_interface->set_target_position(JointInterface::ID_EYES_BOTH_UD, |
|
116 |
reflexxes_position_output->NewPositionVector->VecData[2], |
|
117 |
reflexxes_position_output->NewVelocityVector->VecData[2]); |
|
118 |
|
|
119 |
cout << reflexxes_position_output->NewPositionVector->VecData[2] << " " << reflexxes_position_output->NewVelocityVector->VecData[2] ; |
|
111 | 120 |
} |
112 | 121 |
|
113 | 122 |
|
src/server/eyebrow_motion_generator.cpp | ||
---|---|---|
22 | 22 |
float eyebrow_right_target = requested_gaze_state.eyebrow_right; |
23 | 23 |
|
24 | 24 |
//store targets: |
25 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_BROW, eyebrow_left_target); |
|
26 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_BROW, eyebrow_right_target); |
|
25 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_BROW, eyebrow_left_target, 0.0);
|
|
26 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_BROW, eyebrow_right_target, 0.0);
|
|
27 | 27 |
} |
28 | 28 |
|
29 | 29 |
//! publish targets to motor boards: |
src/server/eyelid_motion_generator.cpp | ||
---|---|---|
81 | 81 |
eyelid_lower_right_target = limit_target(JointInterface::ID_EYES_RIGHT_LID_LOWER, eyelid_lower_right_target); |
82 | 82 |
|
83 | 83 |
//(temporarily) store the target |
84 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_LID_UPPER, eyelid_upper_left_target); |
|
85 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_LID_LOWER, eyelid_lower_left_target); |
|
86 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_LID_UPPER, eyelid_upper_right_target); |
|
87 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_LID_LOWER, eyelid_lower_right_target); |
|
84 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_LID_UPPER, eyelid_upper_left_target, 0.0);
|
|
85 |
joint_interface->set_target_position(JointInterface::ID_EYES_LEFT_LID_LOWER, eyelid_lower_left_target, 0.0);
|
|
86 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_LID_UPPER, eyelid_upper_right_target, 0.0);
|
|
87 |
joint_interface->set_target_position(JointInterface::ID_EYES_RIGHT_LID_LOWER, eyelid_lower_right_target, 0.0);
|
|
88 | 88 |
|
89 | 89 |
//check for saccade |
90 | 90 |
check_for_saccade(); |
... | ... | |
221 | 221 |
//use the upper value + 10 deg as close state: |
222 | 222 |
value = joint_interface->get_joint_min(JointInterface::ID_EYES_LEFT_LID_UPPER) + 10.0; |
223 | 223 |
//overwrite last target_ |
224 |
joint_interface->set_target_position(joint_id, value); |
|
224 |
joint_interface->set_target_position(joint_id, value, 0.0);
|
|
225 | 225 |
break; |
226 | 226 |
|
227 | 227 |
case(JointInterface::ID_EYES_RIGHT_LID_UPPER): |
... | ... | |
229 | 229 |
//use the upper value + 10 deg as close state: |
230 | 230 |
value = joint_interface->get_joint_min(JointInterface::ID_EYES_RIGHT_LID_UPPER) + 10.0; |
231 | 231 |
//overwrite last target_ |
232 |
joint_interface->set_target_position(joint_id, value); |
|
232 |
joint_interface->set_target_position(joint_id, value, 0.0);
|
|
233 | 233 |
break; |
234 | 234 |
} |
235 | 235 |
} |
src/server/joint_interface.cpp | ||
---|---|---|
48 | 48 |
//! set joint target position |
49 | 49 |
//! \param joint_id of joint |
50 | 50 |
//! \param float position |
51 |
void JointInterface::set_target_position(int joint_id, float position){ |
|
51 |
void JointInterface::set_target_position(int joint_id, float position, float speed){
|
|
52 | 52 |
assert(joint_id < JOINT_ID_ENUM_SIZE); |
53 | 53 |
|
54 | 54 |
//update current value |
55 | 55 |
joint_target[joint_id] = position; |
56 |
joint_target_speed[joint_id] = speed; |
|
56 | 57 |
} |
57 | 58 |
|
58 | 59 |
//! fetch target position |
src/server/motion_generator.cpp | ||
---|---|---|
49 | 49 |
//! \param joint_id |
50 | 50 |
//! \return float value of joint position |
51 | 51 |
float MotionGenerator::get_current_position(int joint_id){ |
52 |
/*Timestamp tsl = joint_interface->get_ts_position(joint_id).get_last_timestamp(); |
|
53 |
Timestamp now = Timestamp::now(); |
|
54 |
Timestamp diff=now-tsl; |
|
55 |
printf("TIME DIFF %fs %fns\n",diff.sec, diff.nsec);*/ |
|
56 |
|
|
52 | 57 |
return joint_interface->get_ts_position(joint_id).get_newest_value(); |
53 | 58 |
} |
54 | 59 |
|
src/server/mouth_motion_generator.cpp | ||
---|---|---|
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
//tell the joint about the new values: |
95 |
joint_interface->set_target_position(upper_id, unsafe_target_upper); |
|
96 |
joint_interface->set_target_position(lower_id, unsafe_target_lower); |
|
95 |
joint_interface->set_target_position(upper_id, unsafe_target_upper, 0.0);
|
|
96 |
joint_interface->set_target_position(lower_id, unsafe_target_lower, 0.0);
|
|
97 | 97 |
|
98 | 98 |
//printf("> update_mouth_target(u=%d, l=%d) -> upper = %4.2f, lower = %4.2f\n",upper_id, lower_id,unsafe_target_upper,unsafe_target_lower); |
99 | 99 |
} |
src/server/neck_motion_generator.cpp | ||
---|---|---|
151 | 151 |
reflexxes_calculate_profile(); |
152 | 152 |
|
153 | 153 |
//tell the joint if about the new values: |
154 |
joint_interface->set_target_position(JointInterface::ID_NECK_PAN, reflexxes_position_output->NewPositionVector->VecData[0]); |
|
155 |
joint_interface->set_target_position(JointInterface::ID_NECK_TILT, reflexxes_position_output->NewPositionVector->VecData[1]); |
|
156 |
joint_interface->set_target_position(JointInterface::ID_NECK_ROLL, reflexxes_position_output->NewPositionVector->VecData[2]); |
|
154 |
joint_interface->set_target_position(JointInterface::ID_NECK_PAN, |
|
155 |
reflexxes_position_output->NewPositionVector->VecData[0], |
|
156 |
reflexxes_position_output->NewVelocityVector->VecData[0]); |
|
157 |
|
|
158 |
joint_interface->set_target_position(JointInterface::ID_NECK_TILT, |
|
159 |
reflexxes_position_output->NewPositionVector->VecData[1], |
|
160 |
reflexxes_position_output->NewVelocityVector->VecData[1]); |
|
161 |
joint_interface->set_target_position(JointInterface::ID_NECK_ROLL, |
|
162 |
reflexxes_position_output->NewPositionVector->VecData[2], |
|
163 |
reflexxes_position_output->NewVelocityVector->VecData[2]); |
|
157 | 164 |
} |
158 | 165 |
|
159 | 166 |
//! publish targets to motor boards: |
... | ... | |
206 | 213 |
if (max_accel>1000){ |
207 | 214 |
max_accel = 1000; |
208 | 215 |
} |
209 |
|
|
210 | 216 |
///printf("MAX SPEED %4.2f / max accel %4.2f\n",max_speed, max_accel); |
211 | 217 |
|
212 | 218 |
//feed reflexxes api with data |
213 |
reflexxes_set_input(dof, target, max_speed, max_accel); |
|
219 |
reflexxes_set_input(dof, target, now, max_speed, max_accel);
|
|
214 | 220 |
} |
src/server/reflexxes_motion_generator.cpp | ||
---|---|---|
35 | 35 |
ReflexxesMotionGenerator::ReflexxesMotionGenerator(JointInterface *j, int dof, float t) : MotionGenerator(j){ |
36 | 36 |
dof_count = dof; |
37 | 37 |
|
38 |
//create Reflexxes API for 3 DOF
|
|
38 |
//create Reflexxes API for <dof> DOF actuator
|
|
39 | 39 |
reflexxes_api = new ReflexxesAPI(dof, t); |
40 | 40 |
reflexxes_position_input = new RMLPositionInputParameters(dof); |
41 | 41 |
reflexxes_position_output = new RMLPositionOutputParameters(dof); |
... | ... | |
54 | 54 |
//! \param target angle |
55 | 55 |
//! \param max_speed max reachable speed during accel |
56 | 56 |
//! \param max_accel max allowable acceleration |
57 |
void ReflexxesMotionGenerator::reflexxes_set_input(int dof, float target, float max_speed, float max_accel){ |
|
57 |
void ReflexxesMotionGenerator::reflexxes_set_input(int dof, float target, float position, float max_speed, float max_accel){ |
|
58 |
assert(dof < dof_count); |
|
59 |
|
|
58 | 60 |
//set up reflexxes: |
59 | 61 |
reflexxes_position_input->TargetPositionVector->VecData[dof] = target; |
60 | 62 |
reflexxes_position_input->SelectionVector->VecData[dof] = true; |
61 | 63 |
reflexxes_position_input->MaxVelocityVector->VecData[dof] = max_speed; |
62 |
reflexxes_position_input->MaxAccelerationVector->VecData[dof] = 0.0001 + max_accel;
|
|
64 |
reflexxes_position_input->MaxAccelerationVector->VecData[dof] = max_accel; |
|
63 | 65 |
reflexxes_position_input->TargetVelocityVector->VecData[dof] = 0.0; //target speed is zero (really?) |
66 |
reflexxes_position_input->CurrentPositionVector->VecData[dof] = position; |
|
67 |
|
|
68 |
// safety: libreflexxes does not like zero accellerations... |
|
69 |
if (reflexxes_position_input->MaxAccelerationVector->VecData[dof] == 0.0){ |
|
70 |
reflexxes_position_input->MaxAccelerationVector->VecData[dof] = 0.0001; |
|
71 |
} |
|
72 |
|
|
64 | 73 |
} |
65 | 74 |
|
66 | 75 |
//! calculate motion profile |
... | ... | |
78 | 87 |
|
79 | 88 |
//feed back values: |
80 | 89 |
for(int i=0; i<dof_count; i++){ |
81 |
reflexxes_position_input->CurrentPositionVector->VecData[i] = reflexxes_position_output->NewPositionVector->VecData[i]; |
|
90 |
//reflexxes_position_input->CurrentPositionVector->VecData[i] = reflexxes_position_output->NewPositionVector->VecData[i];
|
|
82 | 91 |
reflexxes_position_input->CurrentVelocityVector->VecData[i] = reflexxes_position_output->NewVelocityVector->VecData[i]; |
83 | 92 |
reflexxes_position_input->CurrentAccelerationVector->VecData[i] = reflexxes_position_output->NewAccelerationVector->VecData[i]; |
84 | 93 |
} |
src/timestamped_list.cpp | ||
---|---|---|
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
//we reached the end, return the last value |
140 |
printf("> warning: found no timestamp bigger than %f in timestamped list...\n", target_ts.to_seconds());
|
|
140 |
printf("> warning: found no timestamp >= than %f in timestamped list...\n", target_ts.to_seconds());
|
|
141 | 141 |
printf(" this should not happen as images will always be behind\n"); |
142 | 142 |
printf(" the motor data. returning most recent value (ts=%f)\n", previous.timestamp.to_seconds()); |
143 | 143 |
|
Also available in: Unified diff