55 #include <boost/thread/mutex.hpp> 56 #include <boost/thread/condition.hpp> 57 #include <boost/shared_ptr.hpp> 72 #ifdef TF2_ROS_VERSION_3 // if this is groovy 77 #define class eus_class 78 #define throw eus_throw 79 #define export eus_export 80 #define vector eus_vector 81 #define string eus_string 91 char modname[] =
"___eustf";
109 #define set_ros_time(time,argv) \ 110 if (isvector(argv) && (elmtypeof(argv)==ELM_INT)) { \ 111 time.sec = argv->c.ivec.iv[0]; \ 112 time.nsec = argv->c.ivec.iv[1]; \ 122 bool interpolating = ((argv[0]==
T)?
true:
false);
123 float cache_time =
ckfltval(argv[1]);
143 isintvector(argv[3]);
169 float timeout = 0, duration = 0;
173 if (isstring(argv[1]))
177 if (isstring(argv[2]))
178 source_frame =
std::string((
char*)(argv[2]->c.str.chars));
183 if (isint(argv[4])) timeout = (float)
intval(argv[4]);
184 else if (isflt(argv[4])) timeout = (
float)
fltval(argv[4]);
187 if (isint(argv[5])) duration = (float)
intval(argv[5]);
188 else if (isflt(argv[5])) duration = (
float)
fltval(argv[5]);
199 <<
"target_frame : " << target_frame
200 <<
"source_frame : " << source_frame
202 <<
"timeout : " << timeout
203 <<
"duration : " << duration
204 <<
"return : " << ret);
206 return((ret==
true)?(
T):(
NIL));
214 std::string target_frame, source_frame, fixed_frame;
216 float timeout = 0, duration = 0;
220 if (isstring(argv[1]))
226 if (isstring(argv[3]))
227 source_frame =
std::string((
char*)(argv[3]->c.str.chars));
232 if (isstring(argv[5]))
233 fixed_frame =
std::string((
char*)(argv[5]->c.str.chars));
236 if (isint(argv[6])) timeout = (float)
intval(argv[6]);
237 else if (isflt(argv[6])) timeout = (
float)
fltval(argv[6]);
240 if (isint(argv[7])) duration = (float)
intval(argv[7]);
241 else if (isflt(argv[7])) duration = (
float)
fltval(argv[7]);
246 source_frame, source_time,
254 <<
"target_frame : " << target_frame
255 <<
"target_time : " << target_time
256 <<
"source_frame : " << source_frame
257 <<
"source_time : " << source_time
258 <<
"fixed_frame : " << fixed_frame
259 <<
"timeout : " << timeout
260 <<
"duration : " << duration
261 <<
"return : " << ret);
263 return((ret==
true)?(
T):(
NIL));
275 if (isstring(argv[1]))
279 if (isstring(argv[2]))
280 source_frame =
std::string((
char*)(argv[2]->c.str.chars));
286 ret = tf->
canTransform(target_frame, source_frame, time, &err_str);
288 ROS_WARN_STREAM(
"canTransform " << target_frame <<
" " << source_frame <<
" failed! : " << err_str);
291 <<
"target_frame : " << target_frame
292 <<
"source_frame : " << source_frame
294 <<
"return : " << ret);
296 return((ret==
true)?(
T):(
NIL));
303 std::string target_frame, source_frame, fixed_frame;
308 if (isstring(argv[1]))
314 if (isstring(argv[3]))
315 source_frame =
std::string((
char*)(argv[3]->c.str.chars));
320 if (isstring(argv[5]))
321 fixed_frame =
std::string((
char*)(argv[5]->c.str.chars));
326 source_frame, source_time,
327 fixed_frame, &err_str);
329 ROS_WARN_STREAM(
"canTransformFull " << target_frame <<
" " << source_frame <<
" failed! : " << err_str);
332 <<
"target_frame : " << target_frame
333 <<
"target_time : " << target_time
334 <<
"source_frame : " << source_frame
335 <<
"source_time : " << source_time
336 <<
"fixed_frame : " << fixed_frame
337 <<
"return : " << ret);
339 return((ret==
true)?(
T):(
NIL));
344 ROS_ERROR(
"%s is not implemented yet", __PRETTY_FUNCTION__);
364 frame_id =
std::string((
char*)(argv[1]->c.str.chars));
372 std::vector< std::string > ids;
376 for (std::vector< std::string >::iterator
s = ids.begin();
s != ids.end();
s++) {
387 std::string source_frame, target_frame, error_string;
391 source_frame =
std::string((
char*)(argv[1]->c.str.chars));
393 target_frame =
std::string((
char*)(argv[2]->c.str.chars));
400 ROS_ERROR_STREAM(
"getLatestCommonTime " << target_frame <<
" " << source_frame <<
" failed! : " << error_string);
414 target_frame =
std::string((
char*)(argv[1]->c.str.chars));
416 source_frame =
std::string((
char*)(argv[2]->c.str.chars));
423 }
catch ( std::runtime_error e ) {
446 std::string target_frame, source_frame, fixed_frame;
451 target_frame =
std::string((
char*)(argv[1]->c.str.chars));
456 source_frame =
std::string((
char*)(argv[3]->c.str.chars));
461 fixed_frame =
std::string((
char*)(argv[5]->c.str.chars));
466 source_frame, source_time, fixed_frame, transform);
467 }
catch ( std::runtime_error e ) {
501 geometry_msgs::PoseStamped input, output;
503 input.pose.position.x = argv[4]->
c.
fvec.
fv[0];
504 input.pose.position.y = argv[4]->
c.
fvec.
fv[1];
505 input.pose.position.z = argv[4]->
c.
fvec.
fv[2];
506 input.pose.orientation.w = argv[4]->
c.
fvec.
fv[3];
507 input.pose.orientation.x = argv[4]->
c.
fvec.
fv[4];
508 input.pose.orientation.y = argv[4]->
c.
fvec.
fv[5];
509 input.pose.orientation.z = argv[4]->
c.
fvec.
fv[6];
511 input.header.stamp = tm;
512 input.header.frame_id = frame_id;
516 }
catch ( std::runtime_error e ) {
522 vs->
c.
fvec.
fv[0] = output.pose.position.x;
523 vs->
c.
fvec.
fv[1] = output.pose.position.y;
524 vs->
c.
fvec.
fv[2] = output.pose.position.z;
525 vs->
c.
fvec.
fv[3] = output.pose.orientation.w;
526 vs->
c.
fvec.
fv[4] = output.pose.orientation.x;
527 vs->
c.
fvec.
fv[5] = output.pose.orientation.y;
528 vs->
c.
fvec.
fv[6] = output.pose.orientation.z;
539 float time = 0, duration = 0;
543 reference_frame =
std::string((
char*)(argv[1]->c.str.chars));
546 moving_frame =
std::string((
char*)(argv[2]->c.str.chars));
548 if (isint(argv[3])) time = (float)
intval(argv[3]);
549 else if (isflt(argv[3])) time = (
float)
fltval(argv[3]);
552 if (isint(argv[4])) duration = (float)
intval(argv[4]);
553 else if (isflt(argv[4])) duration = (
float)
fltval(argv[4]);
556 geometry_msgs::Twist velocity;
562 vs->
c.
fvec.
fv[0] = velocity.linear.x;
563 vs->
c.
fvec.
fv[1] = velocity.linear.y;
564 vs->
c.
fvec.
fv[2] = velocity.linear.z;
565 vs->
c.
fvec.
fv[3] = velocity.angular.x;
566 vs->
c.
fvec.
fv[4] = velocity.angular.y;
567 vs->
c.
fvec.
fv[5] = velocity.angular.z;
575 if( !
ros::ok() ) {
error(
E_USER,
"You must call ros::init() before creating the first NodeHandle"); }
578 float cache_time =
ckfltval(argv[0]);
579 bool spin_thread = ((argv[1]==
T)?
true:
false);
613 if (isstring(argv[1]))
620 bool ret = tf->
getParent(frame_id, time, parent);
621 return(ret?
makestring((
char *)parent.c_str(),parent.length()):
NIL);
622 }
catch ( std::runtime_error e ) {
630 if( !
ros::ok() ) {
error(
E_USER,
"You must call ros::init() before creating the first NodeHandle"); }
641 isintvector(argv[5]);
648 isfltvector(argv[1]);
649 isfltvector(argv[2]);
653 quaternion= argv[2]->
c.
fvec.
fv;
654 p_frame_id = (
char *)argv[3]->c.str.chars;
655 c_frame_id = (
char *)argv[4]->
c.
str.
chars;
657 geometry_msgs::TransformStamped trans;
658 trans.header.stamp = tm;
659 trans.header.frame_id = p_frame_id;
660 trans.child_frame_id = c_frame_id;
661 trans.transform.translation.x = pos[0]/1000.0;
662 trans.transform.translation.y = pos[1]/1000.0;
663 trans.transform.translation.z = pos[2]/1000.0;
665 trans.transform.rotation.w = quaternion[0];
666 trans.transform.rotation.x = quaternion[1];
667 trans.transform.rotation.y = quaternion[2];
668 trans.transform.rotation.z = quaternion[3];
678 if(!
ros::ok()) {
error(
E_USER,
"You must call (ros::roseus \"nodename\") before creating the first NodeHandle"); }
682 double check_frequency = 10.0;
687 if (isstring (argv[0])) {
688 ns_str.assign ((
char *)(argv[0]->c.str.chars));
694 check_frequency =
ckfltval(argv[1]);
724 return((ret==
true)?(
T):(
NIL));
737 if (isstring(argv[1])) {
738 char *cstr = (
char*)(argv[1]->c.str.chars);
739 if (cstr[0] ==
'/') {
740 target_frame.assign((
char *)(cstr+1));
742 target_frame.assign(cstr);
746 if (isstring(argv[2])) {
747 char *cstr = (
char*)(argv[2]->c.str.chars);
748 if (cstr[0] ==
'/') {
749 source_frame.assign((
char *)(cstr+1));
751 source_frame.assign(cstr);
762 ret = tfbc->
canTransform(target_frame, source_frame, time, timeout, &err_str);
764 ROS_WARN_STREAM(
"BufferClient::waitForTransform failed! : " << err_str);
767 <<
"target_frame : " << target_frame
768 <<
"source_frame : " << source_frame
770 <<
"timeout : " << timeout
771 <<
"return : " << ret);
773 return((ret==
true)?(
T):(
NIL));
786 target_frame =
std::string((
char*)(argv[1]->c.str.chars));
789 source_frame =
std::string((
char*)(argv[2]->c.str.chars));
797 geometry_msgs::TransformStamped trans;
799 trans = tfbc->
lookupTransform(target_frame, source_frame, time, timeout);
800 }
catch (std::runtime_error e) {
809 vs->
c.
fvec.
fv[0] = trans.transform.translation.x;
810 vs->
c.
fvec.
fv[1] = trans.transform.translation.y;
811 vs->
c.
fvec.
fv[2] = trans.transform.translation.z;
812 vs->
c.
fvec.
fv[3] = trans.transform.rotation.w;
813 vs->
c.
fvec.
fv[4] = trans.transform.rotation.x;
814 vs->
c.
fvec.
fv[5] = trans.transform.rotation.y;
815 vs->
c.
fvec.
fv[6] = trans.transform.rotation.z;
831 ROS_ERROR(
"Coudld not found ROS package; Please load eusros.so");
835 defun(ctx,
"EUSTF-TRANSFORMER",argv[0],(
pointer (*)())
EUSTF_TRANSFORMER,
"A Class which provides coordinate transforms between any two frames in a system");
842 defun(ctx,
"EUSTF-CHAIN",argv[0],(
pointer (*)())
EUSTF_CHAIN,
"Debugging function that will print the spanning chain of transforms");
849 defun(ctx,
"EUSTF-TRANSFORM-POSE",argv[0],(
pointer (*)())
EUSTF_TRANSFORMPOSE,
"Transform a Stamped Pose into the target frame This can throw anything a lookupTransform can throw as well as tf::InvalidArgument");
850 defun(ctx,
"EUSTF-LOOKUP-VELOCITY",argv[0],(
pointer (*)())
EUSTF_LOOKUPVELOCITY,
"Lookup the twist of the tracking_frame with respect to the observation frame in the reference_frame using the reference point");
852 defun(ctx,
"EUSTF-TRANSFORM-LISTENER",argv[0],(
pointer (*)())
EUSTF_TRANSFORM_LISTENER,
"This class inherits from Transformer and automatically subscribes to ROS transform messages");
859 defun(ctx,
"EUSTF-TRANSFORM-BROADCASTER",argv[0],(
pointer (*)())
EUSTF_TRANSFORM_BROADCASTER,
"This class provides an easy way to publish coordinate frame transform information. It will handle all the messaging and stuffing of messages. And the function prototypes lay out all the necessary data needed for each message");
860 defun(ctx,
"EUSTF-SEND-TRANSFORM",argv[0],(
pointer (*)())
EUSTF_SEND_TRANSFORM,
"Send a StampedTransform The stamped data structure includes frame_id, and time, and parent_id already");
863 defun(ctx,
"EUSTF-BUFFER-CLIENT",argv[0],(
pointer (*)())
EUSTF_BUFFER_CLIENT,
"Action client-based implementation of the tf2_ros::BufferInterface abstract data type. BufferClient uses actionlib to coordinate waiting for available transforms.");
869 pointer_update(Spevalof(
PACKAGE),p);
pointer makeint(eusinteger_t v)
pointer EUSTF_BUFFER_CLIENT_DISPOSE(register context *ctx, int n, pointer *argv)
pointer EUSTF_TRANSFORM_LISTENER(register context *ctx, int n, pointer *argv)
pointer EUSTF_LOOKUPTRANSFORM(register context *ctx, int n, pointer *argv)
pointer makepkg(context *, pointer, pointer, pointer)
pointer EUSTF_WAITFORTRANSFORMFULL(register context *ctx, int n, pointer *argv)
pointer ___eustf(register context *ctx, int n, pointer *argv, pointer env)
TFSIMD_FORCE_INLINE const tfScalar & getY() const
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
TFSIMD_FORCE_INLINE const tfScalar & getW() const
TFSIMD_FORCE_INLINE const tfScalar & getZ() const
void add_module_initializer(char *, pointer(*)())
pointer EUSTF_TRANSFORMER(register context *ctx, int n, pointer *argv)
pointer EUSTF_ALLFRAMESASSTRING(register context *ctx, int n, pointer *argv)
pointer EUSTF_CHAIN(register context *ctx, int n, pointer *argv)
pointer EUSTF_LOOKUPVELOCITY(register context *ctx, int n, pointer *argv)
bool waitForServer(const ros::Duration &timeout=ros::Duration(0))
pointer EUSTF_TRANSFORMPOSE(register context *ctx, int n, pointer *argv)
ROS_INFO ROS_ERROR int pointer * argv
pointer EUSTF_TRANSFORM_LISTENER_DISPOSE(register context *ctx, int n, pointer *argv)
pointer EUSTF_SETTRANSFORM(register context *ctx, int n, pointer *argv)
pointer EUSTF_WAITFORTRANSFORM(register context *ctx, int n, pointer *argv)
pointer EUSTF_TRANSFORM_BROADCASTER(register context *ctx, int n, pointer *argv)
pointer EUSTF_CLEAR(register context *ctx, int n, pointer *argv)
pointer EUSTF_CANTRANSFORM(register context *ctx, int n, pointer *argv)
pointer EUSTF_GETPARENT(register context *ctx, int n, pointer *argv)
pointer EUSTF_GETFRAMESTRINGS(register context *ctx, int n, pointer *argv)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
pointer defun(context *, char *, pointer, pointer(*)(), char *)
pointer EUSTF_SETEXTRAPOLATIONLIMIT(register context *ctx, int n, pointer *argv)
pointer EUSTF_CANTRANSFORMFULL(register context *ctx, int n, pointer *argv)
pointer makestring(char *, int)
pointer EUSTF_TFBC_WAITFORSERVER(register context *ctx, int n, pointer *argv)
TFSIMD_FORCE_INLINE const tfScalar & getX() const
pointer EUSTF_TFBC_LOOKUPTRANSFORM(register context *ctx, int n, pointer *argv)
pointer EUSTF_SEND_TRANSFORM(register context *ctx, int n, pointer *argv)
#define ROS_ERROR_STREAM(args)
eusinteger_t intval(pointer p)
pointer EUSTF_GETLATERSTCOMMONTIME(register context *ctx, int n, pointer *argv)
pointer EUSTF_LOOKUPTRANSFORMFULL(register context *ctx, int n, pointer *argv)
pointer EUSTF_BUFFER_CLIENT(register context *ctx, int n, pointer *argv)
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout=ros::Duration(0.0)) const
pointer EUSTF_FRAMEEXISTS(register context *ctx, int n, pointer *argv)
virtual bool canTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout=ros::Duration(0.0), std::string *errstr=NULL) const
pointer EUSTF_TFBC_CANTRANSFORM(register context *ctx, int n, pointer *argv)
#define set_ros_time(time, argv)