ROS ImagePtr and Image Compilation Confusion [duplicate] - image

This question already has an answer here:
ROS Custom message with sensor_msgs/Image Publisher
(1 answer)
Closed 7 years ago.
I am trying to create a publish a custom message that has two images. Here is the custom message file:
Header header
sensor_msgs/Image leftimage
sensor_msgs/Image rightimage
And here is the file where I try to publish the images from my stereo camera over ROS using my custom message:
sensor_msgs::ImagePtr leftmsg;
sensor_msgs::ImagePtr rightmsg;
leftmsg = cv_bridge::CvImage(std_msgs::Header(), "mono8", leftframe).toImageMsg();
rightmsg = cv_bridge::CvImage(std_msgs::Header(), "mono8", rightframe).toImageMsg();
stereo.leftimage = leftmsg;
stereo.rightimage = rightmsg;
stereo_pub.publish(stereo);
However, I am getting the following compilation error when I catkin_make:
error: no match for ‘operator=’ (operand types are ‘duo_cam::Stereo_<std::allocator<void> >::_leftimage_type {aka sensor_msgs::Image_<std::allocator<void> >}’ and ‘sensor_msgs::ImagePtr {aka boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > >}’)
stereo.leftimage = leftmsg;
^
note: candidate is:
In file included from /opt/ros/indigo/include/image_transport/publisher.h:39:0,
from /opt/ros/indigo/include/image_transport/image_transport.h:38,
sensor_msgs::Image_<std::allocator<void> >& sensor_msgs::Image_<std::allocator<void> >::operator=(const sensor_msgs::Image_<std::allocator<void> >&)
struct Image_
^
How do I correct this? I already am using the toImageMsg() function which I see online makes the ImagePtr into an Image, so not sure what is going wrong.

According to the documentation the signature of toImageMsg is
sensor_msgs::ImagePtr toImageMsg() const;
that is it does not convert the ImagePtr to Image (CvImage is used to convert OpenCV images to ROS images). This can also be seen by the fact that you declared leftmsg and rightmsg as ImagePtr; if toImageMsg would return Image, this would not work.
To get the Image of a ImagePtr, just dereference the pointer. The following should work:
stereo.leftimage = *leftmsg;
stereo.rightimage = *rightmsg;

Related

'RedisCluster' has no member named 'get_shards_pool'

I am trying to build DeathStarBench (https://github.com/delimitrou/DeathStarBench), however, I am getting the following error:
In file included from /social-network-microservices/src/HomeTimelineService/HomeTimelineService.cpp:15:0:
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h: In member function 'virtual void social_network::HomeTimelineHandler::WriteHomeTimeline(int64_t, int64_t, int64_t, int64_t, const std::vector&, const std::mapstd::__cxx11::basic_string<char, std::__cxx11::basic_string >&)':
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h:129:55: error: 'class sw::redis::RedisCluster' has no member named 'get_shards_pool'
auto *shards_pool = _redis_cluster_client_pool->get_shards_pool();
I don't know anything about Redis. However, I googled the error message and couldn't find anything related to this. Any suggestions on what might be the problem?

SuperCollider * marking the constructor method is not expected

I tried to create a Class and the constructor always gave me a Syntax Error about the *new method then I just copied the Example from the documentation:
MyClass {
// this is a normal constructor method
*new { | arga, argb, argc |
^super.new.init(arga, argb, argc)
}
init { | arga, argb, argc |
// do initiation here
}
}
and still got this:
ERROR: syntax error, unexpected '*', expecting '}'
in interpreted text
line 6 char 5:
*new { | arga, argb, argc |
^
^super.new.init(arga, argb, argc)
-----------------------------------
ERROR: Command line parse failed
-> nil
From my own class i get the same error concerning the constructor. Where am I wrong?
If you check out the Writing Classes helpfile, there's a bit at the top that's easy to miss about where to save your classes.
https://depts.washington.edu/dxscdoc/Help/Guides/WritingClasses.html
NOTE: Class definitions are statically compiled when you launch
SuperCollider or "recompile the library." This means that class
definitions must be saved into a file with the extension .sc, in a
disk location where SuperCollider looks for classes. Saving into the
main class library (SCClassLibrary) is generally not recommended. It's
preferable to use either the user or system extension directories.
Platform.userExtensionDir; // Extensions available only to your user account
Platform.systemExtensionDir; // Extensions available to all users on the machine
It is not possible to enter a class definition into an interpreter
window and execute it.
The the Save As Extension option under the file menu. Then recompile the interpretter and try using your class.

Botan build error 'AutoSeeded_RNG' does not name a type

Trying to build the Botan executable, I am getting the following error:
../src/cli/timing_tests.cpp: In static member function 'static Botan::RandomNumberGenerator& Botan_CLI::Timing_Test::timing_test_rng()':
../src/cli/timing_tests.cpp:100:17: error: 'AutoSeeded_RNG' does not name a type
static AutoSeeded_RNG static_timing_test_rng(Botan::Entropy_Sources::global_sources(), 0);
^~~~~~~~~~~~~~
../src/cli/timing_tests.cpp:101:17: error: 'static_timing_test_rng' was not declared in this scope
return static_timing_test_rng;
^~~~~~~~~~~~~~~~~~~~~~
../src/cli/timing_tests.cpp:101:17: note: suggested alternative: 'timing_test_rng'
return static_timing_test_rng;
^~~~~~~~~~~~~~~~~~~~~~
timing_test_rng
make: *** [Makefile:606: build/obj/cli/timing_tests.o] Error 1
this is the C++ code:
static Botan::RandomNumberGenerator& timing_test_rng()
{
#if defined(BOTAN_HAS_SYSTEM_RNG)
return Botan::system_rng();
#elif defined(BOTAN_HAS_AUTO_SEEDING_RNG)
static AutoSeeded_RNG static_timing_test_rng(Botan::Entropy_Sources::global_sources(), 0);
return static_timing_test_rng;
#else
// we could just use SHA-256 in OFB mode for these purposes
throw CLI_Error("Timing tests require a PRNG");
#endif
}
I am using these settings:
configure.py --prefix=$BUILD_DIR --with-external-includedir=$OPENSSL_PREFIX/include --with-external-libdir=$OPENSSL_PREFIX/lib --os=mingw --cpu=i386 --minimized-build --enable- modules=rsa,dsa,ecdsa,ed25519,hmac,hmac_drbg,mode_pad,bigint,filters,block,auto_rng,x509,cbc,dh --with-openssl
(building with mingw32, in Windows 10. Botan version 2.11.0)
I am pretty new on this. Any ideas?
EDIT: Changed to version 2.10.0, since 2.11.0 is not yet official, however the error did now change, to :
undefined reference to 'Botan::CPUID::state()'
Seems like adding entropy source system_rng solves this problem. Just add it to the enable-modules list. Got this from Jack Lloyd, creator of the Botan lib,

Conversions between tf and eigen

Eigen::Affine3f transform_temp = (Affine3f)transforms[i];
const Eigen::Matrix3d rotation_part = transform_temp.rotation().cast<double>();
const Eigen::Vector3d translation_part = transform_temp.translation().cast<double>();
tf::Matrix3x3 rot;
tf::Vector3 tra;
tf::matrixEigenToTF(rotation_part, rot);
tf::vectorEigenToTF(translation_part, tra);
tf::Transform temp_transform(rot, tra);
listener->lookupTransform (link, msg_in->header.frame_id, ros::Time(0), tfTransform);
broadcaster->sendTransform(tf::StampedTransform(tfTransform * temp_transform.inverse(), ros::Time::now(), link, "chess_board"));
I got the following error. Do not know why, I have find_package(catkin REQUIRED COMPONENTS tf tf_conversions) and also target_link_libraries(${catkin_LIBRARIES})
undefined reference to `tf::matrixEigenToTF(Eigen::Matrix<double, 3, 3, 1, 3, 3> const&, tf::Matrix3x3&)'
You have to set up you CMakeList.txt as shown in this answer to properly include Eigen in your project.
Also, you don't need to split the affine transform in the rotation and traslation components (have a look at Eigen-tf conversion).
Eigen::Affine3f transform_eigen = (Affine3f)transforms[i];
tf::Transform transform_tf;
tf::transformEigenToTF(transform_eigen, transform_tf);
EDIT:
I have suddenly thought about Eigen library and not about what could be actually the problem. Have you added the tf_conversions dependency in the package.xml file? You have not mentioned it. Also, you have to include the library: #include <tf_conversions/tf_eigen.h>

Compiling OpenMCU in Linux (Fedora12)

I am tring to compile OpenMCU in fedora 12. Since the orignal project was compiled in VC++, it has some compatiility issues with gcc.
I am using gcc 4.4.4 and febora 12.
The error shows somehting like this.
In file included from mcu.h:84,
from main.cxx:56:
filemembers.h:123: error: ISO C++ forbids declaration of ‘deque’ with no type
filemembers.h:123: error: typedef name may not be a nested-name-specifier
filemembers.h:123: error: expected ‘;’ before ‘<’ token
filemembers.h:124: error: ISO C++ forbids declaration of ‘FilenameList’ with no type
filemembers.h:124: error: expected ‘,’ or ‘...’ before ‘&’ token
In file included from mcu.h:84,
from main.cxx:56:
filemembers.h:149: error: ‘FilenameList’ does not name a type
make: *** [obj_linux_x86_r/main.o] Error 1
when checked in the source code of that perticular file it was something like this...
class ConferenceFileMember : public ConferenceMember
{
PCLASSINFO(ConferenceFileMember, ConferenceMember);
public:
ConferenceFileMember(Conference * conference, const PFilePath & _fn, PFile::OpenMode mode);
*typedef std::deque<PFilePath> FilenameList; //Line 123..*
ConferenceFileMember(Conference * conference, const FilenameList & _fns, PFile::OpenMode mode);
~ConferenceFileMember();
void Unlisten();
Seems to be a simple syntax issue. Can someone help me in this regards?
Thanx in advance..
Looks like std::deque is not defined. Did you #include <deque>?

Resources