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

[MuJoCo] enable to use mujoco simulator #557

Merged
merged 133 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
ec18bc9
[mujoco] add dragon mujoco model
sugikazu75 May 3, 2023
b0379bf
[mesh] add blender script for conversion from dae to stl
sugikazu75 May 3, 2023
6584d5d
[mujoco] add floor to dragon mujoco model
sugikazu75 May 3, 2023
35d4695
[mujoco] add launcher and script to spawn model
sugikazu75 May 3, 2023
ad8f562
[mujoco] modify dragon mujoco model
sugikazu75 May 3, 2023
f556e29
[WIP] add birotor mujoco model
sugikazu75 May 3, 2023
b687706
[aerial_robot_msgs] add new type of message ControlInput for mujoco
sugikazu75 May 3, 2023
ff9c4e3
[WIP][mujoco] update mujoco model spawner and add mujoco interface
sugikazu75 May 3, 2023
c864483
[mujoco] update dragon mujoco model
sugikazu75 May 4, 2023
be7ba7b
[mujoco] add mujoco interface scripts
sugikazu75 May 4, 2023
c371152
[mujoco] update launchers
sugikazu75 May 4, 2023
21160d0
[mujoco] add config
sugikazu75 May 4, 2023
10abdba
[mujoco] update pid controller
sugikazu75 May 7, 2023
548028f
[mujoco] update dragon mujoco model
sugikazu75 May 7, 2023
9460d46
[mujoco] update mujoco interface and flight controller
sugikazu75 May 7, 2023
982c544
[mujoco] update control param
sugikazu75 May 7, 2023
0d288ec
[mujoco] add ros topics: Clock, Imu, FourAxisCommnad, TorqueAllocatio…
sugikazu75 May 7, 2023
6b2549b
[mujoco] add flight controller interface
sugikazu75 Jun 4, 2023
76d5a4b
[mujoco] update mujoco ros interface
sugikazu75 Jun 4, 2023
e19ff4f
[mujoco] update dragon mujoco model
sugikazu75 Jun 4, 2023
a37e9c0
[mujoco][servo_bridge] extend servo_bridge for mujoco simulation
sugikazu75 Jun 5, 2023
85a3896
[mujoco] update damping of dragon mujoco model joint
sugikazu75 Jun 5, 2023
54177cc
[mujoco] updat mujoco interface
sugikazu75 Jun 5, 2023
a13bc80
[mujoco] add initalize process of joint servos
sugikazu75 Jun 5, 2023
5d8a113
[mujoco] remove unused files
sugikazu75 Jun 5, 2023
0080765
[mujoco] add mujoco source to path
sugikazu75 Jun 5, 2023
544b773
[mujoco] remove nuused files
sugikazu75 Jun 5, 2023
9767347
[mujoco] update mujoco interface not to use numpy-quaternion
sugikazu75 Jun 5, 2023
5b729b5
[mujoco] remove unused file in launcher
sugikazu75 Jun 5, 2023
f9a2c4a
[mujoco] modify publish rate
sugikazu75 Jun 5, 2023
fd306bb
[WIP][mujoco] implement mujoco interface C++ version
sugikazu75 Jun 11, 2023
8d1d4fc
[mujoco] update launchers for mujoco
sugikazu75 Jun 11, 2023
cf303bf
[mujoco] added joint initialize process
sugikazu75 Jun 11, 2023
523340b
[mujoco] update mujoco version to 2.3.6
sugikazu75 Jun 26, 2023
6f142e8
[mujoco] moved meshs
sugikazu75 Jun 27, 2023
75d7200
[mujoco] moved meshes
sugikazu75 Jul 5, 2023
bfee04f
update mujoco version to 2.3.7
sugikazu75 Jul 29, 2023
dace119
[mujoco] update parameter input
sugikazu75 Jul 29, 2023
6438b87
[mujoco] remove unused functions
sugikazu75 Jul 29, 2023
ab94668
[mujoco] refactor
sugikazu75 Jul 29, 2023
a483ab0
[mujoco] update dragom mujoco launcher
sugikazu75 Jul 29, 2023
895a18c
[mujoco][WIP] update
sugikazu75 Jul 29, 2023
6fc345d
[mujoco] add MujocoRobotHWSim
sugikazu75 Jul 31, 2023
8fc9784
[mujoco] depend on libglfw3-dev for build
sugikazu75 Aug 10, 2023
7f3a1ff
[mujoco] add interfaces of spinal and attitude controller for mujoco
sugikazu75 Aug 10, 2023
7c36782
[mujoco] update spinal interface and attitude controller for mujoco
sugikazu75 Aug 12, 2023
0d3994c
[mujoco] compile spinal interface and attitude controller for mujoco
sugikazu75 Aug 12, 2023
2981e15
[mujoco] compile mujoco_robot_hw_sim and add sample model from mujoco
sugikazu75 Aug 15, 2023
ab16465
[mujoco] add timer in mujoco_robot_hw_sim
sugikazu75 Aug 15, 2023
d26e73a
[mujoco] add dummy timer
sugikazu75 Aug 16, 2023
b954f45
[mujoco] update.
sugikazu75 Aug 16, 2023
cde359b
[mujoco] publish mocap and read imu
sugikazu75 Aug 16, 2023
30baaa8
Merge branch 'jsk-ros-pkg:master' into develop/mujoco
sugikazu75 Aug 16, 2023
77f8d44
[mujoco] add robot hardware interface
sugikazu75 Aug 21, 2023
6e8ee85
[mujoco] fix
sugikazu75 Aug 21, 2023
78f04ca
[mujoco] enable to load flight controller
sugikazu75 Aug 21, 2023
c06eab2
[mujoco] enable to publish simulation time
sugikazu75 Aug 22, 2023
5a3244d
[mujoco] publish mocap, imu, joint state
sugikazu75 Aug 22, 2023
8276eab
[mujoco][servo_bridge] add use mujoco flag
sugikazu75 Aug 23, 2023
2e61e2f
[mujoco] enable to joint control
sugikazu75 Aug 23, 2023
a6a706f
[mujoco][dragon] update launcher to switch gazebo or mujoco
sugikazu75 Aug 23, 2023
bfd99e7
[mujoco] remove unused files
sugikazu75 Aug 23, 2023
d998f41
[mujoco] add makefile to download pre-build mujoco
sugikazu75 Aug 23, 2023
0ff4a54
[mujoco] update CMekeLists to use downloaded mujoco header and library
sugikazu75 Aug 23, 2023
0ab1225
[aerial_robot_msgs] remove unused message ControlInput
sugikazu75 Aug 24, 2023
a5641b4
[mujoco] debug for CI
sugikazu75 Aug 24, 2023
6040dd1
[mujoco] rename filenames
sugikazu75 Aug 24, 2023
9e2dfe7
[mujoco][dragon] modify joint param
sugikazu75 Aug 26, 2023
88ea696
[mujoco][ServoBridge] refactor servo bridge node not to use additiona…
sugikazu75 Aug 26, 2023
589b127
[mujoco] refactor
sugikazu75 Aug 26, 2023
0f25684
[mujoco] modify joint damping
sugikazu75 Sep 6, 2023
e6f44ff
[mujoco] refactor
sugikazu75 Sep 10, 2023
6a06dfd
[mujoco] add noise to mocap data
sugikazu75 Sep 10, 2023
b98dd4b
[mujoco] print out key bind in mujoco viewer
sugikazu75 Sep 10, 2023
773b26e
[dragon] fix bug in transformation demo: exit when unsupported mode t…
sugikazu75 Sep 10, 2023
aad2b01
[mujoco][aeiral_robot_simulation] debug for CI
sugikazu75 Sep 12, 2023
2aabcae
Merge branch 'jsk-ros-pkg:master' into develop/mujoco
sugikazu75 Sep 13, 2023
3fd7e61
Merge branch 'jsk-ros-pkg:master' into develop/mujoco_
sugikazu75 Sep 15, 2023
7c2d5a0
[Simulation][Mujoco] remove mk from catkin_package
tongtybj Sep 13, 2023
53ac46b
[Simulation][Mujoco] refactor CMake config
tongtybj Sep 13, 2023
f4fbd34
[dragon] modify dae convesion script for blender>2.8.0
sugikazu75 Sep 15, 2023
f28bf57
[mujoco] separate mujoco robot model and world setting
sugikazu75 Sep 15, 2023
ddbb4aa
[mujoco] support headless mode
sugikazu75 Sep 16, 2023
d53612a
[mujoco] fix dae conversion script to work recursively
sugikazu75 Sep 16, 2023
59c1e2e
[mujoco] add stl mesh of hydrus_xi and mini_quadrotor
sugikazu75 Sep 16, 2023
824a21d
[mujoco] add mjcf generation script
sugikazu75 Sep 16, 2023
aa9cb41
[dragon][mujoco] update mujoco model path in launcher
sugikazu75 Sep 17, 2023
cde01f3
[mini_quadrotor][mujoco] add mujoco option in launcher
sugikazu75 Sep 17, 2023
7cef0cc
[gitignore][mujoco] ignore mujoco generated file, directory
sugikazu75 Sep 17, 2023
aaad186
[RobotModel][WIP] output robot mass
sugikazu75 Sep 17, 2023
bb63c00
[mujoco] output robot mass
sugikazu75 Sep 17, 2023
376d27b
[mini_quadrotor] fix inertia of battery to become positive definite m…
sugikazu75 Sep 17, 2023
dd00cb2
[aerial_robot_simulation] depend on blender
sugikazu75 Sep 17, 2023
03d1a5a
[hydrus_xi] add mujoco option in launcher
sugikazu75 Sep 17, 2023
fc60a4d
[mujoco] support ros melodic
sugikazu75 Sep 18, 2023
fda8552
[mujoco] update model generation script not to generate stl in urdf d…
sugikazu75 Sep 18, 2023
21c42c3
[mujoco] delete stls
sugikazu75 Sep 18, 2023
19dba86
[mujoco] refactor model generation script
sugikazu75 Sep 18, 2023
7ae5d3f
[mujoco] enable to run mujoco model generation script by CMake
sugikazu75 Sep 18, 2023
65ea3ec
[mujoco] remove unused files
sugikazu75 Sep 18, 2023
4a64367
[mujoco] do not show blender script log to standard output
sugikazu75 Sep 19, 2023
0cbd2a4
[mujoco] remove duplicated assignment
tongtybj Oct 7, 2023
ceadd7c
[mujoco] create directory for files related to mujoco
tongtybj Oct 7, 2023
2e00400
[mojoco] refactor the mujoco ros bridge
tongtybj Oct 7, 2023
eccc884
[mojoco] refactor MujocoRosControl to be more plane
tongtybj Oct 7, 2023
909f305
[mujoco] rename the files for mujoco robot hardware interface
tongtybj Oct 7, 2023
3845cf1
[mujoco] refactor the rotation process
tongtybj Oct 7, 2023
c8fe84d
[mujoco] refactor the robot hardwared inteface, create a default hw c…
tongtybj Oct 7, 2023
a758cee
Merge pull request #1 from tongtybj/develop/mujoco
sugikazu75 Oct 9, 2023
15375ee
[mujoco] refactor CMake for mujoco model generation
sugikazu75 Sep 18, 2023
eb21826
[mujoco] refactor mujoco model generation script
sugikazu75 Sep 19, 2023
6edbabe
[mujoco] refactor servo angle initialization process
sugikazu75 Oct 9, 2023
9828fd1
[mujoco] comment out the portion of dae2stl script
sugikazu75 Sep 19, 2023
d1cbe79
Merge remote-tracking branch 'origin/master' into develop/mujoco
tongtybj Oct 14, 2023
d108596
[Mujoco] move files that are not related to aerial robot to mojuco_ro…
tongtybj Oct 14, 2023
52ce6c7
[Mujoco][Robots] update the model conversion scripts
tongtybj Oct 14, 2023
35fac73
[Mujoco][Hydrus] add model conversion script for hydrus
tongtybj Oct 14, 2023
33cc82b
[Mujoco][Hydrus_XI] correct the inertia of PC
tongtybj Oct 14, 2023
8a328c4
[Mujoco][Robots] update the mujoco launch file, and related launch fi…
tongtybj Oct 14, 2023
c9fdd0a
[Gazebo] rename the launch file for gazebo to distinguish from mujoco…
tongtybj Oct 14, 2023
75c0fe0
[Mujoco][WIP] update the tag of aerial_robot_3rdparty to use the late…
tongtybj Oct 14, 2023
a1680b0
[Mujoco][Hydrus] add "mujoco" arg in the bringup launch file
tongtybj Oct 15, 2023
4f76fa0
[Mujoco][Robots] use the macro func in mujoco_ros_control to convert …
tongtybj Oct 18, 2023
3fd8fa8
[Mujoco] update the tag of aerial_robot_3rdparty
tongtybj Oct 18, 2023
7423240
Merge pull request #2 from tongtybj/develop/mujoco
sugikazu75 Oct 18, 2023
cc11549
[Mujoco][hydrus] fix servo bridge node in launcher for mujoco
sugikazu75 Oct 18, 2023
c93702d
[mini_quadrotor][mujoco] add rostest for mujoco
sugikazu75 Oct 18, 2023
0996ba0
Merge remote-tracking branch 'origin/master' into develop/mujoco
sugikazu75 Oct 28, 2023
90e67ba
[Mujoco][Github Action] avoid to back to the original path because of…
tongtybj Oct 28, 2023
bbd9b12
[Mujoco][Mini Quadrotor] skip mujoco test in ubuntu 16.04 kinetic
tongtybj Oct 28, 2023
88be082
Merge pull request #3 from tongtybj/develop/mujoco
sugikazu75 Oct 28, 2023
e50e386
Merge pull request #5 from tongtybj/chou/develop/mujoco_kinetic
sugikazu75 Oct 28, 2023
ede95d9
[mujoco] update the version of 3rd party repositry
sugikazu75 Oct 29, 2023
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ tags
# Jetbrains
.idea/
*cmake-build-debug/

# mujoco
MUJOCO_LOG.txt
robots/**/mujoco
2 changes: 1 addition & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rosdep update --include-eol-distros
# Install source code
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
ln -sf ${CI_SOURCE_PATH} src/${REPOSITORY_NAME}
cp -r ${CI_SOURCE_PATH} src/${REPOSITORY_NAME} # copy the whole contents instead of create symbolic link
wstool init src
wstool merge -t src src/${REPOSITORY_NAME}/aerial_robot_${ROS_DISTRO}.rosinstall
wstool update -t src
Expand Down
2 changes: 1 addition & 1 deletion aerial_robot_kinetic.rosinstall
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- git:
local-name: aerial_robot_3rdparty
uri: https://github.com/JSKAerialRobot/aerial_robot_3rdparty.git
version: ros-kinetic
version: b21caa3

# kalman filter
- git:
Expand Down
2 changes: 1 addition & 1 deletion aerial_robot_melodic.rosinstall
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- git:
local-name: aerial_robot_3rdparty
uri: https://github.com/JSKAerialRobot/aerial_robot_3rdparty.git
version: b936f88
version: b21caa3

# kalman filter
- git:
Expand Down
2 changes: 2 additions & 0 deletions aerial_robot_model/include/aerial_robot_model/servo_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class ServoBridge
ros::NodeHandle nhp_;

ros::Publisher servo_states_pub_;
ros::Publisher mujoco_control_input_pub_;
map<string, ros::Subscriber> servo_states_subs_;
map<string, ros::Subscriber> servo_ctrl_subs_;
map<string, bool> no_real_state_flags_;
Expand All @@ -212,6 +213,7 @@ class ServoBridge
double moving_angle_thresh_;
bool send_init_joint_pose_;
bool simulation_mode_;
bool use_mujoco_;
int send_init_joint_pose_cnt_;

void servoStatesCallback(const spinal::ServoStatesConstPtr& state_msg, const std::string& servo_group_name);
Expand Down
1 change: 1 addition & 0 deletions aerial_robot_model/src/model/base_model/robot_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ namespace aerial_robot_model {
cog.p = link_inertia.getCOG();
setCog(cog);
mass_ = link_inertia.getMass();
ROS_INFO_STREAM_ONCE("[aerial_robot_model] robot mass is " << mass_);

setInertia((cog.Inverse() * link_inertia).getRotationalInertia());
setCog2Baselink(cog.Inverse() * f_baselink);
Expand Down
17 changes: 16 additions & 1 deletion aerial_robot_model/src/servo_bridge/servo_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
ServoBridge::ServoBridge(ros::NodeHandle nh, ros::NodeHandle nhp): nh_(nh),nhp_(nhp)
{
nh_.param("/use_sim_time", simulation_mode_, false);
nhp_.param("use_mujoco", use_mujoco_, false);
if(use_mujoco_)
{
ROS_WARN("use mujoco simulator");
simulation_mode_ = false;
}

if(simulation_mode_)
{
Expand All @@ -64,6 +70,7 @@ ServoBridge::ServoBridge(ros::NodeHandle nh, ros::NodeHandle nhp): nh_(nh),nhp_(
servo_states_subs_.insert(make_pair("common", nh_.subscribe<spinal::ServoStates>(state_sub_topic, 10, boost::bind(&ServoBridge::servoStatesCallback, this, _1, "common"))));
/* common publisher: target servo state to real machine (spinal_ros_bridge) */
servo_ctrl_pubs_.insert(make_pair("common", nh_.advertise<spinal::ServoControlCmd>(ctrl_pub_topic, 1)));
mujoco_control_input_pub_ = nh_.advertise<sensor_msgs::JointState>("mujoco/ctrl_input", 1);
/* common publisher: torque on/off command */
servo_torque_ctrl_pubs_.insert(make_pair("common", nh_.advertise<spinal::ServoTorqueCmd>(torque_pub_topic, 1)));

Expand Down Expand Up @@ -291,19 +298,22 @@ void ServoBridge::servoStatesCallback(const spinal::ServoStatesConstPtr& state_m
void ServoBridge::servoCtrlCallback(const sensor_msgs::JointStateConstPtr& servo_ctrl_msg, const string& servo_group_name)
{
spinal::ServoControlCmd target_angle_msg;
sensor_msgs::JointState mujoco_control_input_msg;

if(servo_ctrl_msg->name.size() > 0)
{
for(int i = 0; i < servo_ctrl_msg->name.size(); i++)
{/* servo name is assigned */

if(servo_ctrl_msg->position.size() != servo_ctrl_msg->name.size())
{
ROS_ERROR("[servo bridge, servo control control]: the servo position num and name num are different in ros msgs [%d vs %d]",
(int)servo_ctrl_msg->position.size(), (int)servo_ctrl_msg->name.size());
return;
}

mujoco_control_input_msg.name.push_back(servo_ctrl_msg->name.at(i));
mujoco_control_input_msg.position.push_back(servo_ctrl_msg->position.at(i));

// use servo_name to search the servo_handler
auto servo_handler = find_if(servos_handler_[servo_group_name].begin(), servos_handler_[servo_group_name].end(),
[&](SingleServoHandlePtr s) {return servo_ctrl_msg->name.at(i) == s->getName();});
Expand Down Expand Up @@ -344,6 +354,9 @@ void ServoBridge::servoCtrlCallback(const sensor_msgs::JointStateConstPtr& servo
target_angle_msg.index.push_back(servo_handler->getId());
target_angle_msg.angles.push_back(servo_handler->getTargetAngleVal(ValueType::BIT));

mujoco_control_input_msg.name.push_back(servo_handler->getName());
mujoco_control_input_msg.position.push_back(servo_ctrl_msg->position.at(i));

if(simulation_mode_)
{
std_msgs::Float64 msg;
Expand All @@ -353,6 +366,8 @@ void ServoBridge::servoCtrlCallback(const sensor_msgs::JointStateConstPtr& servo
}
}

mujoco_control_input_pub_.publish(mujoco_control_input_msg);

if (servo_ctrl_pubs_.find(servo_group_name) != servo_ctrl_pubs_.end())
servo_ctrl_pubs_[servo_group_name].publish(target_angle_msg);
else
Expand Down
2 changes: 1 addition & 1 deletion aerial_robot_noetic.rosinstall
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- git:
local-name: aerial_robot_3rdparty
uri: https://github.com/JSKAerialRobot/aerial_robot_3rdparty.git
version: b936f88
version: b21caa3

# kalman filter
- git:
Expand Down
1 change: 1 addition & 0 deletions aerial_robot_simulation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
19 changes: 14 additions & 5 deletions aerial_robot_simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ find_package(catkin REQUIRED COMPONENTS
aerial_robot_model
gazebo_ros_control
kdl_parser
mujoco_ros_control
roscpp
spinal
tf
Expand Down Expand Up @@ -38,24 +39,32 @@ include_directories(
include
)


add_definitions(-DSIMULATION)

add_library(flight_controllers
src/mujoco/mujoco_attitude_controller.cpp
src/simulation_attitude_controller.cpp)
target_link_libraries(flight_controllers ${catkin_LIBRARIES})
add_dependencies(flight_controllers spinal_generate_messages_cpp)
target_link_libraries(flight_controllers ${catkin_LIBRARIES})

add_library(spinal_interface src/spinal_interface.cpp)
target_link_libraries(spinal_interface ${catkin_LIBRARIES})

add_library(mujoco_spinal_interface src/mujoco/mujoco_spinal_interface.cpp)
target_link_libraries(mujoco_spinal_interface ${catkin_LIBRARIES})

add_library(aerial_robot_hw_sim src/aerial_robot_hw_sim.cpp)
target_link_libraries(aerial_robot_hw_sim spinal_interface ${catkin_LIBRARIES} ${GAZEBO_LIBRARIES} ${orocos_kdl_LIBRARIES})

add_library(mujoco_aerial_robot_hw_sim src/mujoco/mujoco_aerial_robot_hw_sim.cpp )
target_link_libraries(mujoco_aerial_robot_hw_sim ${catkin_LIBRARIES} mujoco_spinal_interface)


install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})


install(TARGETS aerial_robot_hw_sim spinal_interface flight_controllers
install(TARGETS aerial_robot_hw_sim spinal_interface flight_controllers mujoco_spinal_interface mujoco_aerial_robot_hw_sim
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

Expand All @@ -64,6 +73,6 @@ install(DIRECTORY scripts
USE_SOURCE_PERMISSIONS
)

install(FILES aerial_robot_hw_sim_plugins.xml flight_controllers_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
install(FILES aerial_robot_hw_sim_plugins.xml flight_controllers_plugins.xml mujoco_robot_hw_sim_plugin.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
17 changes: 17 additions & 0 deletions aerial_robot_simulation/config/Mujoco.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# control
attitude_controller:
type: flight_controllers/MujocoAttitudeController


# sensor -> aerial_robot_hw_sim
## mocap
simulation:
robot_hw_sim_plugin_name: mujoco_ros_control/AerialRobotHWSim

mocap_pub_rate: 0.01
mocap_pos_noise: 0.001
mocap_rot_noise: 0.001

# ground truth -> aerial_robot_hw_sim
ground_truth_pub_rate: 0.01

6 changes: 6 additions & 0 deletions aerial_robot_simulation/flight_controllers_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
</description>
</class>

<class name="flight_controllers/MujocoAttitudeController" type="flight_controllers::MujocoAttitudeController" base_class_type="controller_interface::ControllerBase">
<description>
The Attitude Controller using part of the flight controller function in micro-baord.
</description>
</class>

</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include <aerial_robot_simulation/mujoco/mujoco_spinal_interface.h>
#include <aerial_robot_simulation/noise_model.h>
#include <geometry_msgs/PoseStamped.h>
#include <mujoco_ros_control/mujoco_default_robot_hw_sim.h>
#include <nav_msgs/Odometry.h>

namespace mujoco_ros_control
{
class AerialRobotHWSim : public mujoco_ros_control::DefaultRobotHWSim
{
public:
AerialRobotHWSim() {};
~AerialRobotHWSim() {}

bool init(const std::string& robot_namespace,
ros::NodeHandle model_nh,
mjModel* mujoco_model,
mjData* mujoco_data
) override;

void read(const ros::Time& time, const ros::Duration& period) override;

void write(const ros::Time& time, const ros::Duration& period) override;

protected:
hardware_interface::MujocoSpinalInterface spinal_interface_;

std::vector<std::string> rotor_list_;
ros::Publisher ground_truth_pub_;
ros::Publisher mocap_pub_;
double ground_truth_pub_rate_;
double mocap_pub_rate_;
double mocap_rot_noise_, mocap_pos_noise_;
double ground_truth_pos_noise_, ground_truth_vel_noise_, ground_truth_rot_noise_, ground_truth_angular_noise_;
double ground_truth_rot_drift_, ground_truth_vel_drift_, ground_truth_angular_drift_;
double ground_truth_rot_drift_frequency_, ground_truth_vel_drift_frequency_, ground_truth_angular_drift_frequency_;
double joint_state_pub_rate_ = 0.02;

ros::Time last_mocap_time_;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <ros/ros.h>
#include <aerial_robot_estimation/state_estimation.h>
#include <aerial_robot_simulation/mujoco/mujoco_spinal_interface.h>
#include <flight_control/flight_control.h>
#include <controller_interface/controller.h>
#include <pluginlib/class_list_macros.h>

namespace flight_controllers
{
class MujocoAttitudeController : public controller_interface::Controller<hardware_interface::MujocoSpinalInterface>
{
public:
MujocoAttitudeController();
~MujocoAttitudeController() {}

bool init(hardware_interface::MujocoSpinalInterface *robot, ros::NodeHandle &n);

void starting(const ros::Time& time);
void update(const ros::Time& time, const ros::Duration& period);

private:
hardware_interface::MujocoSpinalInterface* spinal_interface_;
boost::shared_ptr<FlightControl> controller_core_;
int motor_num_;

};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once

#include <ros/ros.h>
#include <hardware_interface/internal/hardware_resource_manager.h>
#include <hardware_interface/hardware_interface.h>
#include <aerial_robot_estimation/state_estimation.h>
#include <state_estimate/state_estimate.h>
#include <tf/LinearMath/Transform.h>
#include <cassert>
#include <limits>

namespace hardware_interface
{
class MujocoSpinalInterface : public HardwareInterface
{
public:
MujocoSpinalInterface();
bool init(ros::NodeHandle& nh, int motor_num);

void setImuValue(double acc_x, double acc_y, double acc_z, double gyro_x, double gyro_y, double gyro_z);
void setMagValue(double mag_x, double mag_y, double mag_z);
void setTrueBaselinkOrientation(double q_x, double q_y, double q_z, double q_w);
void setTrueBaselinkAngular(double w_x, double w_y, double w_z);

tf::Vector3 getTrueBaselinkRPY();
inline tf::Vector3 getTrueBaselinkAngular() { return baselink_angular_;}
tf::Vector3 getTrueCogRPY();
tf::Vector3 getTrueCogAngular();

void stateEstimate();
inline void onGround(bool flag) { on_ground_ = flag; }
StateEstimate* getEstimatorPtr() {return &spinal_state_estimator_;}
std::string getName() const{return "";}
int getMotorNum() {return motor_num_;}
double getForce(int index){return force_.at(index);}
void setForce(int index, double force) {force_.at(index) = force;}

private:
/* attitude estimator */
bool on_ground_;

int motor_num_;
std::vector<double> force_;
tf::Matrix3x3 baselink_rot_;
tf::Vector3 baselink_angular_;
StateEstimate spinal_state_estimator_;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
</include>

<!-- basic parameter -->
<rosparam file="$(find aerial_robot_simulation)/config/Simulation.yaml" command="load" ns="$(arg robot_ns)" />
<rosparam file="$(find aerial_robot_simulation)/config/Gazebo.yaml" command="load" ns="$(arg robot_ns)" />

<node name="$(anon urdf_spawner)" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
args="-urdf -model $(arg robot_ns) -x $(arg spawn_x) -y $(arg spawn_y) -z $(arg spawn_z) -Y $(arg spawn_yaw) -param $(arg robot_ns)/robot_description"/>

<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="$(arg robot_ns)" args="joint_state_controller attitude_controller">
</node>
output="screen" ns="$(arg robot_ns)" args="joint_state_controller attitude_controller" />

</launch>
20 changes: 20 additions & 0 deletions aerial_robot_simulation/launch/mujoco.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<launch>
<arg name="robot_ns" default="" />
<arg name="headless" default="false" />
<arg name="mujoco_model" default="" />

<!-- mujoco ros control -->
<include file="$(find mujoco_ros_control)/launch/mujoco.launch" >
<arg name="robot_ns" value="$(arg robot_ns)" />
<arg name="headless" value="$(arg headless)"/>
<arg name="mujoco_model" value="$(arg mujoco_model)"/>
</include>

<!-- basic parameter -->
<rosparam file="$(find aerial_robot_simulation)/config/Mujoco.yaml" command="load" ns="$(arg robot_ns)" />

<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="$(arg robot_ns)" args="attitude_controller" />

</launch>
10 changes: 10 additions & 0 deletions aerial_robot_simulation/mujoco_robot_hw_sim_plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library path="lib/libmujoco_aerial_robot_hw_sim">
<class
name="mujoco_ros_control/AerialRobotHWSim"
type="mujoco_ros_control::AerialRobotHWSim"
base_class_type="mujoco_ros_control::RobotHWSim">
<description>
simulation interface for aerial robot in MuJoCo.
</description>
</class>
</library>
Loading
Loading