Ask Your Question
0

Generating getter and setter methods for simple custom message

asked 2016-07-06 13:08:57 -0500

Brenton gravatar image

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 <string>
#include <vector>
#include <map>

#include <ros types.h="">
#include <ros serialization.h="">
#include <ros builtin_message_traits.h="">
#include <ros message_operations.h="">

#include <std_msgs header.h="">

namespace ros_pantiltzoom_tardec
{
template <class containerallocator="">
struct PTZ_
{
  typedef PTZ_<containerallocator> 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_<containerallocator>  _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< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> > Ptr;
  typedef boost::shared_ptr< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> const> ConstPtr;

}; // struct PTZ_

typedef ::ros_pantiltzoom_tardec::PTZ_<std::allocator<void> > PTZ;

typedef boost::shared_ptr< ::ros_pantiltzoom_tardec::PTZ > PTZPtr;
typedef boost::shared_ptr< ::ros_pantiltzoom_tardec::PTZ const> PTZConstPtr;

// constants requiring out of line definition



template<typename containerallocator="">
std::ostream& operator<<(std::ostream& s, const ::ros_pantiltzoom_tardec::PTZ_<containerallocator> & v)
{
ros::message_operations::Printer< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >::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 <class containerallocator="">
struct IsFixedSize< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >
  : FalseType
  { };

template <class containerallocator="">
struct IsFixedSize< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> const>
  : FalseType
  { };

template <class containerallocator="">
struct IsMessage< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >
  : TrueType
  { };

template <class containerallocator="">
struct IsMessage< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> const>
  : TrueType
  { };

template <class containerallocator="">
struct HasHeader< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >
  : TrueType
  { };

template <class containerallocator="">
struct HasHeader< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> const>
  : TrueType
  { };


template<class containerallocator="">
struct MD5Sum< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >
{
  static const char* value()
  {
    return "163a943a2132dce8f0610e78f5487c99";
  }

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

template<class containerallocator="">
struct DataType< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >
{
  static const char* value()
  {
    return "ros_pantiltzoom_tardec/PTZ";
  }

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

template<class containerallocator="">
struct Definition< ::ros_pantiltzoom_tardec::PTZ_<containerallocator> >
{
  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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-07 01:54:20 -0500

gvdhoorn gravatar image

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).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-07-06 13:08:16 -0500

Seen: 159 times

Last updated: Jul 07 '16