User Tools

Site Tools


vrep:create-rc-car-robot

Differences

This shows you the differences between two versions of the page.


vrep:create-rc-car-robot [2023/03/31 12:14] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +Back to [[vrep:main|V-REP Main Page]]
 +
 +We start from an Inventor CAD file off an RC car that we want to use as a cheap autonomous robot for educational purpose:
 + 
 +  - Convert the CAD file to a format importable in V-REP
 +  - Simplify the CAD to create the dynamic model
 +  - Make dynamic model more realistic
 +  - Add the CAD parts 
 +  - Program the ROS Interface
 +  - Test
 +  - Build the track
 +  - Test again
 +
 +The original CAD file of the RC car has been made on Inventor. It has been converted to a bunch of STL files, one for each part. As we will have to define ourselves the links in V-REP when building the dynamical model, we do not need to use the links defined in Inventor.  
 +
 +The dynamic model of the car is quite realistic, it models the steering bar and the gears between the motor and the rear wheels axis. 
 +{{ :vrep:rc_car_dyn_only.png?400 |}}
 +
 +The V-REP file with only the dynamic model can be found here [[https://www.ensta-bretagne.fr/zerr/filerepo/vrep/seance4_modele_realiste_dyn.ttt|seance4_modele_realiste_dyn.ttt]]
 +
 +We take all the parts from the CAD file and we import them as static objects in V-REP. Thanks to Jules's car body, the RC car looks now quite well in V-REP. However, to see the inside of the car and e.g. the moving gears, the car body opacity has been reduced (in color settings in V-REP).
 +{{ :vrep:rc_car_vrep.png?400 |}}
 +
 +The V-REP file is here [[https://www.ensta-bretagne.fr/zerr/filerepo/vrep/seance4_modele_realiste.ttt|seance4_modele_realiste.ttt]]. Another V-REP file can be usefull with car on a lifting bridge [[https://www.ensta-bretagne.fr/zerr/filerepo/vrep/seance4_modele_realiste_pont_levage.ttt|seance4_modele_realiste_pont_levage.ttt]].
 +
 +Now we can test that the car can be controlled by ROS. After starting **roscore**, we just update the topics with the **rostopic pub** command. The car is control, as we do it with th RC controller, by two topics :
 +  * /vrep_steer_angle  : steering angle , from -20 to +20 degrees
 +  * /vrep_speed_motor  : motor speed , in degrees/second (to be verified ?!?)
 +
 +Here are some examples of commands :
 +<code bash>
 +rostopic pub -1 /vrep_steer_angle std_msgs/Float32 -- -20.0   
 +rostopic pub -1 /vrep_speed_motor std_msgs/Float32 -- 5    
 +</code>
 +
 +The last file is the full V-REP file with the track : [[https://www.ensta-bretagne.fr/zerr/filerepo/vrep/seance4_modele_realiste_et_piste.ttt|seance4_modele_realiste_et_piste.ttt]].
 +The track can be built and modified using Blender as explained[[blender:main-blender-create-track|here]].
 +{{ :vrep:rc_car_track.png?400 |}}
 +
 +To import the track created by Blender in V-REP :
 +  * export the track from Blender using Wavefront (.obj) format, the exported file can be called create_track_bezier.obj
 +  * open a scene file with the RC car in V-REP (e.g. [[https://www.ensta-bretagne.fr/zerr/filerepo/vrep/seance4_modele_realiste.ttt|seance4_modele_realiste.ttt]])
 +  * import create_track_bezier.obj using File->Import->Mesh... , select " unit represents 10 cm" and "Y vector is up" and click "OK"
 +  * (optional) rename "GateElement_..." to "Gates" and "TrackElement_.." to "Track"
 +  * remove the default floor "ResizableFloor_5_25"
 +  * select the "Gates" object , doucle click on the icon on the left, once the property window has appeared, click on "adjust color" to give a color to the gates.
 +  * select the "Track" object , doucle click on the icon on the left, once the property window has appeared, click on "show dynamic properties dialog" and select "Body is respondable". (Warning : do not set "Body is dynamic" !!!). Close the warning message and close the "Rigid body dynamic window".
 +  * in the property window, click on "adjust texture" and in the texture window click "load new texture" and select the texture file for the road. Here, we use the 2048x2048 image from [[http://texturelib.com/texture/?path=/Textures/road/road/road_road_0021|texturelib website]] to have lines that the RC car can follow, but you can take any road texture image. Select "Max. 2048x2048" for the texture scale, set "apply mode" to "decal" and close texture dialog window.
 +  * you can add 45x45 meters green plane (add primitive shapes) and place it 10 cm below the track to have a background. If you have enough CPU power you can leave this green plane "dynamic" and "respondable" so that the car will not fall in the abysses when leaving the track.
 +  * if the car is not correctly oriented in the direction of the track, select "Chassis" object, then click on rotation icon, define the "Around-z" rotation angle and click "Z-rotate sel.".
 +  * start the simulation in V-REP (make sure roscore was running before starting V-REP)
 + 
 +
 +ToDo : create a collision form from the car body, now the collision is only done with the hidden elements of the dynamic model, it is OK for the wheels but not for the body of the car.
 +
 +Back to [[vrep:create-rc-car-robot|top]].