-
Notifications
You must be signed in to change notification settings - Fork 13
/
neck_control_example.cpp
42 lines (38 loc) · 1.22 KB
/
neck_control_example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <tough_controller_interface/head_control_interface.h>
#include <stdlib.h>
#include <std_msgs/String.h>
#include <tough_common/tough_common_names.h>
int main(int argc, char** argv)
{
ros::init(argc, argv, "test_neck_navigation");
ros::NodeHandle nh;
RobotDescription* rd = RobotDescription::getRobotDescription(nh);
int n = rd->getNumberOfNeckJoints();
if (argc != n + 1)
{
std::string filename = std::string(argv[0]);
int index = filename.find_last_of('/');
std::stringstream input_trace_filename;
input_trace_filename << "Usage : rosrun tough_examples " << filename.substr(index + 1);
for (size_t count = 0; count < n; count++)
{
input_trace_filename << " <joint" << count + 1 << "_in_radians> ";
}
ROS_INFO_STREAM(input_trace_filename.str());
}
else
{
std::vector<float> neck_joint_values;
for (size_t count = 0; count < n; count++)
{
neck_joint_values.push_back(std::atof(argv[count + 1]));
}
ROS_INFO("Moving the neck");
std::vector<std::vector<float>> traj_points = { neck_joint_values };
HeadControlInterface headTraj(nh);
headTraj.moveNeckJoints(traj_points, 2.0f);
ros::spinOnce();
ros::Duration(2).sleep();
return 0;
}
}