0
$\begingroup$

Rosanswers logo

I need to create a custom message for a PTZ camera so I can post the pan, tilt and zoom values to a topic. The problem is that I can't generate any access methods to change them. My message is defined like this:

std_msgs/Header header
float32 pan
float32 tilt
float32 zoom

Below is the generated header, but includes no methods for setting any of my defined values.

// Generated by gencpp from file ros_pantiltzoom_tardec/PTZ.msg
// DO NOT EDIT!


#ifndef ROS_PANTILTZOOM_TARDEC_MESSAGE_PTZ_H
#define ROS_PANTILTZOOM_TARDEC_MESSAGE_PTZ_H


#include 
#include 
#include 

#include 
#include 
#include 
#include 

#include 

namespace ros_pantiltzoom_tardec
{
template 
struct PTZ_
{
  typedef PTZ_ Type;

  PTZ_()
    : header()
    , pan(0.0)
    , tilt(0.0)
    , zoom(0.0)  {
    }
  PTZ_(const ContainerAllocator& _alloc)
    : header(_alloc)
    , pan(0.0)
    , tilt(0.0)
    , zoom(0.0)  {
  (void)_alloc;
    }



   typedef  ::std_msgs::Header_  _header_type;
  _header_type header;

   typedef float _pan_type;
  _pan_type pan;

   typedef float _tilt_type;
  _tilt_type tilt;

   typedef float _zoom_type;
  _zoom_type zoom;




  typedef boost::shared_ptr > Ptr;
  typedef boost::shared_ptr const> ConstPtr;

}; // struct PTZ_

typedef ::ros_pantiltzoom_tardec::PTZ_ > PTZ;

typedef boost::shared_ptr PTZPtr;
typedef boost::shared_ptr PTZConstPtr;

// constants requiring out of line definition



template
std::ostream& operator & v)
{
ros::message_operations::Printer >::stream(s, "", v);
return s;
}

} // namespace ros_pantiltzoom_tardec

namespace ros
{
namespace message_traits
{



// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True}
// {'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg'], 'roscpp': ['/opt/ros/indigo/share/roscpp/cmake/../msg'], 'ros_pantiltzoom_tardec': ['/home/brenton/jaustoolset/autogenerated/PanTiltZoomCamera_41/msg']}

// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']




template 
struct IsFixedSize >
  : FalseType
  { };

template 
struct IsFixedSize const>
  : FalseType
  { };

template 
struct IsMessage >
  : TrueType
  { };

template 
struct IsMessage const>
  : TrueType
  { };

template 
struct HasHeader >
  : TrueType
  { };

template 
struct HasHeader const>
  : TrueType
  { };


template
struct MD5Sum >
{
  static const char* value()
  {
    return "163a943a2132dce8f0610e78f5487c99";
  }

  static const char* value(const ::ros_pantiltzoom_tardec::PTZ_&) { return value(); }
  static const uint64_t static_value1 = 0x163a943a2132dce8ULL;
  static const uint64_t static_value2 = 0xf0610e78f5487c99ULL;
};

template
struct DataType >
{
  static const char* value()
  {
    return "ros_pantiltzoom_tardec/PTZ";
  }

  static const char* value(const ::ros_pantiltzoom_tardec::PTZ_&) { return value(); }
};

template
struct Definition >
{
  static const char* value()
  {
    return "std_msgs/Header header\n\
float32 pan\n\
float32 tilt\n\
float32 zoom\n\
\n\
================================================================================\n\
MSG: std_msgs/Header\n\
# Standard metadata for higher-level stamped data types.\n\
# This is generally used to communicate timestamped data \n\
# in a particular coordinate frame.\n\
# \n\
# sequence ID: consecutively increasing ID \n\
uint32 seq\n\
#Two-integer timestamp that is expressed as:\n\
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
# time-handling sugar is provided by the client library\n\
time stamp\n\
#Frame this data is associated with\n\
# 0: no frame\n\
# 1: global frame\n\
string frame_id\n\
";
  }

  static const char* value(const ::ros_pantiltzoom_tardec::PTZ_&) { return value(); }
};

} // namespace message_traits
} // namespace ros

namespace ros
{
namespace serialization
{

  template struct Serializer >
  {
    template inline static void allInOne(Stream& stream, T m)
    {
      stream.next(m.header);
      stream.next(m.pan);
      stream.next(m.tilt);
      stream.next(m.zoom);
    }

    ROS_DECLARE_ALLINONE_SERIALIZER;
  }; // struct PTZ_

} // namespace serialization
} // namespace ros

namespace ros
{
namespace message_operations
{

template
struct Printer >
{
  template static void stream(Stream& s, const std::string& indent, const ::ros_pantiltzoom_tardec::PTZ_& v)
  {
    s  >::stream(s, indent + "  ", v.header);
    s ::stream(s, indent + "  ", v.pan);
    s ::stream(s, indent + "  ", v.tilt);
    s ::stream(s, indent + "  ", v.zoom);
  }
};

} // namespace message_operations
} // namespace ros

#endif // ROS_PANTILTZOOM_TARDEC_MESSAGE_PTZ_H

Originally posted by Brenton on ROS Answers with karma: 1 on 2016-07-06

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The problem is that I can't generate any access methods to change them.

ROS messages don't use getters or setters. Instead, all fields are public (in C++ anyway), and you should set them as you would do any other variable (ie: my_msg.a.b.c = 3).


Originally posted by gvdhoorn with karma: 86574 on 2016-07-07

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.