catchrobo2022 mbed LPC1768 メインプログラム

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CameraPlacement.h Source File

CameraPlacement.h

00001 #ifndef _ROS_view_controller_msgs_CameraPlacement_h
00002 #define _ROS_view_controller_msgs_CameraPlacement_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "ros/duration.h"
00009 #include "geometry_msgs/PointStamped.h"
00010 #include "geometry_msgs/Vector3Stamped.h"
00011 
00012 namespace view_controller_msgs
00013 {
00014 
00015   class CameraPlacement : public ros::Msg
00016   {
00017     public:
00018       typedef uint8_t _interpolation_mode_type;
00019       _interpolation_mode_type interpolation_mode;
00020       typedef const char* _target_frame_type;
00021       _target_frame_type target_frame;
00022       typedef ros::Duration _time_from_start_type;
00023       _time_from_start_type time_from_start;
00024       typedef geometry_msgs::PointStamped _eye_type;
00025       _eye_type eye;
00026       typedef geometry_msgs::PointStamped _focus_type;
00027       _focus_type focus;
00028       typedef geometry_msgs::Vector3Stamped _up_type;
00029       _up_type up;
00030       typedef uint8_t _mouse_interaction_mode_type;
00031       _mouse_interaction_mode_type mouse_interaction_mode;
00032       typedef bool _interaction_disabled_type;
00033       _interaction_disabled_type interaction_disabled;
00034       typedef bool _allow_free_yaw_axis_type;
00035       _allow_free_yaw_axis_type allow_free_yaw_axis;
00036       enum { LINEAR =  0  };
00037       enum { SPHERICAL =  1  };
00038       enum { NO_CHANGE =  0  };
00039       enum { ORBIT =  1  };
00040       enum { FPS =  2  };
00041 
00042     CameraPlacement():
00043       interpolation_mode(0),
00044       target_frame(""),
00045       time_from_start(),
00046       eye(),
00047       focus(),
00048       up(),
00049       mouse_interaction_mode(0),
00050       interaction_disabled(0),
00051       allow_free_yaw_axis(0)
00052     {
00053     }
00054 
00055     virtual int serialize(unsigned char *outbuffer) const
00056     {
00057       int offset = 0;
00058       *(outbuffer + offset + 0) = (this->interpolation_mode >> (8 * 0)) & 0xFF;
00059       offset += sizeof(this->interpolation_mode);
00060       uint32_t length_target_frame = strlen(this->target_frame);
00061       varToArr(outbuffer + offset, length_target_frame);
00062       offset += 4;
00063       memcpy(outbuffer + offset, this->target_frame, length_target_frame);
00064       offset += length_target_frame;
00065       *(outbuffer + offset + 0) = (this->time_from_start.sec >> (8 * 0)) & 0xFF;
00066       *(outbuffer + offset + 1) = (this->time_from_start.sec >> (8 * 1)) & 0xFF;
00067       *(outbuffer + offset + 2) = (this->time_from_start.sec >> (8 * 2)) & 0xFF;
00068       *(outbuffer + offset + 3) = (this->time_from_start.sec >> (8 * 3)) & 0xFF;
00069       offset += sizeof(this->time_from_start.sec);
00070       *(outbuffer + offset + 0) = (this->time_from_start.nsec >> (8 * 0)) & 0xFF;
00071       *(outbuffer + offset + 1) = (this->time_from_start.nsec >> (8 * 1)) & 0xFF;
00072       *(outbuffer + offset + 2) = (this->time_from_start.nsec >> (8 * 2)) & 0xFF;
00073       *(outbuffer + offset + 3) = (this->time_from_start.nsec >> (8 * 3)) & 0xFF;
00074       offset += sizeof(this->time_from_start.nsec);
00075       offset += this->eye.serialize(outbuffer + offset);
00076       offset += this->focus.serialize(outbuffer + offset);
00077       offset += this->up.serialize(outbuffer + offset);
00078       *(outbuffer + offset + 0) = (this->mouse_interaction_mode >> (8 * 0)) & 0xFF;
00079       offset += sizeof(this->mouse_interaction_mode);
00080       union {
00081         bool real;
00082         uint8_t base;
00083       } u_interaction_disabled;
00084       u_interaction_disabled.real = this->interaction_disabled;
00085       *(outbuffer + offset + 0) = (u_interaction_disabled.base >> (8 * 0)) & 0xFF;
00086       offset += sizeof(this->interaction_disabled);
00087       union {
00088         bool real;
00089         uint8_t base;
00090       } u_allow_free_yaw_axis;
00091       u_allow_free_yaw_axis.real = this->allow_free_yaw_axis;
00092       *(outbuffer + offset + 0) = (u_allow_free_yaw_axis.base >> (8 * 0)) & 0xFF;
00093       offset += sizeof(this->allow_free_yaw_axis);
00094       return offset;
00095     }
00096 
00097     virtual int deserialize(unsigned char *inbuffer)
00098     {
00099       int offset = 0;
00100       this->interpolation_mode =  ((uint8_t) (*(inbuffer + offset)));
00101       offset += sizeof(this->interpolation_mode);
00102       uint32_t length_target_frame;
00103       arrToVar(length_target_frame, (inbuffer + offset));
00104       offset += 4;
00105       for(unsigned int k= offset; k< offset+length_target_frame; ++k){
00106           inbuffer[k-1]=inbuffer[k];
00107       }
00108       inbuffer[offset+length_target_frame-1]=0;
00109       this->target_frame = (char *)(inbuffer + offset-1);
00110       offset += length_target_frame;
00111       this->time_from_start.sec =  ((uint32_t) (*(inbuffer + offset)));
00112       this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00113       this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00114       this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00115       offset += sizeof(this->time_from_start.sec);
00116       this->time_from_start.nsec =  ((uint32_t) (*(inbuffer + offset)));
00117       this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00118       this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00119       this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00120       offset += sizeof(this->time_from_start.nsec);
00121       offset += this->eye.deserialize(inbuffer + offset);
00122       offset += this->focus.deserialize(inbuffer + offset);
00123       offset += this->up.deserialize(inbuffer + offset);
00124       this->mouse_interaction_mode =  ((uint8_t) (*(inbuffer + offset)));
00125       offset += sizeof(this->mouse_interaction_mode);
00126       union {
00127         bool real;
00128         uint8_t base;
00129       } u_interaction_disabled;
00130       u_interaction_disabled.base = 0;
00131       u_interaction_disabled.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00132       this->interaction_disabled = u_interaction_disabled.real;
00133       offset += sizeof(this->interaction_disabled);
00134       union {
00135         bool real;
00136         uint8_t base;
00137       } u_allow_free_yaw_axis;
00138       u_allow_free_yaw_axis.base = 0;
00139       u_allow_free_yaw_axis.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00140       this->allow_free_yaw_axis = u_allow_free_yaw_axis.real;
00141       offset += sizeof(this->allow_free_yaw_axis);
00142      return offset;
00143     }
00144 
00145     virtual const char * getType(){ return "view_controller_msgs/CameraPlacement"; };
00146     virtual const char * getMD5(){ return "38be6efe15caa86e2c835dd05ab88393"; };
00147 
00148   };
00149 
00150 }
00151 #endif