Wheeled mobile robot
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
Up:[[Tutorial]] Previous:[[Control of humanoid age...
----
#contents
* Wheeled mobile robot [#y0590a3f]
This tutorial explains how to control a wheeled mobile ro...
(※This sample code is valid only for later than v2.1.1)
** Model of a mobile robot [#ce581e96]
The following model is used in this tutorial.
#ref(./mobile_robot_top_view.jpg)
Figure from overhead view
#br
#ref(./mobile_robot_bottom_view.jpg)
Figure from bottom view
This mobile robot has two wheels on both sides and two ca...
The both of two wheels are connected to the main body wit...
In this example, the wheels are rotated by setting the an...
The radius of the wheel (8cm) and the size of the robot 2...
The mass, color and so on are also defined in the 3D mode...
// Download the 3D model file and extract it on the worki...
// #ref(MobileBase_2.1.0.tar.gz)
// $ cd ~/MyWorld
// $ tar zxvf MobileBase_2.1.0.tar.gz
//
//
// v2.1.0 では標準で配布されていなかったが,v2.2.0 以降で...
** Creating a controller [#l40b0896]
$ emacs wheelController.cpp
wheelController.cpp
#highlight(cpp){{
#include <Controller.h>
#include <ControllerEvent.h>
#include <Logger.h>
/**
* Sample controller of a wheeled mobile robot
*/
class MobileController : public Controller {
public:
void onInit(InitEvent &evt);
double onAction(ActionEvent&);
void onRecvMsg(RecvMsgEvent &evt);
private:
double maxForce;
};
void MobileController::onInit(InitEvent &evt) {
maxForce = 500.0;
}
double MobileController::onAction(ActionEvent &evt) {
return 10.0;
}
// Callback function which is called when messages comes
void MobileController::onRecvMsg(RecvMsgEvent &evt)
{
// Receiving a message
std::string msg = evt.getMsg();
SimObj *my = getObj(myname());
// Set the angular velocity of the two wheels
if (strstr(msg.c_str(), " "))
{
// Separate the two elements by a space separator ' '
std::string left_vel;
std::string right_vel;
int n = 0;
n = msg.find(" ");
left_vel = msg.substr(0,n);
right_vel = msg.substr(n+1);
double lvel = atof(left_vel.c_str());
double rvel = atof(right_vel.c_str());
// Set velocity
my->setJointVelocity("JOINT_LWHEEL", lvel, maxForce);
my->setJointVelocity("JOINT_RWHEEL", rvel, maxForce);
}
}
extern "C" Controller * createController() {
return new MobileController;
}
}}
You can control the velocity of the two wheels by sending...
Compile the controller by the following command.
$ ./sigmake.sh wheelController.cpp
** World file [#oe6c7a97]
$ emacs wheelWorld.xml
wheelWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="mobile_base.xml">
<set-attr-value name="name" value="mobile_base_001"/>
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="7.5"/>
<set-attr-value name="z" value="0.0"/>
<set-attr-value name="language" value="c++"/>
<set-attr-value name="implementation" value="./wheel...
<set-attr-value name="collision" value="true"/>
<camera id="1"
link="LINK_CENTER"
position="0.0 0.0 10.0"/>
</instanciate>
<instanciate class="sePetBottle2LEmpty.xml">
<set-attr-value name="name" value="petbottle_0"/>
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="16.67"/>
<set-attr-value name="z" value="100.0"/>
<set-attr-value name="collision" value="true"/>
</instanciate>
<instanciate class="sePetBottle2LEmpty.xml">
<set-attr-value name="name" value="petbottle_1"/>
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="16.67"/>
<set-attr-value name="z" value="200.0"/>
<set-attr-value name="collision" value="true"/>
</instanciate>
</world>
}}
This world file specifies the 3D model file of the mobile...
A camera is attached on a link named "LINK_CENTER" which ...
A plastic bottle is also appeared as an obstacle.
** Execution [#ncada848]
$ sigserver.sh -w ./wheelWorld.xml
You can see a plastic bottle in front of the mobile robot.
For example, send a message "1 0.5" from the SIGViewer. T...
#ref(./mobile_robot_result.PNG,40%)
The robot can go backward.
#highlight(end)
Up:[[Tutorial]] Previous:[[Control of humanoid age...
#counter
End:
Up:[[Tutorial]] Previous:[[Control of humanoid age...
----
#contents
* Wheeled mobile robot [#y0590a3f]
This tutorial explains how to control a wheeled mobile ro...
(※This sample code is valid only for later than v2.1.1)
** Model of a mobile robot [#ce581e96]
The following model is used in this tutorial.
#ref(./mobile_robot_top_view.jpg)
Figure from overhead view
#br
#ref(./mobile_robot_bottom_view.jpg)
Figure from bottom view
This mobile robot has two wheels on both sides and two ca...
The both of two wheels are connected to the main body wit...
In this example, the wheels are rotated by setting the an...
The radius of the wheel (8cm) and the size of the robot 2...
The mass, color and so on are also defined in the 3D mode...
// Download the 3D model file and extract it on the worki...
// #ref(MobileBase_2.1.0.tar.gz)
// $ cd ~/MyWorld
// $ tar zxvf MobileBase_2.1.0.tar.gz
//
//
// v2.1.0 では標準で配布されていなかったが,v2.2.0 以降で...
** Creating a controller [#l40b0896]
$ emacs wheelController.cpp
wheelController.cpp
#highlight(cpp){{
#include <Controller.h>
#include <ControllerEvent.h>
#include <Logger.h>
/**
* Sample controller of a wheeled mobile robot
*/
class MobileController : public Controller {
public:
void onInit(InitEvent &evt);
double onAction(ActionEvent&);
void onRecvMsg(RecvMsgEvent &evt);
private:
double maxForce;
};
void MobileController::onInit(InitEvent &evt) {
maxForce = 500.0;
}
double MobileController::onAction(ActionEvent &evt) {
return 10.0;
}
// Callback function which is called when messages comes
void MobileController::onRecvMsg(RecvMsgEvent &evt)
{
// Receiving a message
std::string msg = evt.getMsg();
SimObj *my = getObj(myname());
// Set the angular velocity of the two wheels
if (strstr(msg.c_str(), " "))
{
// Separate the two elements by a space separator ' '
std::string left_vel;
std::string right_vel;
int n = 0;
n = msg.find(" ");
left_vel = msg.substr(0,n);
right_vel = msg.substr(n+1);
double lvel = atof(left_vel.c_str());
double rvel = atof(right_vel.c_str());
// Set velocity
my->setJointVelocity("JOINT_LWHEEL", lvel, maxForce);
my->setJointVelocity("JOINT_RWHEEL", rvel, maxForce);
}
}
extern "C" Controller * createController() {
return new MobileController;
}
}}
You can control the velocity of the two wheels by sending...
Compile the controller by the following command.
$ ./sigmake.sh wheelController.cpp
** World file [#oe6c7a97]
$ emacs wheelWorld.xml
wheelWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="mobile_base.xml">
<set-attr-value name="name" value="mobile_base_001"/>
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="7.5"/>
<set-attr-value name="z" value="0.0"/>
<set-attr-value name="language" value="c++"/>
<set-attr-value name="implementation" value="./wheel...
<set-attr-value name="collision" value="true"/>
<camera id="1"
link="LINK_CENTER"
position="0.0 0.0 10.0"/>
</instanciate>
<instanciate class="sePetBottle2LEmpty.xml">
<set-attr-value name="name" value="petbottle_0"/>
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="16.67"/>
<set-attr-value name="z" value="100.0"/>
<set-attr-value name="collision" value="true"/>
</instanciate>
<instanciate class="sePetBottle2LEmpty.xml">
<set-attr-value name="name" value="petbottle_1"/>
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="16.67"/>
<set-attr-value name="z" value="200.0"/>
<set-attr-value name="collision" value="true"/>
</instanciate>
</world>
}}
This world file specifies the 3D model file of the mobile...
A camera is attached on a link named "LINK_CENTER" which ...
A plastic bottle is also appeared as an obstacle.
** Execution [#ncada848]
$ sigserver.sh -w ./wheelWorld.xml
You can see a plastic bottle in front of the mobile robot.
For example, send a message "1 0.5" from the SIGViewer. T...
#ref(./mobile_robot_result.PNG,40%)
The robot can go backward.
#highlight(end)
Up:[[Tutorial]] Previous:[[Control of humanoid age...
#counter
Page: