SpeedRos documentation

SpeedRos is a version of Speedlib which offers us the possibility to control miniature devices like Faller (c) Crane, DCC trains or Switches using ROS.

Software requirements

In addition to the speedlib software requirements, SpeedRos to work requires:

  • Ubuntu mate

  • speedlib: Install and download speedlib

  • ROS : Install ROS

Hardware requirements

In addition to the hardware configuration required for speedlib it is necessary to add to that a Tquad

Building a SpeedRos workspace and sourcing the setup file

  • Knowing how to use ROS

Note

Before starting, it is imperative to create a local working directory in which to clone the remote repository of SpeedROS .Once this is done, the tquad directory must be moved to the raspberry which is on the tquad. This means that we will have two working spaces. The working space SpeedRos which will contain the train, switch and crane and a second one whitch is the tquad working space that we have to move in the tquad’s raspberry

Warning

This step must be fulfilled otherwise the catkin_make command will generated errors

$ cd ~/.../SpeedRos
$ catkin_make

Once the workspace was built, it created a similar structure in the devel subfolder which you usually find under /opt/ros/$ROSDISTRO_NAME

To add the workspace to your ROS environment you need to source the generated setup file:

$ source ~/.../SpeedRos/devel/setup.bash

It should be noted that this will only work for cranes. In order to correctly source the generated setup file, because of the wiringPi used to control the trains and the switches, you must be in sudo :

$ sudo su

Once it’s done we can now control our devices

Controlling a Faller (c) crane model using ROS

You must first check that you are connected to the faller’s wifi.

Open a terminal and run the following command:

$ roscore

Open a second terminal and run the following command:

$ rosrun crane crane_pilotpy "172.17.217.217"

Open a third terminal and run the following command:

$ rostopic pub /crane/command std_msgs/String " data : '' "

Note

“172.17.217.217” is the ip address of the crane faller card I used. It is required to connect to the crane. If yours is different, please put the one corresponding to your crane. (See faller datasheet)

Example

For the start_for method here is the command:

$ rostopic pub /crane/command std_msgs/String " data : ' crane_command : start_for; value : 5; motors_name : MotorChassis; motors_direction : MotorDirectionForward' "

For the set_speed method here is the command:

$ rostopic pub /crane/command std_msgs/String " data : ' crane_command : set_speed; speed_value : 5; motors_name : MotorChassis' "

Controlling a DCC train and switch model

..note ::

You must first be an administrator to be able to control the train or the switch because of the wiringPiSetup It is also essential to source the setup file (see Building a SpeedRos workspace and sourcing the setup file)

Train

Open a terminal and run the following command:

$ roscore

Open a second terminal and run the following command:

$ rosrun train train_pilotpy 8 3

Note

The first parameter is the number of train that we want to initialize. The second parameter designates the address or number of the first train to be initialized

Open a third terminal and run the following command:

$ rostopic pub /train/command std_msgs/String " data : '' "

Example

For the faster method here is the command:

$ rostopic pub /train/command std_msgs/String " data : 'train_command : faster; train_number : 3' "

For the speed method here is the command :

$ rostopic pub /train/command std_msgs/String " data : 'train_command : speed; train_number : 5; speed_value : 15' "

For the fl method here is the command:

$ rostopic pub /train/command std_msgs/String " data : 'train_command : fl; train_number : 5; accessories_value : True' "

Switch

Open a terminal and run the following command:

$ roscore

Open a second terminal and run the following command:

$ rosrun switch switch_pilot.py 8 3

Note

Like the train, the first parameter is the number of switch that we want to initialize. The second parameter designates the address or number of the first switch to be initialized

Open a third terminal and run the following command:

$ rostopic pub /switch/command std_msgs/String " data : '' "

Example

For the biais method here is the command:

$ rostopic pub /switch/command std_msgs/String " data : 'switch_command : biais; switch_number : 6; biais_id : 1; biais_state : True' "

To print information about the switch her is the command :

$ rostopic pub /switch/command std_msgs/String " data : 'switch_command : biais_info; switch_number : 6' "

Controlling T-Quad using ROS

You must install and configure the T-quad beforehand. To do this, follow the installation guide

If you want to control the T-quad with the keyboard keys, open a terminal and run the following command:

$ roslaunch tquad tquad_teleop.launch

If you want to control the tquad with a rosbridge client, open a terminal and run the following command:

$ roslaunch tquad tquad_bridge.launch

For the debugging

Usually we can use the tab to help us enter the ros command lines. However, sometimes the tab does not work. This can be due to 2 potential errors:

  • the node file is not an executable. To correct this, just write in the terminal:
    $ chmod + x file.py
    
  • the Setup file is not well sourced.

Note

We can also use a debugging command to find out if the ros node that we have launched has been properly initialized

$ roswtf

This command allows you to know which ros nodes are running on the machine.