arr_find.cpp

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #ifdef __BCPLUSPLUS__
#include <iostream.h>
#include <algorith.h>
#else
#include <iostream>
#include <algorithm>
#endif

using namespace std ;

void main(void)
 {
   const int ARRAY_SIZE = 8;
   int IntArray[ARRAY_SIZE] = { 1, 2, 3, 4, 4, 5, 6, 7 };
   int *location ; //stores the position of the first matching element.
   int i;
   int value = 4;

   // print content of IntArray
   cout << "IntArray { ";
   for (i = 0; i < ARRAY_SIZE; i++)
    cout << IntArray[i] << ", ";
   cout << " }" << endl;

   //Find the first element in the range (first, last + 1)
   //that matches value.
   location = find(IntArray, IntArray + ARRAY_SIZE, value);
  
   //print the matching element if any was found
   if (location != IntArray + ARRAY_SIZE) //matching element found
    cout << "First element that matches " << value << " is at location "
    << (location - IntArray) << endl;
   else          // no matching element found
    cout << "The sequence does not contain any elements with value " << value << endl;
}

 

 

wjs@wjs-desktop:~/Drone_Slam$ ros2 launch fishbot_grapher test_grapher_6.launch.py [INFO] [launch]: All log files can be found below /home/wjs/.ros/log/2025-08-01-00-35-21-205680-wjs-desktop-2879 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [sllidar_node-1]: process started with pid [2882] [INFO] [ahrs_driver_node-2]: process started with pid [2884] [INFO] [static_transform_publisher-3]: process started with pid [2886] [INFO] [robot_state_publisher-4]: process started with pid [2888] [INFO] [cartographer_node-5]: process started with pid [2890] [INFO] [cartographer_occupancy_grid_node-6]: process started with pid [2894] [INFO] [test01-7]: process started with pid [2902] [static_transform_publisher-3] [WARN] [1753979721.537040397] []: Old-style arguments are deprecated; see --help for new-style arguments [sllidar_node-1] [INFO] [1753979721.758057445] [sllidar_node]: SLLidar running on ROS2 package SLLidar.ROS2 SDK Version:1.0.1, SLLIDAR SDK Version:2.0.0 [sllidar_node-1] [INFO] [1753979721.806444401] [sllidar_node]: SLLidar S/N: 7885EC95C1EA9ED1B2E49CF4FB594571 [sllidar_node-1] [INFO] [1753979721.806628793] [sllidar_node]: Firmware Ver: 1.01 [sllidar_node-1] [INFO] [1753979721.806682875] [sllidar_node]: Hardware Rev: 18 [sllidar_node-1] [INFO] [1753979721.858743833] [sllidar_node]: SLLidar health status : 0 [sllidar_node-1] [INFO] [1753979721.858900064] [sllidar_node]: SLLidar health status : OK. [sllidar_node-1] [INFO] [1753979722.089228500] [sllidar_node]: current scan mode: DenseBoost, sample rate: 32 Khz, max_distance: 18.0 m, scan frequency:10.0 Hz, [cartographer_node-5] [INFO] [1753979722.285159294] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/home/wjs/Drone_Slam/install/fishbot_grapher/share/fishbot_grapher/config/fishbot_2d.lua' for 'fishbot_2d.lua'. [cartographer_node-5] [INFO] [1753979722.316376894] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'. [cartographer_node-5] [INFO] [1753979722.316734830] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'. [cartographer_node-5] [INFO] [1753979722.317209060] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'. [cartographer_node-5] [INFO] [1753979722.317477826] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'. [cartographer_node-5] [INFO] [1753979722.318294347] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'. [cartographer_node-5] [INFO] [1753979722.318567575] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'. [cartographer_node-5] [INFO] [1753979722.335346971] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'. [cartographer_node-5] [INFO] [1753979722.335619015] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'. [cartographer_node-5] [INFO] [1753979722.336400726] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'. [cartographer_node-5] [INFO] [1753979722.336697858] [cartographer logger]: I0801 00:35:22.000000 2890 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'. [static_transform_publisher-3] [INFO] [1753979722.387448415] [imu_tf_publisher]: Spinning until stopped - publishing transform [static_transform_publisher-3] translation: ('0.000000', '0.000000', '0.000000') [static_transform_publisher-3] rotation: ('0.000000', '0.000000', '0.000000', '1.000000') [static_transform_publisher-3] from 'base_link' to 'imu_link' [ahrs_driver_node-2] [INFO] [1753979722.599184780] [ahrs_bringup]: Serial Port initialized [ahrs_driver_node-2] [INFO] [1753979722.599712426] [ahrs_bringup]: ahrsBringup::processLoop: start [ahrs_driver_node-2] terminate called after throwing an instance of 'serial::SerialException' [ahrs_driver_node-2] what(): SerialException device reports readiness to read but returned no data (device disconnected?) failed. [robot_state_publisher-4] [INFO] [1753979722.692730637] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1753979722.693155486] [robot_state_publisher]: got segment imu_link [robot_state_publisher-4] [INFO] [1753979722.693285778] [robot_state_publisher]: got segment laser_link [cartographer_node-5] [INFO] [1753979722.875068815] [cartographer logger]: I0801 00:35:22.000000 2890 map_builder_bridge.cpp:136] Added trajectory with ID '0'. [ERROR] [ahrs_driver_node-2]: process has died [pid 2884, exit code -6, cmd '/home/wjs/Drone_Slam/install/fdilink_ahrs/lib/fdilink_ahrs/ahrs_driver_node --ros-args --params-file /tmp/launch_params_ccuxsgpz']. [cartographer_node-5] [INFO] [1753979723.981995571] [cartographer logger]: I0801 00:35:23.000000 2890 ordered_multi_queue.cc:172] All sensor data for trajectory 0 is available starting at '638895765239747368'. [cartographer_node-5] [INFO] [1753979723.982265376] [cartographer logger]: I0801 00:35:23.000000 2890 local_trajectory_builder_2d.cc:135] Extrapolator is still initializing. [cartographer_node-5] [INFO] [1753979724.080317557] [cartographer logger]: I0801 00:35:24.000000 2890 pose_graph_2d.cc:148] Inserted submap (0, 0). [cartographer_node-5] [WARN] [1753979724.286147835] [cartographer logger]: W0801 00:35:24.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [test01-7] Traceback (most recent call last): [test01-7] File "/home/wjs/.local/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open [test01-7] self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK) [test01-7] FileNotFoundError: [Errno 2] No such file or directory: '/dev/esp' [test01-7] [test01-7] During handling of the above exception, another exception occurred: [test01-7] [test01-7] Traceback (most recent call last): [test01-7] File "/home/wjs/Drone_Slam/install/fishbot_grapher/lib/fishbot_grapher/test01", line 33, in <module> [test01-7] sys.exit(load_entry_point('fishbot-grapher==0.0.0', 'console_scripts', 'test01')()) [test01-7] File "/home/wjs/Drone_Slam/install/fishbot_grapher/lib/python3.10/site-packages/fishbot_grapher/test01.py", line 101, in main [test01-7] tf_subscriber = TFSubscriber() [test01-7] File "/home/wjs/Drone_Slam/install/fishbot_grapher/lib/python3.10/site-packages/fishbot_grapher/test01.py", line 20, in __init__ [test01-7] self.ser = serial.Serial("/dev/esp", 115200) [test01-7] File "/home/wjs/.local/lib/python3.10/site-packages/serial/serialutil.py", line 244, in __init__ [test01-7] self.open() [test01-7] File "/home/wjs/.local/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open [test01-7] raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg)) [test01-7] serial.serialutil.SerialException: [Errno 2] could not open port /dev/esp: [Errno 2] No such file or directory: '/dev/esp' [cartographer_node-5] [WARN] [1753979724.491526002] [cartographer logger]: W0801 00:35:24.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979724.709295995] [cartographer logger]: W0801 00:35:24.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [ERROR] [test01-7]: process has died [pid 2902, exit code 1, cmd '/home/wjs/Drone_Slam/install/fishbot_grapher/lib/fishbot_grapher/test01 --ros-args']. [cartographer_node-5] [WARN] [1753979724.926728636] [cartographer logger]: W0801 00:35:24.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979725.135525279] [cartographer logger]: W0801 00:35:25.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979725.355498538] [cartographer logger]: W0801 00:35:25.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979725.575934667] [cartographer logger]: W0801 00:35:25.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979725.791681973] [cartographer logger]: W0801 00:35:25.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979725.792889539] [cartographer logger]: W0801 00:35:25.000000 2890 range_data_collator.cc:82] Dropped 154 earlier points. [cartographer_node-5] [WARN] [1753979726.009195591] [cartographer logger]: W0801 00:35:26.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979726.010459952] [cartographer logger]: W0801 00:35:26.000000 2890 range_data_collator.cc:82] Dropped 532 earlier points. [cartographer_node-5] [WARN] [1753979726.220309676] [cartographer logger]: W0801 00:35:26.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979726.437783320] [cartographer logger]: W0801 00:35:26.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979726.439136426] [cartographer logger]: W0801 00:35:26.000000 2890 range_data_collator.cc:82] Dropped 542 earlier points. [cartographer_node-5] [WARN] [1753979726.649371795] [cartographer logger]: W0801 00:35:26.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979726.857038597] [cartographer logger]: W0801 00:35:26.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [WARN] [1753979727.064830761] [cartographer logger]: W0801 00:35:27.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [robot_state_publisher-4] [INFO] [1753979727.252864090] [rclcpp]: signal_handler(signum=2) [static_transform_publisher-3] [INFO] [1753979727.252895586] [rclcpp]: signal_handler(signum=2) [cartographer_occupancy_grid_node-6] [INFO] [1753979727.252922415] [rclcpp]: signal_handler(signum=2) [cartographer_node-5] [INFO] [1753979727.254331207] [rclcpp]: signal_handler(signum=2) [cartographer_node-5] [WARN] [1753979727.278186754] [cartographer logger]: W0801 00:35:27.000000 2890 tf_bridge.cpp:53] "odom" passed to lookupTransform argument source_frame does not exist. [cartographer_node-5] [INFO] [1753979727.299298707] [cartographer logger]: I0801 00:35:27.000000 2890 node.cpp:569] Shutdown the subscriber of [scan] [cartographer_node-5] [INFO] [1753979727.299538745] [cartographer logger]: I0801 00:35:27.000000 2890 map_builder_bridge.cpp:152] Finishing trajectory with ID '0'... [cartographer_node-5] [WARN] [1753979727.299999084] [cartographer logger]: W0801 00:35:27.000000 2890 node.cpp:773] Can't run final optimization if there are one or more active trajectories. Trying to finish trajectory with ID 0 now. [cartographer_node-5] [INFO] [1753979727.300107494] [cartographer logger]: I0801 00:35:27.000000 2890 node.cpp:551] Trajectory 0 already pending to finish. [cartographer_node-5] [INFO] [1753979727.300154006] [cartographer logger]: I0801 00:35:27.000000 2890 map_builder_bridge.cpp:161] Running final trajectory optimization... [cartographer_node-5] [INFO] [1753979727.300265082] [cartographer logger]: I0801 00:35:27.000000 2953 pose_graph_2d.cc:538] Remaining work items in queue: 0 [cartographer_node-5] [INFO] [1753979727.300400284] [cartographer logger]: I0801 00:35:27.000000 2953 constraint_builder_2d.cc:290] 0 computations resulted in 0 additional constraints. [cartographer_node-5] [INFO] [1753979727.300446870] [cartographer logger]: I0801 00:35:27.000000 2953 constraint_builder_2d.cc:292] Score histogram: [cartographer_node-5] Count: 0 [cartographer_node-5] [WARN] [1753979727.308865144] [cartographer logger]: W0801 00:35:27.000000 2953 preprocessor.cc:62] Specified options.num_threads: 7 exceeds maximum available from the threading model Ceres was compiled with: 4. Bounding to maximum number available. [cartographer_node-5] [INFO] [1753979727.321944840] [cartographer logger]: I0801 00:35:27.000000 2953 pose_graph_2d.cc:538] Remaining work items in queue: 1 [cartographer_node-5] [INFO] [1753979727.322111019] [cartographer logger]: I0801 00:35:27.000000 2953 constraint_builder_2d.cc:290] 0 computations resulted in 0 additional constraints. [cartographer_node-5] [INFO] [1753979727.322155142] [cartographer logger]: I0801 00:35:27.000000 2953 constraint_builder_2d.cc:292] Score histogram: [cartographer_node-5] Count: 0 [cartographer_node-5] [WARN] [1753979727.323773588] [cartographer logger]: W0801 00:35:27.000000 2953 preprocessor.cc:62] Specified options.num_threads: 7 exceeds maximum available from the threading model Ceres was compiled with: 4. Bounding to maximum number available. [cartographer_node-5] [INFO] [1753979727.356344069] [cartographer logger]: I0801 00:35:27.000000 2954 constraint_builder_2d.cc:290] 0 computations resulted in 0 additional constraints. [cartographer_node-5] [INFO] [1753979727.356515895] [cartographer logger]: I0801 00:35:27.000000 2954 constraint_builder_2d.cc:292] Score histogram: [cartographer_node-5] Count: 0 Optimizing: Done. [cartographer_node-5] [INFO] [1753979727.441603445] [cartographer logger]: I0801 00:35:27.000000 2952 constraint_builder_2d.cc:290] 0 computations resulted in 0 additional constraints. [cartographer_node-5] [INFO] [1753979727.441713595] [cartographer logger]: I0801 00:35:27.000000 2952 constraint_builder_2d.cc:292] Score histogram: [cartographer_node-5] Count: 0 Optimizing: Done. [INFO] [static_transform_publisher-3]: process has finished cleanly [pid 2886] [INFO] [cartographer_occupancy_grid_node-6]: process has finished cleanly [pid 2894] [INFO] [robot_state_publisher-4]: process has finished cleanly [pid 2888] [INFO] [cartographer_node-5]: process has finished cleanly [pid 2890] [sllidar_node-1] [INFO] [1753979727.674903693] [sllidar_node]: Stop motor [INFO] [sllidar_node-1]: process has finished cleanly [pid 2882] wjs@wjs-desktop:~/Drone_Slam$
最新发布
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值