鱼香社区

    • 登录
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    1. 主页
    2. 小丑汪

    重要提示

    社区建设靠大家,欢迎参与社区建设赞助计划
    提问前必看的发帖注意事项—— 提问的智慧
    社区使用指南—如何添加标签修改密码
    • 资料
    • 关注 0
    • 粉丝 0
    • 主题 7
    • 帖子 14
    • 最佳 2
    • 有争议的 0
    • 群组 0

    WOW995

    @小丑汪

    2
    声望
    1
    资料浏览
    14
    帖子
    0
    粉丝
    0
    关注
    注册时间 最后登录
    年龄 26

    小丑汪 取消关注 关注

    小丑汪 发布的最佳帖子

    • gazebo仿真模型沉到地下,ros-control不能控制车运行

      您好,我自己画了一个铲车的简化模型,是中间铰接转向的。在gazebo里面运行之后车的轮子沉到地下,车自己滑行偏转,怎么解决sendpix3.jpg

      下面是我的xacro文件:

      <?xml version="1.0" encoding="utf-8"?>
      
      <robot name="xul307a" xmlns:xacro="http://www.ros.org/wiki/xacro">
      
        <xacro:include filename="$(find velodyne_description)/urdf/HDL-32E.urdf.xacro"/>
        <xacro:include filename="$(find velodyne_description)/urdf/VLP-16.urdf.xacro"/>
      
        <link name="base_footprint">
              <visual>
                  <geometry>
                      <sphere radius="0.001" />
                  </geometry>
              </visual>
        </link>
      
        <link name="base_link">
          <inertial>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <mass value="4049.8" />
              <!-- <inertia
              ixx="7926.94"
              ixy="0"
              ixz="0"
              iyy="7723.8"
              iyz="0"
              izz="613.68" /> -->
            <inertia
              ixx="613.68"
              ixy="0"
              ixz="0"
              iyy="7723.8"
              iyz="0"
              izz="7926.94" />
          </inertial>
      
          <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
              <box size="4.72 0.78 1.1" />
            </geometry>
            <material name="">
              <color rgba="1 1 1 1" />
            </material>
          </visual>
      
          <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
              <box size="4.72 0.78 1.1" />
            </geometry>
          </collision>
        </link>
      
        <joint name="base_link2base_footprint" type="fixed">
            <parent link="base_footprint" />
            <child link="base_link"/>
            <origin xyz="0 0 1.067" />
        </joint>
      
      
      <link name="back_right_wheel">
          <inertial>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <mass value="639.613" />
            <inertia 
              ixx="87.55" 
              ixy="0.00" 
              ixz="0.00"
              iyy="87.55" 
              iyz="0.00" 
              izz="156.705" />
          </inertial>
      
          <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
            <material name="">
              <color rgba="1 1 1 1" />
            </material>
          </visual>
      
          <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
          </collision>
        </link>
      
        <joint
          name="back_right_wheel2base_link"
          type="continuous">
          <origin
            xyz="0.59665 -0.7504 -0.3671"
            rpy="1.5708 0 0" />
          <parent
            link="base_link" />
          <child
            link="back_right_wheel" />
          <axis
            xyz="0 0 -1" />
        </joint>
      
        <link
          name="back_left_wheel">
          <inertial>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <mass
              value="639.613" />
            <inertia
              ixx="87.55"
              ixy="0.00"
              ixz="0.00"
              iyy="87.55"
              iyz="0.00"
              izz="156.705" />
          </inertial>
          <visual>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
            <material
              name="">
              <color
                rgba="1 1 1 1" />
            </material>
          </visual>
          <collision>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
          </collision>
        </link>
      
        <joint
          name="back_left_wheel2base_link"
          type="continuous">
          <origin
            xyz="0.59665 0.7504 -0.3671"
            rpy="1.5707 0 -3.1416" />
          <parent
            link="base_link" />
          <child
            link="back_left_wheel" />
          <axis
            xyz="0 0 -1" />
        </joint>
      
        <link
          name="steering_hinge_link">
          <inertial>
            <origin
              xyz="2.127 0 0"
              rpy="0 0 0" />
            <mass
              value="2985.8" />
            <!-- <inertia
              ixx="3314.3"
              ixy="0"
              ixz="0"
              iyy="3164.6"
              iyz="0"
              izz="452.45" /> -->
              <inertia
              ixx="452.45"
              ixy="0"
              ixz="0"
              iyy="3314.3"
              iyz="0"
              izz="3164.6" /> 
          </inertial>
          <visual>
            <origin
              xyz="2.127 0 0"
              rpy="0 0 0" />
            <geometry>
              <box size="3.48 0.78 1.1" />
            </geometry>
            <material
              name="">
              <color
                rgba="1 1 1 1" />
            </material>
          </visual>
          <collision>
            <origin
              xyz="2.127 0 0"
              rpy="0 0 0" />
            <geometry>
              <box size="3.48 0.78 1.1" />
            </geometry>
          </collision>
        </link>
      
        <joint
          name="steering_hinge2base_link"
          type="revolute">
          <origin
            xyz="2.36 0 0"
            rpy="0 0 0" />
          <parent
            link="base_link" />
          <child
            link="steering_hinge_link" />
          <axis
            xyz="0 0 -1" />
          <limit
            lower="-0.74"
            upper="0.74"
            effort="0"
            velocity="0" />
        </joint>
      
        <link
          name="front_right_wheel">
          <inertial>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <mass
              value="639.613" />
            <inertia
              ixx="87.55"
              ixy="0.00"
              ixz="0.00"
              iyy="87.55"
              iyz="0.00"
              izz="156.705" />
          </inertial>
          <visual>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
            <material
              name="">
              <color
                rgba="1 1 1 1" />
            </material>
          </visual>
          <collision>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
          </collision>
        </link>
      
        <joint
          name="front_right_wheel2steering_hinge"
          type="continuous">
          <origin
            xyz="1.42 -0.75 -0.366"
            rpy="1.57 0 0" />
          <parent
            link="steering_hinge_link" />
          <child
            link="front_right_wheel" />
          <axis
            xyz="0 0 -1" />
        </joint>
        <link
          name="front_left_wheel">
          <inertial>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <mass
              value="639.613" />
            <inertia
              ixx="87.55"
              ixy="0.00"
              ixz="0.00"
              iyy="87.55"
              iyz="0.00"
              izz="156.705" />
          </inertial>
          <visual>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
            <material
              name="">
              <color
                rgba="1 1 1 1" />
            </material>
          </visual>
          <collision>
            <origin
              xyz="0 0 0"
              rpy="0 0 0" />
            <geometry>
              <cylinder radius="0.7" length="0.415" />
            </geometry>
          </collision>
        </link>
        <joint
          name="front_left_wheel2steering_hinge"
          type="continuous">
          <origin
            xyz="1.42 0.75 -0.366"
            rpy="1.57 0 -3.14" />
          <parent
            link="steering_hinge_link" />
          <child
            link="front_left_wheel" />
          <axis
            xyz="0 0 -1" />
        </joint>
      
        <VLP-16 parent="base_link" name="velodyne_front" topic="/velodyne_points_front" hz="10" samples="1801"  min_range="0.8" max_range="130.0" min_angle="-${M_PI}" max_angle="${M_PI}" >   
          <origin xyz="2.505 0 1.26" rpy="0 0 0" />    
        </VLP-16>
      
        <VLP-16 parent="base_link" name="velodyne_back" topic="/velodyne_points_back" hz="10" samples="1801"  min_range="0.8" max_range="130.0" min_angle="-${M_PI}" max_angle="${M_PI}" >   
          <origin xyz="-2.2056 0 0.7538" rpy="0 0 3.14" />    
        </VLP-16>
      
      
      <!-- motors and transmissions for the two rear wheels -->
        <transmission name="tran1">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="back_right_wheel2base_link">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          </joint>
          <actuator name="motor1">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission>  
      
        <transmission name="tran2">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="back_left_wheel2base_link">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          </joint>
          <actuator name="motor2">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission>  
      
        <!-- EPS and transmissions for the front steering -->
        <transmission name="tran3">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="steering_hinge2base_link">
            <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
          </joint>
          <actuator name="eps">
            <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
            <motorTorqueConstant>1000000</motorTorqueConstant>
          </actuator>
        </transmission>
      
      
        <!-- Friction Parametres -->
      
        <gazebo reference="back_right_wheel">
          <mu1>10000000</mu1>
          <mu2>10000000</mu2>
          <kp>10000000</kp>
          <kd>1</kd>
        </gazebo>  
      
        <gazebo reference="back_left_wheel">
          <mu1>10000000</mu1>
          <mu2>10000000</mu2>
          <kp>10000000</kp>
          <kd>1</kd>         
        </gazebo>   
      
        <gazebo reference="front_right_wheel">
          <mu1>10000000</mu1>
          <mu2>10000000</mu2>
          <kp>10000000</kp>
          <kd>1</kd>         
        </gazebo> 
      
        <gazebo reference="front_left_wheel">
          <mu1>10000000</mu1>
          <mu2>10000000</mu2>
          <kp>10000000</kp>
          <kd>1</kd>           
        </gazebo>    
      
        <!-- Gazebo Plugins -->
        <gazebo>
          <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/xul307a</robotNamespace>
            <robotParam>robot_description</robotParam>
            <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
            <!-- <legacyModeNS>true</legacyModeNS> -->
          </plugin>
        </gazebo>
      
        <gazebo>
          <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
            <jointName>back_right_wheel2base_link, back_left_wheel2base_link, steering_hinge2base_link,front_right_wheel2steering_hinge,front_left_wheel2steering_hinge</jointName>
            <updateRate>50.0</updateRate>
            <robotNamespace>/xul307a</robotNamespace>
            <alwaysOn>true</alwaysOn>
          </plugin>
        </gazebo>
      
      
      </robot>
      
      发布在 综合问题 gazebo ros
      小丑汪
      WOW995
    • RE: rviz显示marker不能实时更新

      @小鱼 抱歉,我的。我没写ros::spinOnce()

      发布在 综合问题
      小丑汪
      WOW995

    小丑汪 发布的最新帖子

    • 跑同一个bag,两个算法算法轨迹时间戳不一样,

      之前自己用ouster激光雷达录了一个包,分别跑了aloam和legoloam,然后保存了两个算法的轨迹,两个算法的轨迹时间戳不一样,但是我搭建了一个仿真环境,录了velodyne的包,跑算法时间戳一样.想用evo对比一下轨迹,但是时间戳不一样.
      ouster录的包跑ALOAM的时间戳如下:
      sendpix0.jpg
      ouster录的包跑legoLOAM轨迹时间戳如下
      sendpix1.jpg
      包播放的时间戳
      sendpix2.jpg

      发布在 综合问题 rosbag slam aloam legoloam
      小丑汪
      WOW995
    • 请教一下大家,有人用过mpc-tools-casadi吗?

      我从github上面下载了一个程序,按照readme安装了MPCTools,然后运行之后出现说mpctools里面没有'getCasadiFunc'这个函数,我按mpctools安装要求重新装了也不行,想请教一下大家怎么解决.

      Traceback (most recent call last):
        File "/home/github/articulated_ws/src/articulated_tractor_trailer_paper/articulated_tractor_trailer_trajectory/src/articulated_tractor_trailer_trajectory.py", line 247, in <module>
          start()
        File "/home/github/articulated_ws/src/articulated_tractor_trailer_paper/articulated_tractor_trailer_trajectory/src/articulated_tractor_trailer_trajectory.py", line 127, in start
          (controller, Nt, Delta) = export_articulated_tractor_trailer_model()
        File "/home/github/articulated_ws/src/articulated_tractor_trailer_paper/articulated_tractor_trailer_trajectory/src/export_articulated_tractor_trailer_model.py", line 59, in export_articulated_tractor_trailer_model
          ode_casadi = mpc.getCasadiFunc(ode_control_trailer, [Nx, Nu], ["x", "u"], funcname="f")
      AttributeError: module 'mpctools' has no attribute 'getCasadiFunc'
      
      
      [articulated_tractor_trailer_trajectory-5] process has died [pid 11460, exit code 1, cmd /home/github/articulated_ws/src/articulated_tractor_trailer_paper/articulated_tractor_trailer_trajectory/src/articulated_tractor_trailer_trajectory.py __name:=articulated_tractor_trailer_trajectory __log:=/home/.ros/log/3108ace8-6d2a-11ed-8666-d4548b799fd2/articulated_tractor_trailer_trajectory-5.log].
      log file: /home/.ros/log/3108ace8-6d2a-11ed-8666-d4548b799fd2/articulated_tractor_trailer_trajectory-5*.log
      
      
      发布在 综合问题 ros mpc
      小丑汪
      WOW995
    • gazebo仿真的时候转向怎么控制的顺滑

      我在进行铲车仿真的时候,控制转向角的时候模型反应比较慢,置0的时候不能回到0位,转向运动的时候模型发生抖动。各位大佬看看是什么原因

      <!-- motors and transmissions for the two rear wheels -->
        <transmission name="tran1">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="back_right_wheel2base_link">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          </joint>
          <actuator name="motor1">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission>  
      
        <transmission name="tran2">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="back_left_wheel2base_link">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          </joint>
          <actuator name="motor2">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission>  
      
        <!-- EPS and transmissions for the front steering -->
        <transmission name="tran3">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="steering_hinge2base_link">
            <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
          </joint>
          <actuator name="eps">
            <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission>
      
        <transmission name="tran4">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="front_right_wheel2steering_hinge">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          </joint>
          <actuator name="motor3">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission>  
      
        <transmission name="tran5">
          <type>transmission_interface/SimpleTransmission</type>
          <joint name="front_left_wheel2steering_hinge">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          </joint>
          <actuator name="motor4">
            <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
          </actuator>
        </transmission> 
      
      
        <!-- Friction Parametres -->
      
        <gazebo reference="back_right_wheel">
          <mu1>2.0</mu1>
          <mu2>2.0</mu2>
          <kp>10000000</kp>
          <kd>1</kd>
        </gazebo>  
      
        <gazebo reference="back_left_wheel">
          <mu1>2.0</mu1>
          <mu2>2.0</mu2>
          <kp>10000000</kp>
          <kd>1</kd>         
        </gazebo>   
      
        <gazebo reference="front_right_wheel">
          <mu1>2.0</mu1>
          <mu2>2.0</mu2>
          <kp>10000000</kp>
          <kd>1</kd>         
        </gazebo> 
      
        <gazebo reference="front_left_wheel">
          <mu1>2.0</mu1>
          <mu2>2.0</mu2>
          <kp>10000000</kp>
          <kd>1</kd>           
        </gazebo>   
      

      控制的ymal文件

      xul307a:
      # controls the rear two tires based on individual motors
        # Publish all joint states -----------------------------------
        joint_state_controller:
          type: joint_state_controller/JointStateController
          publish_rate: 50  
        back_right_velocity_controller:
          type: velocity_controllers/JointVelocityController
          joint: back_right_wheel2base_link
          pid: {p: 100.0, i: 0.01, d: 10.0}
        back_left_velocity_controller:
          type: velocity_controllers/JointVelocityController
          joint: back_left_wheel2base_link
          pid: {p: 100.0, i: 0.01, d: 10.0}
        steering_position_controller:
          type: effort_controllers/JointPositionController
          joint: steering_hinge2base_link
          pid: {p: 25000, i: 0, d: 10.0}
        front_right_velocity_controller:
          type: velocity_controllers/JointVelocityController
          joint: front_right_wheel2steering_hinge
          pid: {p: 100.0, i: 0.01, d: 10.0}
        front_left_velocity_controller:
          type: velocity_controllers/JointVelocityController
          joint: front_left_wheel2steering_hinge
          pid: {p: 100.0, i: 0.01, d: 10.0}    
      

      不能上传视频,我传到b站上去了
      链接文本
      链接文本

      发布在 综合问题 gazebo ros1
      小丑汪
      WOW995
    • RE: 使用OS0-128激光雷达跑ALOAM,怎么修改

      好的,谢谢大佬,我再看看

      发布在 综合问题
      小丑汪
      WOW995
    • 使用OS0-128激光雷达跑ALOAM,怎么修改

      我修改了launch文件和scanRegistration.cpp文件,没有跑成功。

      <launch>
          
          <param name="scan_line" type="int" value="128" />
      
          <!-- if 1, do mapping 10 Hz, if 2, do mapping 5 Hz. Suggest to use 1, it will adjust frequence automaticlly -->
          <param name="mapping_skip_frame" type="int" value="1" />
      
          <!-- remove too closed points -->
          <param name="minimum_range" type="double" value="5"/>
      
          <remap from="/velodyne_points" to="/os_cloud_node/points"/>
      
          <param name="mapping_line_resolution" type="double" value="0.4"/>
          <param name="mapping_plane_resolution" type="double" value="0.8"/>
      
          <node pkg="aloam_velodyne" type="ascanRegistration" name="ascanRegistration" output="screen" />
      
          <node pkg="aloam_velodyne" type="alaserOdometry" name="alaserOdometry" output="screen" />
      
          <node pkg="aloam_velodyne" type="alaserMapping" name="alaserMapping" output="screen" />
      
          <arg name="rviz" default="true" />
          <group if="$(arg rviz)">
              <node launch-prefix="nice" pkg="rviz" type="rviz" name="rviz" args="-d $(find aloam_velodyne)/rviz_cfg/aloam_velodyne.rviz" />
          </group>
      
      </launch>
      
          bool halfPassed = false;
          int count = cloudSize;
          PointType point;
          std::vector<pcl::PointCloud<PointType>> laserCloudScans(N_SCANS);
          for (int i = 0; i < cloudSize; i++)
          {
              point.x = laserCloudIn.points[i].x;
              point.y = laserCloudIn.points[i].y;
              point.z = laserCloudIn.points[i].z;
      
              float angle = atan(point.z / sqrt(point.x * point.x + point.y * point.y)) * 180 / M_PI;
              int scanID = 0;
      
              if (N_SCANS == 16)
              {
                  scanID = int((angle + 15) / 2 + 0.5);  //确定每一个点的scanID,与垂直角度有关,确定这个点属于那个scan
                  if (scanID > (N_SCANS - 1) || scanID < 0)  
                  {
                      count--;  //有效点减一
                      continue;
                  }
              }
              else if (N_SCANS == 32)
              {
                  scanID = int((angle + 92.0/3.0) * 3.0 / 4.0);
                  if (scanID > (N_SCANS - 1) || scanID < 0)
                  {
                      count--;
                      continue;
                  }
              }
              else if (N_SCANS == 64)
              {   
                  if (angle >= -8.83)
                      scanID = int((2 - angle) * 3.0 + 0.5);
                  else
                      scanID = N_SCANS / 2 + int((-8.83 - angle) * 2.0 + 0.5);
      
                  // use [0 50]  > 50 remove outlies 
                  if (angle > 2 || angle < -24.33 || scanID > 50 || scanID < 0)
                  {
                      count--;
                      continue;
                  }
              }
              else if (N_SCANS == 128)
              {
                  scanID = int((angle + 45) / 2 + 0.5);  
                  if (scanID > (N_SCANS - 1) || scanID < 0)  
                  {
                      count--;  
                      continue;
                  }
              }
              else
              {
                  printf("wrong scan number\n");
                  ROS_BREAK();
              }
              //printf("angle %f scanID %d \n", angle, scanID);
      
              float ori = -atan2(point.y, point.x);
              if (!halfPassed)
              { 
                  if (ori < startOri - M_PI / 2)
                  {
                      ori += 2 * M_PI;
                  }
                  else if (ori > startOri + M_PI * 3 / 2)
                  {
                      ori -= 2 * M_PI;
                  }
      
                  if (ori - startOri > M_PI)
                  {
                      halfPassed = true;
                  }
              }
              else
              {
                  ori += 2 * M_PI;
                  if (ori < endOri - M_PI * 3 / 2)
                  {
                      ori += 2 * M_PI;
                  }
                  else if (ori > endOri + M_PI / 2)
                  {
                      ori -= 2 * M_PI;
                  }
              }
      
              float relTime = (ori - startOri) / (endOri - startOri);
              point.intensity = scanID + scanPeriod * relTime;// intensity字段的整数部分存放scanID,小数部分存放归一化后的fireID
              laserCloudScans[scanID].push_back(point); // 将点根据scanID放到对应的子点云laserCloudScans中
          }
      

      主要修改了launch文件里面的线数,和更改了话题,scanRegistration.cpp文件里面按照16线的格式增加了128线的scanID。

      发布在 综合问题 ros slam aloam
      小丑汪
      WOW995
    • RE: rviz显示marker不能实时更新

      @小鱼 抱歉,我的。我没写ros::spinOnce()

      发布在 综合问题
      小丑汪
      WOW995
    • RE: rviz显示marker不能实时更新

      @小鱼 您好,我在回调函数和下面的ros::ok里面都打印输出了,回调函数没有调用,没有打印输出。我看了订阅和回调写的好像没什么问题

      发布在 综合问题
      小丑汪
      WOW995
    • RE: rviz显示marker不能实时更新

      @小鱼 您好,我看了订阅的/aft_mapped_to_init和marker的话题/robot_marker,/aft_mapped_to_init数据是在更新的,/robot_marker数据一直没变。
      topic.jpg
      sendpix1.jpg

      发布在 综合问题
      小丑汪
      WOW995
    • RE: rviz显示marker不能实时更新

      @小丑汪 图片没有传上去
      20220718.jpg

      发布在 综合问题
      小丑汪
      WOW995
    • rviz显示marker不能实时更新

      各位大佬,我想在保存的pcd地图里面用marker显示机器人的位置,我订阅了机器人的坐标形象,但是机器人移动位置变化后,marker位置不变,一直在初始位置;marker不能随机器人移动而更新,希望有了解的大佬帮忙解答一下。

      #include <ros/ros.h>
      #include <visualization_msgs/Marker.h>
      #include <nav_msgs/Odometry.h>
      
      #include <geometry_msgs/Point.h>
      
      double temp_x,temp_y,temp_z;
      double temp_or_x,temp_or_y,temp_or_z,temp_or_w;
      
      void record_point(const nav_msgs::Odometry::ConstPtr& odom)
      {
          temp_x = odom->pose.pose.position.x;
          temp_y = odom->pose.pose.position.y;
          temp_z = odom->pose.pose.position.z;
          temp_or_w = odom->pose.pose.orientation.w;
          temp_or_x = odom->pose.pose.orientation.x;
          temp_or_y = odom->pose.pose.orientation.y;
          temp_or_z = odom->pose.pose.orientation.z;
          
      }
       
      int main( int argc, char** argv )
      {
        ros::init(argc, argv, "points_marker");
        ros::NodeHandle n;
        ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("/robot_marker", 10);
        ros::Subscriber odom_pose = n.subscribe<nav_msgs::Odometry>("/aft_mapped_to_init",100,record_point);
        visualization_msgs::Marker points_marker;
      
        ros::Rate r(30);
       
        while (ros::ok())
        {
       
      
          points_marker.header.frame_id ="/camera_init";
          points_marker.header.stamp =ros::Time::now();
          points_marker.ns ="points_marker";
          points_marker.action =visualization_msgs::Marker::ADD;
          points_marker.id = 0;
          points_marker.type = visualization_msgs::Marker::POINTS;
          geometry_msgs::Point obj;
          obj.x = temp_x;
          obj.y = temp_y;
          obj.z = temp_z;
          points_marker.pose.orientation.w = 1;
      
       
          // points_marker markers use x and y scale for width/height respectively
          points_marker.scale.x = 1;
          points_marker.scale.y = 1;
          points_marker.scale.z = 1;
      
          // points_marker are green
          points_marker.color.r = 0.0f;
          points_marker.color.g = 1.0f;
          points_marker.color.b = 0.0f;
          points_marker.color.a = 1.0f;
          points_marker.points.push_back(obj);
       
          points_marker.lifetime = ros::Duration(0.1); // 生命周期
      
          marker_pub.publish(points_marker);
       
          r.sleep();
      
        }
      }
      ![20220718.jpg](/forum/assets/uploads/files/1658153571513-20220718-resized.jpg)
      发布在 综合问题 rviz marker
      小丑汪
      WOW995