lgsvl / simulator

A ROS/ROS2 Multi-robot Simulator for Autonomous Vehicles
Other
2.29k stars 780 forks source link

How can I publish constant throttle to SVL with ROS2 #1404

Open nitesh4146 opened 3 years ago

nitesh4146 commented 3 years ago

Hi,

I am trying to drive the vehicle at constant speed. I tried publishing VehicleControlData msg on /lanefollowing/steering_cmd topic as following -

message = VehicleControlData()
message.header = header
message.target_gear = message.GEAR_DRIVE
message.acceleration_pct = 1.0

However, it doesn't seem to work. The steering values are published but not throttle/acceleration. What am I missing here? FYI- I am working on the lanefollowing image.

Thanks in advance!

t0ny-peng commented 3 years ago

You need to publish it at a constant rate, 100Hz maybe? (need clarification from LGSVL simulators developers).

In addition, constant throttle != constant speed.

nitesh4146 commented 3 years ago

Sure,but if I can understand how to publish throttle values I might as well be able to figure out constant speed. I couldn't find anything in documentation on how to control the throttle with a ROS/ROS2 node. I know how to do this with PythonAPI, but I want to control it through ROS node. Thanks!

t0ny-peng commented 3 years ago

@nitesh4146 You need to build a ROS2 package first https://github.com/lgsvl/ros2-lgsvl-bridge

It's a bridge between ROS2 and lgsvl simulator. It listens on port 9090 and relay the state/control messages. You'll also need to select the correct Autopiolet profile and use 127.0.0.1:9090 as the API endpoint when you create the simulation in the web page.

nitesh4146 commented 3 years ago

Hi @left4taco, thanks for your reply. I have no issues connecting to simulator over the bridge or configuring web settings. As I said, I am able to publish steering commands but not the throttle. I checked the simulator/command/control topic and the speed doesn't no matter what I publish from my ROS2 node. What am I missing here? Appreciate your help