Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp review #14

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# robotics_spot
Reinforced Spot Mini
The package of Spot` controller based on [SpotMicro project](https://github.com/OpenQuadruped/spot_mini_mini).


## Install
Expand Down Expand Up @@ -34,7 +34,7 @@ git clone https://github.com/tarasborov/robotics_spot.git
Build docker images

```bash
cd robotics_spot/docker/ros_melodic
cd robotics_spot/docker/ros_spot
chmod a+x build.bash
sudo ./build.bash
```
Expand All @@ -54,7 +54,7 @@ catkin config --init --extend /opt/ros/melodic
catkin build
```

## Use state machine
## Use tmux
All following commands should be executed in specified containers:

```bash
Expand All @@ -63,5 +63,59 @@ chmod a+x start.sh
chmod a+x session.yml
./start.sh
```
Now tmux session will start with all required tabs. All required commandsmay be added to the history, in order to simplify their usage.
Now tmux session will start with all required tabs. All required commands may be added to the history, in order to simplify their usage.

## Start Gazebo
Launch world SoftServe office:
```bash
roslaunch rs_gazebo HQ.launch
```
Launch the specific world:
```bash
roslaunch rs_gazebo HQ.launch world_name:="<world_name>"
```
Spawn robot:
```bash
roslaunch rs_gazebo robot.launch
```
Spawn robot with the specific name and position:
```bash
roslaunch rs_gazebo robot.launch robot_name:="<spot_name>" init_pose:="-x 0.0 -y 0.0 -z 0.0"
```
## Control
You can control Spot in the two ways: using forward or inverse kinematics. Forward kinematics means to send command on actuator directly. To run hardcoded actuators` command just run:
```bash
roslaunch rs_control talker.launch
```
Run for the specific robot:
```bash
roslaunch rs_control talker.launch robot_name:="<spot_name>"
```

Inverse kinematics means to predetermine joins angels by calculating kinematics relationships between joints. To calculate gait we use algorithm frrom [SpotMicro project](https://github.com/OpenQuadruped/spot_mini_mini).
In order to control Spot using inverse kinematics and MIT control use the following commands:

Start a controller:
```bash
roslaunch rs_inverse inverse.launch
```
Run for the specific robot:
```bash
roslaunch rs_inverse inverse.launch robot_name:="<spot_name>"
```
Launch GUI to send command:
```bash
roslaunch rs_inverse gui_spot.launch
```
Run GUI for the specific robot:
```bash
roslaunch rs_inverse gui_spot.launch robot_name:="<spot_name>"
```
Launch a teleop to control Spot:
```bash
roslaunch rs_teleop teleop_spot.launch
```
Run teleop for the specific robot:
```bash
roslaunch rs_teleop teleop_spot.launch robot_name:="<spot_name>"
```
14 changes: 8 additions & 6 deletions docker/ros_melodic/Dockerfile → docker/ros_spot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ FROM lyubomyrd/ros_melodic:latest

WORKDIR /root

# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

RUN apt-get update && apt-get install -y \
openssh-server \
gdb \
Expand All @@ -10,8 +16,6 @@ RUN apt-get update && apt-get install -y \
ros-melodic-joint-state-publisher-gui \
ros-melodic-interactive-marker-twist-server \
ros-melodic-robot-state-publisher \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to move this installation to package.xml

python-pip \
&& pip install simple-pid \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir /var/run/sshd
Expand All @@ -27,8 +31,6 @@ RUN mkdir -p deps_ws/src && \
--cmake-args -DCMAKE_BUILD_TYPE=Release && \
catkin profile set release

RUN echo "PS1='\[\e[33m\][MrHandy]\[\e[m\] ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '" >> ~/.bashrc

RUN echo "source ~/ws/devel/setup.bash" >> ~/.bashrc
RUN echo "PS1='\[\e[33m\][Spot]\[\e[m\] ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '" >> ~/.bashrc

RUN echo "export XV_NAME=hand_0" >> ~/.bashrc
RUN echo "source ~/ws/devel/setup.bash" >> ~/.bashrc
File renamed without changes.
1 change: 1 addition & 0 deletions docker/ros_melodic/run.bash → docker/ros_spot/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docker run -it --rm \
--volume="$WS_DIR_PATH:/root/ws" \
--env="DISPLAY=$DISPLAY" \
--env QT_X11_NO_MITSHM=1 \
--runtime=nvidia \
--net host \
ros_melodic_ws

Expand Down
15 changes: 8 additions & 7 deletions rs_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ find_package(catkin REQUIRED COMPONENTS)

catkin_package()


install(DIRECTORY config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

catkin_install_python(
PROGRAMS
scripts/talker.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY launch config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
39 changes: 39 additions & 0 deletions rs_control/config/forward_kinematics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
sit_down: [ [ 0.20, 1.0, -2.49 ],
[ -0.20, 1.0, -2.49 ],
[ 0.20, 1.0, -2.49 ],
[ -0.20, 1.0, -2.49 ] ]

stand_up: [ [ 0.20, 0.7, -1.39 ],
[ -0.20, 0.7, -1.39 ],
[ 0.20, 0.7, -1.39 ],
[ -0.20, 0.7, -1.39 ] ]

give_paw: [ [ -0.30, 1.0, -1.39 ],
[ -0.20, -0.6, -1.09 ],
[ 0.20, 1.0, -2.39 ],
[ -0.20, 1.0, -2.39 ] ]

leg_spread: [ [ 1.20, 0.7, -1.39 ],
[ -1.20, 0.7, -1.39 ],
[ 1.20, 0.7, -1.39 ],
[ -1.20, 0.7, -1.39 ] ]

fl_leg: [ [ 0.20, -0.2, -1.09 ],
[ -0.20, 0.7, -1.39 ],
[ 0.20, 0.7, -1.39 ],
[ -0.20, 0.7, -1.39 ] ]

fr_leg: [ [ 0.20, 0.7, -1.09 ],
[ -0.20, -0.2, -1.09 ],
[ 0.20, 0.7, -1.39 ],
[ -0.20, 0.7, -1.39 ] ]

bow_forward: [ [ 0.20, 1.0, -1.79 ],
[ -0.20, 1.0, -1.79 ],
[ 0.20, 0.7, -1.29 ],
[ -0.20, 0.7, -1.29 ] ]

leg_spread_left: [ [ 1.20, 0.7, -1.39 ],
[ 0.20, 0.7, -1.39 ],
[ 1.20, 0.7, -1.39 ],
[ 0.20, 0.7, -1.39 ] ]
9 changes: 4 additions & 5 deletions rs_control/config/spot_control.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
spot:
# Publish all joint states -----------------------------------
# Publish all joint states -----------------------------------
joint_states_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
Expand Down Expand Up @@ -30,11 +29,11 @@ spot:
type: effort_controllers/JointPositionController
joint: front_right_hip_y
pid: {p: 280, d: 45, i: 0.001}
antiwindup: False
antiwindup: False
joint_front_right_knee_controller:
type: effort_controllers/JointPositionController
joint: front_right_knee
pid: {p: 280, d: 45, i: 0.001}
pid: {p: 280, d: 45, i: 0.001}
antiwindup: False
joint_rear_left_hip_x_controller:
type: effort_controllers/JointPositionController
Expand All @@ -44,7 +43,7 @@ spot:
joint_rear_left_hip_y_controller:
type: effort_controllers/JointPositionController
joint: rear_left_hip_y
pid: {p: 280, d: 45, i: 0.001}
pid: {p: 280, d: 45, i: 0.001}
antiwindup: False
joint_rear_left_knee_controller:
type: effort_controllers/JointPositionController
Expand Down
2 changes: 0 additions & 2 deletions rs_control/config/spot_param_for_scripts.yaml

This file was deleted.

23 changes: 14 additions & 9 deletions rs_control/launch/spot_controller.launch
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<launch>

<arg name="spot_name" default="spot1" />
<!-- Load joint controller configurations from YAML file to parameter server -->
<rosparam file="$(find rs_control)/config/spot_control.yaml" command="load"/>

<!-- Load the controllers -->
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="/spot" args="joint_front_left_hip_x_controller joint_front_left_hip_y_controller joint_front_left_knee_controller joint_front_right_hip_x_controller joint_front_right_hip_y_controller joint_front_right_knee_controller joint_rear_left_hip_x_controller joint_rear_left_hip_y_controller joint_rear_left_knee_controller joint_rear_right_hip_x_controller joint_rear_right_hip_y_controller joint_rear_right_knee_controller joint_states_controller"/>

<!-- convert joint states to TF transforms for rviz, etc -->
<!-- <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
<remap from="/joint_states" to="/spot/joint_states" />
</node> -->

output="screen" ns="/$(arg spot_name)" args="joint_front_left_hip_x_controller
joint_front_left_hip_y_controller
joint_front_left_knee_controller
joint_front_right_hip_x_controller
joint_front_right_hip_y_controller
joint_front_right_knee_controller
joint_rear_left_hip_x_controller
joint_rear_left_hip_y_controller
joint_rear_left_knee_controller
joint_rear_right_hip_x_controller
joint_rear_right_hip_y_controller
joint_rear_right_knee_controller
joint_states_controller"/>
</launch>
6 changes: 6 additions & 0 deletions rs_control/launch/talker.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<launch>
<arg name="robot_name" default="spot1" />
<param name="spot_name" type="str" value="$(arg robot_name)" />
<rosparam file="$(find rs_control)/config/forward_kinematics.yaml" command="load"/>
<node name="talker_forward" pkg="rs_control" type="talker.py" output="screen" ns="/$(arg robot_name)"/>
</launch>
3 changes: 0 additions & 3 deletions rs_control/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@
<exec_depend>controller_manager</exec_depend>
<exec_depend>joint_state_controller</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>

<export>
</export>
</package>
82 changes: 0 additions & 82 deletions rs_control/scripts/listeners.py

This file was deleted.

Loading