Home > other >  Tap into the ROS send jpeg image failure?
Tap into the ROS send jpeg image failure?

Time:09-27

I bought a esp32 from taobao - CAM board, using ArduinoIDE development, compile time choice CAMERA_MODEL_AI_THINKER can well demonstrate CameraWebServer sample program,
I plan to put the esp32 - CAM camera images using ros message is sent to PC, ros pub news esp32 collapses, an error is as follows:
X4008f0e0 x3ffbe760 x32cd94a6 Backtrace: 0:0 0:0 x4008d9db x3ffbe780 0:0 x400900f1 x3ffbe7a0 0:0 x4008703a x3ffbe7c0 0:0 x400d10e6 x3ffbe7d0 0:0 x400d1c35 x3ffb1f40 0:0 x400d1fc6 x3ffb1f60 0:0 x400d47dd x3ffb1f90 0:0 x4008d8ed x3ffb1fb0 0:0 x3ffb1fd0
Ros side no error message,
Procedure is as follows:
# include "esp_camera. H"
#include
#include
//# include & lt; Sensor_msgs/Image. H>
#include
//# include & lt; Std_msgs/String. H>
#include
//# define CAMERA_MODEL_AI_THINKER
# define PWDN_GPIO_NUM 32
# define RESET_GPIO_NUM - 1
# define XCLK_GPIO_NUM 0
# define SIOD_GPIO_NUM 26
# define SIOC_GPIO_NUM 27

# define Y9_GPIO_NUM 35
# define Y8_GPIO_NUM 34
# define Y7_GPIO_NUM 39
# define Y6_GPIO_NUM 36
# define Y5_GPIO_NUM 21
# define Y4_GPIO_NUM 19
# define Y3_GPIO_NUM 18
# define Y2_GPIO_NUM 5
# define VSYNC_GPIO_NUM 25
# define HREF_GPIO_NUM 23
# define PCLK_GPIO_NUM 22
Camera_fb_t * fb;
Ros: : NodeHandle nh;

Sensor_msgs: : CompressedImage image_msg;
Ros: ublisher chatter (" image ", & amp; Image_msg, 1);

Const char * ssid="ssid";
Const char * password="mima";
//Set the rosserial socket server IP address
IPAddress server,1,168 (192168);
//Set the rosserial socket server port
Const uint16_t serverPort=11411;
//the control time
Uint16_t period=10000;//control shooting time
Uint32_t last_time=0;
Void setup ()
{
Serial.begin(115200);
//Serial. SetDebugOutput (true);
Serial. Println ();
//WiFi initialization
Serial. Print (WiFi "connecting");
WiFi. The begin (ssid, password);
While (WiFi. The status ().={WL_CONNECTED)
delay(500);
Serial. Print (". ");
}
Serial. Println (" ");
Serial. Println (" WiFi connected ");

//ros init
Nh. GetHardware () - & gt; SetConnection (server, serverPort);
Nh. InitNode ();
Nh. Advertise (chatter);
Serial. Println (" ROS connected. ");
//camera init
Camera_config_t config.
The config. Ledc_channel=LEDC_CHANNEL_0;
The config. Ledc_timer=LEDC_TIMER_0;
The config. Pin_d0=Y2_GPIO_NUM;
The config. Pin_d1=Y3_GPIO_NUM;
The config. Pin_d2=Y4_GPIO_NUM;
The config. Pin_d3=Y5_GPIO_NUM;
The config. Pin_d4=Y6_GPIO_NUM;
The config. Pin_d5=Y7_GPIO_NUM;
The config. Pin_d6=Y8_GPIO_NUM;
The config. Pin_d7=Y9_GPIO_NUM;
The config. Pin_xclk=XCLK_GPIO_NUM;
The config. Pin_pclk=PCLK_GPIO_NUM;
The config. Pin_vsync=VSYNC_GPIO_NUM;
The config. Pin_href=https://bbs.csdn.net/topics/HREF_GPIO_NUM;
The config. Pin_sscb_sda=SIOD_GPIO_NUM;
The config. Pin_sscb_scl=SIOC_GPIO_NUM;
The config. Pin_pwdn=PWDN_GPIO_NUM;
The config. Pin_reset=RESET_GPIO_NUM;
The config. Xclk_freq_hz=20000000;
The config. Pixel_format=PIXFORMAT_JPEG;//from jpeg bgr8 is corresponding?
//init with high specs to pre - the allocate larger buffers
If (psramFound ()) {
The config. Frame_size=FRAMESIZE_UXGA;
The config. Jpeg_quality=10;
The config. Fb_count=2;
} else {
The config. Frame_size=FRAMESIZE_SVGA;
The config. Jpeg_quality=12;
The config. Fb_count=1;
}

//camera init
Esp_err_t err=esp_camera_init (& amp; The config);
If (err!={ESP_OK)
Serial. Printf (" Camera init failed with error 0 x % x ", err);
return;
}
Sensor_t * s=esp_camera_sensor_get ();
//initial sensors are flipped vertically and colors are a bit saturated
If (s - & gt; Id. PID=={OV3660_PID)
s-> Set_vflip (s, 1);//flip it back
s-> Set_brightness (s, 1);//up the blightness just a bit
s-> Set_saturation (s, 2);//the lower the saturation
}
//drop down frame size for who initial frame rate
s-> Set_framesize (s, FRAMESIZE_QVGA);
Serial. Print (" Camera Ready!" );
}
Void loop ()
{

Esp_camera_fb_return (fb).//return the frame buffer back to be reused
If (millis () - last_time & gt;=period)
{
Last_time=millis ();
if (! Nh. Connected ())
{
Serial. Println (" ROS not Connected ");
}
//Say hello
Fb=esp_camera_fb_get ();
if (! Fb) {
Serial. Println (" Frame buffer could not be acquired ");
} else {
Serial. Println (" Sending Jpeg!" );
Image_msg. Format="jpeg";
Serial. Println (" format Jpeg ok!" );
Image_msg. Data_length=fb - & gt; Len.
Serial. Println (" data_lenth ok!" );
image_msg.data=https://bbs.csdn.net/topics/fb-> buf.
Serial. Println (" buffer ok!" );
Chatter. The publish (& amp; Image_msg);
//PC side to perform the following
//roscore
//rosrun rosserial_python serial_node. Py TCP
//rosrun image_view image_view image:=image check whether ros image transfer success;
Serial. Println (" JPEG is the send ");
nullnullnullnullnullnull
  • Related