TorBorve / mpc_local_planner

A nonlinear MPC used to control an autonomous car.
MIT License
41 stars 9 forks source link

Use Twist or Odom #7

Open TorBorve opened 1 year ago

TorBorve commented 1 year ago

Choose between using twist and odom topics

tl123987 commented 1 year ago

图片

this is normal? it need input?

tl123987 commented 1 year ago

图片

TorBorve commented 1 year ago

Hi,

Yes it is normal to get the "Waiting for twist message..." if a twist topic is not provided to the mpc. Make sure that there is a active twist topic and that the topic name is the same as in the .yaml file used to load params.

In the second case you run the program using ros2 run this will not work since the code expects to be provided with parameters. Therefore, you should run the program using ros2 launch. Please see documentation.

Hope this helps!

tl123987 commented 1 year ago

图片 I ran this launch file. There should be data in this global path topic, but I did not find the data in rviz.should l do something others

TorBorve commented 1 year ago

If you still have the warning "waiting for twist message" in the console this is expected. The mpc is unable to start running without having information about the velocity of the car. This is given using a twist topic. Please make sure that ros2 topic echo <your_twist_topic> prints valid data.

tl123987 commented 1 year ago

l tried

tl123987 commented 1 year ago

图片 I defined a topic data myself, but there is still no data

tl123987 commented 1 year ago

图片 is there something wrong with my code

tl123987 commented 1 year ago

Is this test data invalid?

TorBorve commented 1 year ago

Even if that works the data the mpc gets does not make sense since it will be the same no matter what it does. You should not publish data that is not from a simulator or real world sensors.

I recommend using this simulator to test the mpc. This is what I have been using myself. I recommend using the single_vehicle_example.launch file when running the simulator. Make sure you use the ros2 branch of audibot. What you would do is first run ros2 launch audibot_gazebo single_vehicle_example.launch.py, and then run ros2 launch mpc_local_planner mpc.launch.py in a different terminal.

tl123987 commented 1 year ago

图片

tl123987 commented 1 year ago

strangeness

TorBorve commented 1 year ago

Seems like there is something wrong with loading the xacro files. Please search on the internet for solutions and refere to the issue on the audibot github. Make sure you have followed the necessary steps to set up gazebo with ros2.

I believe I also had this problem, however I can't seem to remember how I fixed it. Please check that ros-humble-xacro is installed on your system. This can be installed using sudo apt install ros-humble-xacro Change "humble" to whatever ros2 version you are running.

tl123987 commented 1 year ago

l tried,another question arises,thanks for you answer 图片

TorBorve commented 1 year ago

I'm not sure if this is a big problem. Perhaps you can ignore the warnings. Please do one step at a time. First make sure that the audibot simulator works. You can do this by running the launch file and checking that the car shows up in the simulator. You can also check if the car move by manually publishing a throttle command using ros2 topic pub /throttle_cmd example_interfaces/msg/Float64 "data: 1.0". If this works then you can move on to testing the mpc. You do this by closing audibot and rerunning it and then running the mpc launch file. Hope this helps.

tl123987 commented 1 year ago

it was a big problem , 图片

tl123987 commented 1 year ago

the car can not move,Is it related to the version?

tl123987 commented 1 year ago

l give up.thanks a lot