• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1761 (tree)
日時2010-04-11 01:51:05
作者satofumi

ログメッセージ

comment adjusted.

変更サマリ

差分

--- trunk/libs/simulator/samples/SchedulerModel/SchedulerModel.cpp (revision 1760)
+++ trunk/libs/simulator/samples/SchedulerModel/SchedulerModel.cpp (revision 1761)
@@ -69,13 +69,13 @@
6969
7070 mutex_->unlock();
7171
72- // system_getTicks() の代わり
72+ // system_ticks() の代わり
7373 QThread::msleep(1);
7474 }
7575 }
7676
7777
78- long getTicks(void)
78+ long ticks(void)
7979 {
8080 mutex_->lock();
8181 long ticks = current_ticks_;
@@ -98,9 +98,9 @@
9898 EventScheduler* event_scheduler_ = NULL;
9999
100100
101- long getTicks(void)
101+ long ticks(void)
102102 {
103- return event_scheduler_->getTicks();
103+ return event_scheduler_->ticks();
104104 }
105105
106106
@@ -126,7 +126,7 @@
126126
127127 // プログラム例
128128 for (int i = 0; i < 10; ++i) {
129- cout << getTicks() << " [msec]" << endl;
129+ cout << ticks() << " [msec]" << endl;
130130 delay(100);
131131 }
132132
--- trunk/libs/python/samples/hello.cpp (nonexistent)
+++ trunk/libs/python/samples/hello.cpp (revision 1761)
@@ -0,0 +1,37 @@
1+/*!
2+ http://www.boost.org/doc/libs/1_42_0/libs/python/doc/tutorial/
3+*/
4+
5+#include <string>
6+
7+
8+class World
9+{
10+public:
11+ void set(std::string msg)
12+ {
13+ msg_ = msg;
14+ }
15+
16+
17+ std::string greet(void)
18+ {
19+ return msg_;
20+ }
21+
22+private:
23+ std::string msg_;
24+};
25+
26+
27+#include <boost/python.hpp>
28+using namespace boost::python;
29+
30+
31+BOOST_PYTHON_MODULE(hello)
32+{
33+ class_<World>("World")
34+ .def("greet", &World::greet)
35+ .def("set", &World::set)
36+ ;
37+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/python/samples/hello.py (nonexistent)
+++ trunk/libs/python/samples/hello.py (revision 1761)
@@ -0,0 +1,6 @@
1+#!/usr/bin/env python
2+
3+import hello
4+planet = hello.World()
5+planet.set('howdy')
6+print planet.greet()
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/python/samples/Makefile (nonexistent)
+++ trunk/libs/python/samples/Makefile (revision 1761)
@@ -0,0 +1,29 @@
1+# Makefile for python
2+# Satofumi KAMIMURA
3+# $Id$
4+
5+# Compile options
6+CC = g++
7+CXXFLAGS = -g -O0 -Wall -Werror $(INCLUDES)
8+INCLUDES = -I/usr/include/python
9+LDFLAGS =
10+LDLIBS =
11+
12+
13+# Target
14+TARGET = hello.so
15+
16+
17+all : $(TARGET)
18+
19+clean :
20+ $(RM) *.o $(TARGET)
21+
22+depend :
23+ makedepend -Y -- $(INCLUDES) -- $(wildcard *.h *.cpp)
24+
25+.PHONY : all clean depend
26+######################################################################
27+hello.so : hello.cpp
28+ g++ -I`python -c 'from distutils.sysconfig import *; print get_python_inc()'` -DPIC -shared -fPIC -o hello.so hello.cpp -lboost_python
29+# DO NOT DELETE
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/lua/luabindGui.cpp (revision 1760)
+++ trunk/libs/lua/luabindGui.cpp (revision 1761)
@@ -17,6 +17,7 @@
1717 #include "Font.h"
1818 #include "TextSurface.h"
1919 #include "ColorSurface.h"
20+#include "FillSurface.h"
2021 #include "ImageSurface.h"
2122 #include "MultiSurface.h"
2223 #include "Label.h"
@@ -120,6 +121,12 @@
120121 .def("setAlpha", &ColorSurface::setAlpha)
121122 .def("draw", &ColorSurface::draw),
122123
124+ class_<FillSurface, Surface>("FillSurface")
125+ .def(constructor<const Rect<long>&, Surface&>())
126+ .def("rect", &FillSurface::rect)
127+ .def("setAlpha", &FillSurface::setAlpha)
128+ .def("draw", &FillSurface::draw),
129+
123130 class_<ImageSurface, Surface>("ImageSurface")
124131 .def(constructor<const char*, bool>())
125132 .def("rect", &ImageSurface::rect)
@@ -153,6 +160,7 @@
153160 value("Middle", Menu::Middle),
154161 value("Bottom", Menu::Bottom)
155162 ]
163+ .def("setPosition", &Menu::setPosition)
156164 .def(constructor<const Rect<long>&, Menu::Align>())
157165 .def("setButtonStep", &Menu::setButtonStep)
158166 .def("addButton", &Menu::addButton)
@@ -189,6 +197,15 @@
189197 ];
190198
191199 LuaHandler::registerValue(L, "SDLK_BACKSPACE", SDLK_BACKSPACE);
200+ LuaHandler::registerValue(L, "SDLK_ESCAPE", SDLK_ESCAPE);
201+ LuaHandler::registerValue(L, "SDLK_F4", SDLK_F4);
202+ LuaHandler::registerValue(L, "SDLK_q", SDLK_q);
203+
192204 LuaHandler::registerValue(L, "SDL_KEYDOWN", SDL_KEYDOWN);
205+
193206 LuaHandler::registerValue(L, "KMOD_NONE", KMOD_NONE);
207+ LuaHandler::registerValue(L, "KMOD_LCTRL", KMOD_LCTRL);
208+ LuaHandler::registerValue(L, "KMOD_RCTRL", KMOD_RCTRL);
209+ LuaHandler::registerValue(L, "KMOD_LALT", KMOD_LALT);
210+ LuaHandler::registerValue(L, "KMOD_RALT", KMOD_RALT);
194211 }
--- trunk/libs/lua/Makefile (revision 1760)
+++ trunk/libs/lua/Makefile (revision 1761)
@@ -47,6 +47,7 @@
4747 $(LUABIND_LIB)(luabindRangeFinder.o) \
4848 $(LUABIND_LIB)(luabindBeegoDrive.o) \
4949 $(LUABIND_LIB)(luabindUrgDistance.o) \
50+ $(LUABIND_LIB)(lua_runStateMachine.o) \
5051
5152 $(TOLUA_LIB) : \
5253 $(TOLUA_LIB)(toluaSystem.o) \
@@ -65,6 +66,8 @@
6566
6667 LuaHandler.o: LuaHandler.h ../system/log_printf.h
6768 TestScriptedStateMachine.o: TestScriptedStateMachine.h ScriptedStateMachine.h
69+lua_runStateMachine.o: lua_runStateMachine.h ScriptedStateMachine.h
70+lua_runStateMachine.o: LuaHandler.h luabindInit.h ../system/delay.h
6871 luabindAudio.o: luabindAudio.h ../audio/SoundEffect.h
6972 luabindBeegoDrive.o: luabindBeegoDrive.h ../monitoring/mBeegoDrive.h
7073 luabindBeegoDrive.o: ../coordinate/Coordinate.h ../geometry/Position.h
@@ -82,10 +85,10 @@
8285 luabindGui.o: ../gui/EventUtils.h ../gui/LayerManager.h
8386 luabindGui.o: ../gui/LayerInterface.h ../gui/Layer.h ../gui/Font.h
8487 luabindGui.o: ../common/Color.h ../gui/TextSurface.h ../gui/Surface.h
85-luabindGui.o: ../gui/ColorSurface.h ../gui/ImageSurface.h
86-luabindGui.o: ../gui/MultiSurface.h ../gui/Label.h ../gui/Component.h
87-luabindGui.o: ../gui/Button.h ../gui/Menu.h ../gui/ChatMessage.h
88-luabindGui.o: ../gui/CallbackEvent.h ../gui/AlignUtils.h
88+luabindGui.o: ../gui/ColorSurface.h ../gui/FillSurface.h
89+luabindGui.o: ../gui/ImageSurface.h ../gui/MultiSurface.h ../gui/Label.h
90+luabindGui.o: ../gui/Component.h ../gui/Button.h ../gui/Menu.h
91+luabindGui.o: ../gui/ChatMessage.h ../gui/CallbackEvent.h ../gui/AlignUtils.h
8992 luabindInit.o: luabindInit.h LuaHandler.h ../system/log_printf.h
9093 luabindNetwork.o: luabindNetwork.h
9194 luabindRangeFinder.o: luabindRangeFinder.h ../monitoring/mUrgDevice.h
--- trunk/libs/lua/lua_runStateMachine.h (nonexistent)
+++ trunk/libs/lua/lua_runStateMachine.h (revision 1761)
@@ -0,0 +1,21 @@
1+#ifndef LUA_RUN_STATE_MACHINE_H
2+#define LUA_RUN_STATE_MACHINE_H
3+
4+/*!
5+ \file
6+ \brief 状態遷移の実行
7+
8+ \author Satofumi KAMIMURA
9+
10+ $Id$
11+*/
12+
13+#include <lua.hpp>
14+
15+
16+namespace qrk
17+{
18+ extern void lua_runStateMachine(lua_State* L, const char* first_state);
19+}
20+
21+#endif /* !LUA_RUN_STATE_MACHINE_H */
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/lua/samples/tolua_delay.lua (revision 1760)
+++ trunk/libs/lua/samples/tolua_delay.lua (revision 1761)
@@ -1,5 +1,5 @@
11 print("wait 1000 [msec]")
2-print("current: " .. qrk.getTicks())
2+print("current: " .. qrk.ticks())
33 qrk.delay(1000)
44 print("end")
5-print("current: " .. qrk.getTicks())
5+print("current: " .. qrk.ticks())
--- trunk/libs/lua/lua_runStateMachine.cpp (nonexistent)
+++ trunk/libs/lua/lua_runStateMachine.cpp (revision 1761)
@@ -0,0 +1,76 @@
1+/*!
2+ \file
3+ \brief 状態遷移の実行
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "lua_runStateMachine.h"
11+#include "ScriptedStateMachine.h"
12+#include "LuaHandler.h"
13+#include "luabindInit.h"
14+#include "delay.h"
15+
16+#include <iostream>
17+
18+using namespace qrk;
19+using namespace luabind;
20+using namespace std;
21+
22+
23+namespace
24+{
25+ class EmptyStateMachine;
26+ typedef ScriptedStateMachine<EmptyStateMachine> ScriptedState;
27+
28+
29+ class EmptyStateMachine
30+ {
31+ ScriptedState state_machine_;
32+
33+
34+ public:
35+ EmptyStateMachine(void) : state_machine_(this)
36+ {
37+ }
38+
39+
40+ ScriptedState& stateMachine(void)
41+ {
42+ return state_machine_;
43+ }
44+ };
45+
46+
47+ void luabindStateMachine(lua_State* L)
48+ {
49+ module(L)
50+ [
51+ class_<EmptyStateMachine>("EmptyStateMachine")
52+ .def("stateMachine", &EmptyStateMachine::stateMachine),
53+
54+ class_<ScriptedState>("ScriptedStateMachine")
55+ .def("changeState", &ScriptedState::changeState)
56+ .def("changePreviousState", &ScriptedState::changePreviousState)
57+ ];
58+ }
59+}
60+
61+
62+void qrk::lua_runStateMachine(lua_State* L, const char* first_state)
63+{
64+ EmptyStateMachine state;
65+
66+ luabindStateMachine(L);
67+
68+ // 最初の状態を指定して実行
69+ object global_state = globals(L);
70+ state.stateMachine().changeState(global_state[first_state]);
71+
72+ while (true) {
73+ state.stateMachine().update();
74+ delay(1);
75+ }
76+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/gui/MultiSurface.cpp (revision 1760)
+++ trunk/libs/gui/MultiSurface.cpp (revision 1761)
@@ -80,11 +80,19 @@
8080
8181 void MultiSurface::setAlpha(float alpha)
8282 {
83+ (void)alpha;
84+
85+#if 1
86+ // !!! 各サーフェスの alpha 値に指定された alpha 値を掛けた値に
87+ // !!! 設定するように修正する
88+
89+#else
8390 pimpl->base_surface_.setAlpha(alpha);
8491
8592 // 登録済みのサーフェスに適用
8693 for_each(pimpl->surfaces_.begin(), pimpl->surfaces_.end(),
8794 bind(&Surface::setAlpha, _1, alpha));
95+#endif
8896 }
8997
9098
--- trunk/libs/gui/Makefile (revision 1760)
+++ trunk/libs/gui/Makefile (revision 1761)
@@ -54,6 +54,7 @@
5454 Component.o: ../geometry/Rect.h ../geometry/Point.h
5555 Event.o: ../geometry/Point.h
5656 EventManager.o: ../geometry/Point.h
57+FillSurface.o: Surface.h ../geometry/Rect.h
5758 Font.o: ../common/Color.h
5859 ImageSurface.o: Surface.h ../geometry/Rect.h
5960 Label.o: Component.h ../geometry/Rect.h ../geometry/Point.h
@@ -82,6 +83,7 @@
8283 EventManager.o: EventManager.h ../geometry/Point.h Event.h
8384 EventUtils.o: EventUtils.h CallbackEvent.h Event.h ../geometry/Point.h
8485 EventUtils.o: ../geometry/Rect.h
86+FillSurface.o: FillSurface.h Surface.h ../geometry/Rect.h Screen.h
8587 Font.o: ../system/DetectOS.h Font.h ../common/Color.h SdlTtfInit.h
8688 Font.o: ../system/log_printf.h
8789 ImageSurface.o: ImageSurface.h Surface.h ../geometry/Rect.h SDL_GL_Texture.h
--- trunk/libs/gui/Surface.h (revision 1760)
+++ trunk/libs/gui/Surface.h (revision 1761)
@@ -26,11 +26,25 @@
2626 {
2727 }
2828
29+ /*!
30+ \brief 不明
31+
32+ \todo このメソッドが何のためにあるのかを記述する
33+ */
2934 virtual bool isValid(void) const = 0;
35+
36+
3037 virtual Rect<long> rect(void) const = 0;
3138 virtual void setAlpha(float alpha) = 0;
3239 virtual float alpha(void) const = 0;
3340 virtual void setRotateAngle(const Angle& angle) = 0;
41+
42+
43+ /*!
44+ \brief 描画
45+
46+ \todo src, dest の意味を記述する
47+ */
3448 virtual void draw(const Rect<long>* src, const Rect<long>* dest) = 0;
3549 };
3650 }
--- trunk/libs/gui/FillSurface.cpp (revision 1760)
+++ trunk/libs/gui/FillSurface.cpp (revision 1761)
@@ -7,6 +7,7 @@
77 */
88
99 #include "FillSurface.h"
10+#include "Screen.h"
1011
1112 using namespace qrk;
1213
@@ -14,13 +15,13 @@
1415 struct FillSurface::pImpl
1516 {
1617 Rect<long> rect_;
18+ Rect<long> surface_rect_;
19+ Surface& surface_;
1720
1821
1922 pImpl(const Rect<long>& rect, Surface& surface)
20- : rect_(rect)
23+ : rect_(rect), surface_rect_(surface.rect()), surface_(surface)
2124 {
22- (void)surface;
23- // !!!
2425 }
2526 };
2627
@@ -38,8 +39,7 @@
3839
3940 bool FillSurface::isValid(void) const
4041 {
41- // !!!
42- return true;
42+ return pimpl->surface_.isValid();
4343 }
4444
4545
@@ -51,28 +51,40 @@
5151
5252 void FillSurface::setAlpha(float alpha)
5353 {
54- (void)alpha;
55- // !!!
54+ pimpl->surface_.setAlpha(alpha);
5655 }
5756
5857
5958 float FillSurface::alpha(void) const
6059 {
61- // !!!
62- return 1.0;
60+ return pimpl->surface_.alpha();
6361 }
6462
6563
6664 void FillSurface::setRotateAngle(const Angle& angle)
6765 {
68- (void)angle;
69- // !!!
66+ pimpl->surface_.setRotateAngle(angle);
7067 }
7168
7269
7370 void FillSurface::draw(const Rect<long>* src, const Rect<long>* dest)
7471 {
75- (void)src;
76- (void)dest;
77- // !!!
72+ if ((! dest) || (! pimpl->surface_.isValid())) {
73+ return;
74+ }
75+
76+ Screen::setClipArea(*dest);
77+
78+ // !!! src を考慮する
79+
80+ long w = pimpl->surface_rect_.w;
81+ long h = pimpl->surface_rect_.h;
82+ for (long y = 0; y <= dest->h; y += h) {
83+ for (long x = 0; x <= dest->w; x += w) {
84+ Rect<long> sub_dest(dest->x + x, dest->y + y, w, h);
85+ pimpl->surface_.draw(src, &sub_dest);
86+ }
87+ }
88+
89+ Screen::disableClipArea();
7890 }
--- trunk/libs/gui/samples/drawText.cpp (revision 1760)
+++ trunk/libs/gui/samples/drawText.cpp (revision 1761)
@@ -20,6 +20,7 @@
2020 {
2121 Screen screen;
2222 screen.show(SDL_OPENGL);
23+ screen.clear();
2324
2425 // フォントの読み出し
2526 const char* font_file = (argc <= 1) ? "font.ttf" : argv[1];
--- trunk/libs/gui/samples/drawColorSurface.cpp (nonexistent)
+++ trunk/libs/gui/samples/drawColorSurface.cpp (revision 1761)
@@ -0,0 +1,48 @@
1+/*!
2+ \example colorSurfaceSample.cpp ColorSurface の描画サンプル
3+
4+ \author Satofumi KAMIMURA
5+
6+ $Id$
7+*/
8+
9+#include "Screen.h"
10+#include "ColorSurface.h"
11+#include "ImageSurface.h"
12+#include "Color.h"
13+
14+using namespace qrk;
15+//using namespace std;
16+
17+
18+int main(int argc, char *argv[])
19+{
20+ static_cast<void>(argc);
21+ static_cast<void>(argv);
22+
23+ Screen screen;
24+ screen.show(Screen::OpenGL);
25+ screen.clear();
26+
27+ Surface* surface_1st =
28+ new ColorSurface(Rect<long>(0, 0, 100, 100), Color(1.0, 0.0, 0.0, 1.0));
29+ Rect<long> dest_1st(0, 0, 100, 100);
30+ surface_1st->draw(NULL, &dest_1st);
31+
32+ Surface* surface_2nd = new ImageSurface("cross_blue.bmp");
33+ Rect<long> dest_2nd = surface_2nd->rect();
34+ dest_2nd.x = 125;
35+ dest_2nd.y = 125;
36+ surface_2nd->draw(NULL, &dest_2nd);
37+
38+ Surface* surface_3rd =
39+ new ColorSurface(Rect<long>(0, 0, 100, 100), Color(0.4, 0.4, 1.0, 0.8));
40+ Rect<long> dest_3rd(50, 50, 100, 100);
41+ surface_3rd->draw(NULL, &dest_3rd);
42+
43+ // 描画内容を反映させる
44+ SDL_GL_SwapBuffers();
45+ SDL_Delay(1000);
46+
47+ return 0;
48+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/gui/samples/Makefile (revision 1760)
+++ trunk/libs/gui/samples/Makefile (revision 1761)
@@ -6,7 +6,7 @@
66 CXXFLAGS = -g -O0 -Wall -W -Werror $(INCLUDES) `sdl-config --cflags`
77 INCLUDES = -I.. -I../../geometry -I../../system -I../../common
88 LDFLAGS = -L/usr/X11/lib
9-LDLIBS = `sdl-config --libs` -lSDL_ttf -lGL -lboost_signals-mt
9+LDLIBS = `sdl-config --libs` -lSDL_ttf -lGL -lboost_signals-mt -lSDL_image
1010 #LDLIBS = `sdl-config --libs` -lSDL_ttf -lopengl32 -lboost_signals-mgw34-mt
1111
1212
@@ -24,6 +24,7 @@
2424 toggleScreen \
2525 buttonSample \
2626 menuSample \
27+ drawColorSurface \
2728
2829 all : $(TARGET)
2930
@@ -40,7 +41,7 @@
4041 $(REQUIRE_LIBS) :
4142 cd $(@D)/ && $(MAKE) $(@F)
4243
43-PROGRAMS = drawText handleEvent inputDraw chatMessageSample rectMove buttonSample menuSample
44+PROGRAMS = drawText handleEvent inputDraw chatMessageSample rectMove buttonSample menuSample drawColorSurface
4445 $(PROGRAMS) : $(REQUIRE_LIBS)
4546
4647 # DO NOT DELETE
@@ -56,6 +57,8 @@
5657 chatMessageSample.o: ../../common/Color.h ../ColorSurface.h ../Surface.h
5758 chatMessageSample.o: ../Label.h ../CallbackEvent.h ../Event.h ../EventUtils.h
5859 chatMessageSample.o: ../../system/delay.h
60+drawColorSurface.o: ../Screen.h ../../geometry/Rect.h ../ColorSurface.h
61+drawColorSurface.o: ../Surface.h ../../common/Color.h
5962 drawText.o: ../Screen.h ../../geometry/Rect.h ../Font.h ../../common/Color.h
6063 drawText.o: ../TextSurface.h ../Surface.h
6164 handleEvent.o: ../Screen.h ../../geometry/Rect.h ../CallbackEvent.h
--- trunk/libs/range_sensor/py/samples/simple_sample.py (revision 1760)
+++ trunk/libs/range_sensor/py/samples/simple_sample.py (revision 1761)
@@ -6,8 +6,8 @@
66 connection = serial.Serial(port, 115200)
77
88 # first, send "SCIP2.0" when sensor type is URG-04LX
9- #connection.write("SCIP2.0\n")
10- #time.sleep(0.1)
9+ connection.write("SCIP2.0\n")
10+ time.sleep(0.1)
1111
1212 # display sensor version.
1313 connection.write("VV\n")
--- trunk/libs/range_sensor/samples/decodeSample.cpp (revision 1760)
+++ trunk/libs/range_sensor/samples/decodeSample.cpp (revision 1761)
@@ -26,7 +26,6 @@
2626 printf("%ld\n", ScipHandler::decode("2<X", 3));
2727 printf("%ld\n", ScipHandler::decode("<b2", 3));
2828 printf("%ld\n", ScipHandler::decode("0DKO", 4));
29- printf("%ld\n", ScipHandler::decode("09\\n", 4));
3029
3130 return 0;
3231 }
--- trunk/libs/connection/Makefile (revision 1760)
+++ trunk/libs/connection/Makefile (revision 1761)
@@ -68,7 +68,7 @@
6868 StandardIo.o: ../system/DetectOS.h StandardIo_lin.cpp StandardIo.h
6969 StandardIo.o: Connection.h
7070 StandardIo_lin.o: StandardIo.h Connection.h
71-StandardIo_win.o: StandardIo.h Connection.h
71+StandardIo_win.o: StandardIo.h Connection.h ../system/delay.h
7272 TestSerialDevice.o: TestSerialDevice.h SerialDevice.h Connection.h
7373 TestSerialDevice.o: ../system/ticks.h ../system/DetectOS.h
7474 isUsingComDriver.o: isUsingComDriver.h ../system/DetectOS.h
旧リポジトリブラウザで表示