30 catch (
const std::exception& e)
32 ROS_ERROR(
"Motion: Failed to connect to Motion Proxy!\n\tTrace: %s", e.what());
40 catch (
const std::exception& e)
42 ROS_WARN(
"Motion: Failed to set move arms enabled!\n\tTrace: %s", e.what());
48 motion_proxy_.call<
void>(
"setExternalCollisionProtectionEnabled",
"Arms", 0);
50 catch (
const std::exception& e)
52 ROS_WARN(
"Motion: Failed to set external collision protection!\n\tTrace: %s", e.what());
60 catch (
const std::exception& e)
62 ROS_WARN(
"Motion: Failed to set smart stiffness!\n\tTrace: %s", e.what());
79 catch (
const std::exception& e)
81 ROS_WARN(
"Motion: Failed to check if the robot is wakedup!\n\tTrace: %s", e.what());
97 catch (
const std::exception& e)
99 ROS_WARN(
"Motion: Failed to wake up the robot!\n\tTrace: %s", e.what());
114 catch (
const std::exception& e)
116 ROS_WARN(
"Motion: Failed to go to rest!\n\tTrace: %s", e.what());
122 std::vector <std::string> joints;
125 joints =
motion_proxy_.call< std::vector<std::string> >(
"getBodyNames", robot_part);
127 catch (
const std::exception& e)
129 ROS_ERROR(
"Motion: Failed to get robot body names!\n\tTrace: %s", e.what());
137 std::vector <std::string> res;
139 for (std::vector<std::string>::const_iterator it=motor_groups.begin(); it!=motor_groups.end(); ++it)
141 std::vector <std::string> joint_names =
getBodyNames(*it);
142 res.insert(res.end(), joint_names.begin(), joint_names.end());
154 catch (
const std::exception& e)
156 ROS_WARN(
"Motion: Failed to set external collision protection!\n\tTrace: %s", e.what());
164 catch (
const std::exception& e)
166 ROS_WARN(
"Motion: Failed to set Push Recovery Enabled!\n\tTrace: %s", e.what());
172 ROS_INFO_STREAM(
"going to move x: " << vel_x <<
" y: " << vel_y <<
" th: " << vel_th);
178 catch (
const std::exception& e)
180 ROS_WARN(
"Motion: Failed to execute MoveTo!\n\tTrace: %s", e.what());
186 std::vector<double> res;
190 res =
motion_proxy_.call< std::vector<double> >(
"getAngles", robot_part, 1);
192 catch (
const std::exception& e)
194 ROS_WARN(
"Motion: Failed to get joints angles!\n\tTrace: %s", e.what());
210 motion_proxy_.async<
void>(
"setAngles", names_qi, angles_qi, 0.2f);
212 catch(
const std::exception& e)
214 ROS_ERROR(
"Motion: Failed to set joints nagles! \n\tTrace: %s", e.what());
219 const float &stiffness,
222 std::vector<std::string>::const_iterator it=motor_groups.begin();
223 for (; it!=motor_groups.end(); ++it)
230 const float &stiffness,
235 motion_proxy_.call<
void>(
"stiffnessInterpolation", motor_group, stiffness, time);
237 catch (
const std::exception &e)
239 ROS_ERROR(
"Motion: Failed to set stiffness \n\tTrace: %s", e.what());
243 ROS_INFO_STREAM(
"Stiffness is updated to " << stiffness <<
" for " << motor_group);
bool setStiffnessArms(const float &stiffness, const float &time)
set stiffness for arms
void moveTo(const float &vel_x, const float &vel_y, const float &vel_th)
Move the robot at given velocity and angle.
void manageConcurrence()
Manage concurrence of DCM and ALMotion.
void wakeUp()
wake up the robot
std::vector< std::string > getBodyNamesFromGroup(const std::vector< std::string > &motor_groups)
get body names based on motor groups
qi::AnyObject motion_proxy_
std::vector< double > getAngles(const std::string &robot_part)
get joints angles
void init(const std::vector< std::string > &joints_names)
initialize with joints names to control
Motion(const qi::SessionPtr &session)
std::vector< std::string > joints_names_
void writeJoints(const std::vector< double > &joint_commands)
set joints values
void rest()
go to the rest position
#define ROS_INFO_STREAM(args)
bool robotIsWakeUp()
check if the robot is waked up
std::vector< std::string > getBodyNames(const std::string &robot_part)
get body names
bool stiffnessInterpolation(const std::string &motor_group, const float &stiffness, const float &time)
set stiffness for one motor group