lgsvl / simulator

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

Speed signal of the ego vehicle #856

Open ashwinsarvesh opened 4 years ago

ashwinsarvesh commented 4 years ago

Hello,

I would like to get the speed of the ego vehicle from the simulation and send it to a camera that has a GPS receiver (2.5mm jack). Is this possible to get the speed of the simulated vehicle?

The reason why I need this: This camera has ADAS functions like lane departure and forward collision warning. For these features to work, I need this speed of the simulated ego vehicle. I place this camera in front of the simulator.

EricBoiseLGSVL commented 4 years ago

@ashwinsarvesh You can enable the sensor visualizations and have any value you need. If you need a different UI implementation, you will need to edit simulator code or make a sensor that displays UI data. It could even be as simple as an OnGUI().

SpeedHelp

lemketron commented 4 years ago

You could also monitor (on ROS, ROS2, or CyberRT) the CAN Bus messages (including speed).

For example, in /apollo/canbus/chassis you will see the speed in meters per second labeled as "speed_mps". You could monitor this data programmatically and then determine how to present it to your ADAS camera.

You mentioned a GPS antenna, but generating fake GPS radio signals to trick a stationary ADAS camera into thinking it is moving is non-trivial, and not something the simulator will be able to help you with. If you can figure out how to inject the speed into the ADAS camera (or whatever it is connected to) that would be much easier.

ashwinsarvesh commented 4 years ago

Hello,

Thank you for your reply. I need to extract the following signals of the ego vehicle from the Simulator/Apollo to connect it to the ADAS camera.

The attached picture contains the wiring of the camera. Wiring

rongguodong commented 4 years ago

On the real car, these signals will be passed to your camera driver via those wires. When you use our simulator, you may implement a bridge plugin (please refer to our ROS/ROS2/Cyber bridges). So the bridge will receive all messages from our simulator, and send the useful ones (e.g. ego speed) to your camera driver.

ashwinsarvesh commented 4 years ago

Thank you for your reply Are these data which I listed above given by the simulator or Apollo?

Regarding your idea, Unfortunately, this camera does not have a ROS driver. :/ So I guess this idea will not work. What do you say?

rongguodong commented 4 years ago

I believe we have all those information available in the simulator (may need more information on that ignition signal -- what does it mean? Is it just an on/off status?) Even if the camera dose not have a ROS driver, it must have some driver, right? You can build a bridge plugin working with that driver.

ashwinsarvesh commented 4 years ago

ok, I will check on the driver part. Ignition is a (12/24V) signal. When the vehicle ignition switch is turned to ACC (Accessory) position, this 12/24V is passed to this signal which powers on the camera.

ashwinsarvesh commented 4 years ago

I believe we have all those information available in the simulator (may need more information on that ignition signal -- what does it mean? Is it just an on/off status?) Even if the camera dose not have a ROS driver, it must have some driver, right? You can build a bridge plugin working with that driver.

How do I access this data from the simulator?

rongguodong commented 4 years ago

Please read the code to understand how the current sensors access data and send out messages.

ashwinsarvesh commented 4 years ago

Yes, I will do that. But can you tell me whether I have to read lgsvl code or Apollo code to know how to access data and send out messages? It would be helpful if you can guide me to a specific part to read.

EricBoiseLGSVL commented 4 years ago

Look at sensors and bridge code to see how we send data. They are in their respective folders in Assets/Scripts/Sensors or /Bridge

ashwinsarvesh commented 4 years ago

Hello,

I am planning to use socketcan_bridge to send simulator CAN messages received on a ROS topic to the SocketCAN device which is a CAN hardware connected to a PC.

This socketcan_bridge only processes "can_msgs/Frame" messages. To convert CanBusData type to "can_msgs/Frame" messages, I need to modify this code right? https://github.com/lgsvl/simulator/blob/master/Assets/Scripts/Bridge/Ros/RosBridge.cs#L267

Also, Where can I find more information about the CanBusData type and its message frame format?

EricBoiseLGSVL commented 4 years ago

@ashwinsarvesh We don't support Socketcan bridge currently but you can create a custom bridge to subscribe to the messages. Right @hadiTab ?

ashwinsarvesh commented 4 years ago

@EricBoiseLGSVL Can you elaborate what you mean by not support Socketcan_bridge? I thought I could install socketcan_bridge and then use it to send the "can_msgs/Frame" messages from the simulator (after converting from CanBusData type). I mean, I thought both were independent and Socketcan_bridge doesn't have to do anything with the simulator.

And by a custom bridge, you mean custom bridge plugin?

EricBoiseLGSVL commented 4 years ago

@ashwinsarvesh Yes we support ROS, ROS2 and CyberRT. This new bridge type will need to be added or create a custom solution.

ashwinsarvesh commented 4 years ago

@EricBoiseLGSVL I get it now. ROS bridges and Cyber RT bridges are adapted to be supported by LGSVL but socketcan_bridge is not adapted. Is my understanding correct?

EricBoiseLGSVL commented 4 years ago

@hadiTab is the expert on this but yes you are correct

ashwinsarvesh commented 4 years ago

Can you tell me what I have to refer to implement a custom bridge plugin? In this link, I am not able to find any instructions to create bridge plugins.

EricBoiseLGSVL commented 4 years ago

Sorry, this feature has not released yet but it should be soon. @hadiTab might have a workaround that would help you better.

hadiTab commented 4 years ago

@ashwinsarvesh from what I can tell from what you have described you don't need a new bridge plugin, you need to add a new ROS1 message of type can_msgs/Frame. You would then run the rosbridge and socketcan_bridge on the same machine. rosbridge will publish the can_msgs/Frame message which I believe socketcan_bridge will subscribe to and will then pass along to your device.

To publish the new message you need to:

Now make sure you add the CanBus sensor to your vehicle json config, and that you select the ROS1 bridge. You should now recieve the can_msgs/Frame message on the topic defined in the json. If you run the rosbridge on the machine connected to your CAN device you will be publishing the can_msgs/Frame message on that machine and the socketcan_bridge should be able to subscribe to it and communicate with your CAN device.

ashwinsarvesh commented 4 years ago

Thank you for your reply. I'll check this method Where can I find the below details for the individual signals(for eg. Speed, left turn signal, right turn signal) As the "can_msgs/Frame" asks for the below details. It would be helpful if I can find these. image

ashwinsarvesh commented 4 years ago

Hello,

I am sorry if I was not clear with my previous question. For each can signal produced by the simulator(eg. speed, left and right turn signal),

I need this info to convert to the can_msgs/Frame type. As of now, I can just see the can bus data here