1 #ifndef _KUKA_FRI_ALGORITHM 2 #define _KUKA_FRI_ALGORITHM 8 #include <boost/range/adaptor/copied.hpp> 9 #include <boost/range/algorithm/copy.hpp> 10 #include <boost/range/distance.hpp> 11 #include <boost/range.hpp> 12 #include <boost/geometry/core/access.hpp> 13 #include <boost/units/physical_dimensions/torque.hpp> 14 #include <boost/units/physical_dimensions/plane_angle.hpp> 15 #include <boost/units/physical_dimensions/torque.hpp> 16 #include <boost/lexical_cast.hpp> 17 #include <boost/asio.hpp> 18 #include <boost/container/static_vector.hpp> 21 #include "friClientIf.h" 22 #include "FRIMessages.pb.h" 23 #include "friCommandMessageEncoder.h" 24 #include "friMonitoringMessageDecoder.h" 29 namespace grl {
namespace robot {
43 template<
typename T,
typename OutputIterator>
45 if(dataAvailable)
std::copy(static_cast<double*>(static_cast<tRepeatedDoubleArguments*>(values)->value),static_cast<double*>(static_cast<tRepeatedDoubleArguments*>(values)->value)+
KUKA::LBRState::NUM_DOF,it);
61 template<
typename T,
typename OutputIterator>
64 if(dataAvailable)
std::copy(&values.element[0],&values.element[0]+std::min(values.element_count,static_cast<std::size_t>(6)),it);
70 boost::iterator_range<T>
get(T& values,
bool dataAvailable =
true){
71 return boost::iterator_range<T>(*values);
79 template<
typename OutputIterator>
81 kuka::detail::copyJointState(monitoringMsg.monitorData.measuredJointPosition.value.arg,it,monitoringMsg.monitorData.has_measuredJointPosition);
85 template<
typename OutputIterator>
91 template<
typename OutputIterator>
93 kuka::detail::copyJointState(monitoringMsg.monitorData.commandedJointPosition.value.arg,it, monitoringMsg.monitorData.has_commandedJointPosition);
98 template<
typename OutputIterator>
104 template<
typename OutputIterator>
119 template<
typename OutputIterator>
126 template<
typename OutputIterator>
134 if (monitoringMsg.has_robotInfo) {
135 if (monitoringMsg.robotInfo.has_safetyState)
144 if (monitoringMsg.has_robotInfo) {
145 if (monitoringMsg.robotInfo.has_operationMode)
154 if (monitoringMsg.has_robotInfo) {
155 if (monitoringMsg.robotInfo.has_controlMode)
164 if (monitoringMsg.has_ipoData) {
165 if (monitoringMsg.ipoData.has_clientCommandMode)
174 if (monitoringMsg.has_ipoData) {
175 if (monitoringMsg.ipoData.has_overlayType)
184 tRepeatedIntArguments *values =
185 (tRepeatedIntArguments *)_message.robotInfo.driveState.arg;
186 int firstState = (
int)values->value[0];
189 int state = (int)values->value[i];
190 if (state != firstState)
192 return KUKA::FRI::EDriveState::TRANSITIONING;
200 if (monitoringMsg.has_connectionInfo) {
203 return KukaSessionState;
208 if (monitoringMsg.has_connectionInfo) {
219 uint32_t KukaSendPeriod = 0;
220 if (monitoringMsg.has_connectionInfo) {
221 if (monitoringMsg.connectionInfo.has_sendPeriod)
222 KukaSendPeriod = monitoringMsg.connectionInfo.sendPeriod;
224 return KukaSendPeriod;
228 std::size_t KukaReceiveMultiplier = 0;
229 if (monitoringMsg.has_connectionInfo) {
230 if (monitoringMsg.connectionInfo.has_receiveMultiplier)
231 KukaReceiveMultiplier = monitoringMsg.connectionInfo.receiveMultiplier;
233 return KukaReceiveMultiplier;
236 std::chrono::time_point<std::chrono::high_resolution_clock>
get(
const FRIMonitoringMessage& monitoringMsg,
const std::chrono::time_point<std::chrono::high_resolution_clock>){
238 std::chrono::time_point<std::chrono::high_resolution_clock> timestamp;
239 if (monitoringMsg.monitorData.has_timestamp) {
240 timestamp += std::chrono::seconds(monitoringMsg.monitorData.timestamp.sec) +
241 std::chrono::nanoseconds(monitoringMsg.monitorData.timestamp.nanosec);
255 template<
typename Range>
257 if(boost::size(range))
259 state.has_commandData =
true;
260 state.commandData.has_jointPosition =
true;
261 tRepeatedDoubleArguments *dest = (tRepeatedDoubleArguments*)state.commandData.jointPosition.value.arg;
277 template<
typename Range>
279 if(boost::size(range))
281 state.has_commandData =
true;
282 state.commandData.has_jointTorque =
true;
283 tRepeatedDoubleArguments *dest = (tRepeatedDoubleArguments*)state.commandData.jointTorque.value.arg;
311 template<
typename Range>
313 if(boost::size(range))
315 state.has_commandData =
true;
316 state.commandData.has_cartesianWrenchFeedForward =
true;
317 std::copy_n(std::begin(range),std::min(boost::size(range),state.commandData.cartesianWrenchFeedForward.element_count), &state.commandData.cartesianWrenchFeedForward.element[0]);
323 static inline void set(FRICommandMessage & state,
const FRICommandMessage& sourceState,
grl::command_tag) {
324 state.has_commandData = sourceState.has_commandData;
327 state.commandData.has_cartesianWrenchFeedForward = state.commandData.has_cartesianWrenchFeedForward;
328 std::copy_n(&state.commandData.cartesianWrenchFeedForward.element[0],std::min(state.commandData.cartesianWrenchFeedForward.element_count,sourceState.commandData.cartesianWrenchFeedForward.element_count), &state.commandData.cartesianWrenchFeedForward.element[0]);
331 tRepeatedDoubleArguments *dest;
332 tRepeatedDoubleArguments *source;
337 state.commandData.has_jointTorque = state.commandData.has_jointTorque;
338 dest = (tRepeatedDoubleArguments*)state.commandData.jointTorque.value.arg;
339 source = (tRepeatedDoubleArguments*)sourceState.commandData.jointTorque.value.arg;
340 std::copy_n(source->value,std::min(source->size,dest->size), dest->value);
344 state.commandData.has_jointPosition = state.commandData.has_jointPosition;
345 dest = (tRepeatedDoubleArguments*)state.commandData.jointPosition.value.arg;
346 source = (tRepeatedDoubleArguments*)sourceState.commandData.jointPosition.value.arg;
347 std::copy_n(source->value,std::min(source->size,dest->size), dest->value);
352 static inline void set(FRICommandMessage & state,
const FRICommandMessage& sourceState) {
378 namespace mpl {
template<
int N >
struct int_;}
380 namespace mpl { using ::mpl_::int_; }
385 namespace cs {
struct cartesian; }
390 template<
typename T,
typename Enable>
struct tag;
394 template <
typename Geometry, std::
size_t Dimension,
typename Enable >
struct access;
397 template<
typename Enable>
struct dimension<FRIMonitoringMessage, Enable > : boost::mpl::int_<KUKA::LBRState::NUM_DOF> {};
398 template<
typename Enable>
struct coordinate_type<FRIMonitoringMessage, Enable > {
typedef boost::iterator_range<repeatedDoubleArguments>
type; };
415 return grl::robot::arm::kuka::detail::get(*static_cast<tRepeatedDoubleArguments*>(monitoringMsg.monitorData.commandedJointPosition.value.arg),monitoringMsg.monitorData.has_measuredJointPosition);
421 return grl::robot::arm::kuka::detail::get(*static_cast<tRepeatedDoubleArguments*>(monitoringMsg.ipoData.jointPosition.value.arg), monitoringMsg.ipoData.has_jointPosition);
427 return grl::robot::arm::kuka::detail::get(*static_cast<tRepeatedDoubleArguments*>(monitoringMsg.monitorData.measuredTorque.value.arg),monitoringMsg.monitorData.has_measuredTorque);
433 return grl::robot::arm::kuka::detail::get(*static_cast<tRepeatedDoubleArguments*>(monitoringMsg.monitorData.externalTorque.value.arg),monitoringMsg.monitorData.has_externalTorque);
439 return grl::robot::arm::kuka::detail::get(*static_cast<tRepeatedDoubleArguments*>(monitoringMsg.ipoData.jointPosition.value.arg),monitoringMsg.ipoData.has_jointPosition);
445 return grl::robot::arm::kuka::detail::get(*static_cast<tRepeatedDoubleArguments*>(monitoringMsg.monitorData.commandedTorque.value.arg), monitoringMsg.monitorData.has_commandedTorque);
509 template<
typename Enable>
struct dimension<FRICommandMessage, Enable > : boost::mpl::int_<1> {};
510 template<
typename Enable>
struct coordinate_type<FRICommandMessage, Enable > {
typedef boost::iterator_range<repeatedDoubleArguments>
type; };
530 template<
typename Range>
532 state.has_commandData =
true;
533 state.commandData.has_jointPosition =
true;
534 tRepeatedDoubleArguments *dest = (tRepeatedDoubleArguments*)state.commandData.jointPosition.value.arg;
external joint torque, i.e. torques applied to an arm excluding those caused by the mass of the arm i...
const int default_port_id
OutputIterator copy(std::string model, OutputIterator it, grl::revolute_joint_velocity_open_chain_state_constraint_tag)
copy vector of joint velocity limits in radians/s
boost::iterator_range< repeatedDoubleArguments > type
data for changing a system's physical state, such as joint angles to be sent to a robot arm...
grl::device_state_tag type
void copyJointState(T values, OutputIterator it, bool dataAvailable=true)
void copyCartesianState(T values, OutputIterator it, bool dataAvailable=true)
boost::iterator_range< T > get(T &values, bool dataAvailable=true)
boost::iterator_range< repeatedDoubleArguments > type
if(EXISTS "${PROJECT_DOC_DIR}/CMakeLists.txt") option(BUILD_DOCUMENTATION "Request build and/or installation of documentation." OFF) endif() if(EXISTS "$
time step between measurements
external forces, i.e. forces applied to an arm excluding those caused by the mass of the arm itself a...
void copy(const FRIMonitoringMessage &monitoringMsg, OutputIterator it, revolute_joint_torque_open_chain_command_tag)
copy commanded joint torque to output iterator
EClientCommandMode
Type of command being sent to the arm (Dimensonal units)
grl::device_command_tag type